Loading...
Searching...
No Matches
rmodulon.cc File Reference
`#include "misc/auxiliary.h"`
`#include "misc/mylimits.h"`
`#include "misc/prime.h"`
`#include "reporter/reporter.h"`
`#include "coeffs/si_gmp.h"`
`#include "coeffs/coeffs.h"`
`#include "coeffs/modulop.h"`
`#include "coeffs/rintegers.h"`
`#include "coeffs/numbers.h"`
`#include "coeffs/mpr_complex.h"`
`#include "coeffs/longrat.h"`
`#include "coeffs/rmodulon.h"`
`#include <string.h>`

Go to the source code of this file.

## Macros

#define | nrnDelete nrzDelete
#define | nrnSize nrzSize

## Functions

void | nrnWrite (number a, const coeffs)
static BOOLEAN | nrnDBTest (number a, const char *f, const int l, const coeffs r)
coeffs | nrnInitCfByName (char *s, n_coeffType)
static char * | nrnCoeffName (const coeffs r)
static BOOLEAN | nrnCoeffIsEqual (const coeffs r, n_coeffType n, void *parameter)
static void | nrnKillChar (coeffs r)
static coeffs | nrnQuot1 (number c, const coeffs r)
static number | nrnCopy (number a, const coeffs)
static number | nrnInit (long i, const coeffs r)
static long | nrnInt (number &n, const coeffs)
static number | nrnMult (number a, number b, const coeffs r)
static void | nrnInpMult (number &a, number b, const coeffs r)
static void | nrnPower (number a, int i, number *result, const coeffs r)
static number | nrnAdd (number a, number b, const coeffs r)
static void | nrnInpAdd (number &a, number b, const coeffs r)
static number | nrnSub (number a, number b, const coeffs r)
static BOOLEAN | nrnIsZero (number a, const coeffs)
static number | nrnNeg (number c, const coeffs r)
static number | nrnInvers (number c, const coeffs r)
static number | nrnGcd (number a, number b, const coeffs r)
static number | nrnLcm (number a, number b, const coeffs r)
static number | nrnExtGcd (number a, number b, number *s, number *t, const coeffs r)
static BOOLEAN | nrnIsOne (number a, const coeffs)
static BOOLEAN | nrnEqual (number a, number b, const coeffs)
static number | nrnGetUnit (number k, const coeffs r)
static number | nrnXExtGcd (number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
static BOOLEAN | nrnIsMOne (number a, const coeffs r)
static BOOLEAN | nrnGreater (number a, number b, const coeffs)
static BOOLEAN | nrnGreaterZero (number k, const coeffs cf)
static BOOLEAN | nrnIsUnit (number a, const coeffs r)
static number | nrnAnn (number k, const coeffs r)
static BOOLEAN | nrnDivBy (number a, number b, const coeffs r)
static int | nrnDivComp (number a, number b, const coeffs r)
static number | nrnDiv (number a, number b, const coeffs r)
static number | nrnMod (number a, number b, const coeffs r)
static number | nrnQuotRem (number a, number b, number *rem, const coeffs r)
static number | nrnMapModN (number from, const coeffs, const coeffs dst)
static number | nrnMap2toM (number from, const coeffs, const coeffs dst)
static number | nrnMapZp (number from, const coeffs, const coeffs dst)
number | nrnMapGMP (number from, const coeffs, const coeffs dst)
static number | nrnMapQ (number from, const coeffs src, const coeffs dst)
static number | nrnMapZ (number from, const coeffs src, const coeffs dst)
nMapFunc | nrnSetMap (const coeffs src, const coeffs dst)
static number | nrnInitMPZ (mpz_t m, const coeffs r)
static void | nrnMPZ (mpz_t m, number &n, const coeffs)
static void | nrnSetExp (unsigned long m, coeffs r)
static void | nrnInitExp (unsigned long m, coeffs r)
static const char * | nlCPEatLongC (char *s, mpz_ptr i)
static const char * | nrnRead (const char *s, number *a, const coeffs r)
static number | nrnConvFactoryNSingN (const CanonicalForm n, const coeffs r)
static CanonicalForm | nrnConvSingNFactoryN (number n, BOOLEAN setChar, const coeffs r)
BOOLEAN | nrnInitChar (coeffs r, void *p)

## Variables

EXTERN_VAR omBin | gmp_nrz_bin
STATIC_VAR char * | nrnCoeffName_buff =NULL
STATIC_VAR mpz_ptr | nrnMapCoef = NULL

## Macro Definition Documentation

## nrnDelete

#define nrnDelete nrzDelete

Definition at line 175 of file rmodulon.cc.

## nrnSize

#define nrnSize nrzSize

Definition at line 176 of file rmodulon.cc.

## Function Documentation

## nlCPEatLongC()

const char * nlCPEatLongC | ( | char * | s,
|  | mpz_ptr | i )

static

Definition at line 929 of file rmodulon.cc.

{
const char * start=s;
if (!(*s >= '0' && *s <= '9'))
{
mpz_init_set_ui(i, 1);
return s;
}
mpz_init(i);
while (*s >= '0' && *s <= '9') s++;
if (*s=='\0')
{
mpz_set_str(i,start,10);
}
else
{
char c=*s;
*s='\0';
mpz_set_str(i,start,10);
*s=c;
}
return s;
}
i
int i
Definition cfEzgcd.cc:132
s
const CanonicalForm int s
Definition facAbsFact.cc:51

## nrnAdd()

number nrnAdd | ( | number | a,
|  | number | b,
|  | const coeffs | r )

static

Definition at line 218 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(erg);
mpz_add(erg, (mpz_ptr)a, (mpz_ptr) b);
mpz_mod(erg, erg, r->modNumber);
return (number) erg;
}
b
CanonicalForm b
Definition cfModGcd.cc:4111
omAllocBin
#define omAllocBin(bin)
Definition omAllocDecl.h:205
gmp_nrz_bin
VAR omBin gmp_nrz_bin
Definition rintegers.cc:23

## nrnAnn()

number nrnAnn | ( | number | k,
|  | const coeffs | r )

static

Definition at line 549 of file rmodulon.cc.

{
mpz_ptr tmp = (mpz_ptr) omAllocBin(gmp_nrz_bin);
mpz_init(tmp);
mpz_gcd(tmp, (mpz_ptr) k, r->modNumber);
if (mpz_cmp_si(tmp, 1)==0)
{
mpz_set_ui(tmp, 0);
return (number) tmp;
}
mpz_divexact(tmp, r->modNumber, tmp);
return (number) tmp;
}
k
int k
Definition cfEzgcd.cc:99

## nrnCoeffIsEqual()

BOOLEAN nrnCoeffIsEqual | ( | const coeffs | r,
|  | n_coeffType | n,
|  | void * | parameter )

static

Definition at line 87 of file rmodulon.cc.

{
/* test, if r is an instance of nInitCoeffs(n,parameter) */
ZnmInfo *info=(ZnmInfo*)parameter;
return (n==r->type) && (r->modExponent==info->exp)
&& (mpz_cmp(r->modBase,info->base)==0);
}
info
#define info
Definition libparse.cc:1256
ZnmInfo
Definition rmodulon.h:17

## nrnCoeffName()

char * nrnCoeffName | ( | const coeffs | r | ) |

static

Definition at line 64 of file rmodulon.cc.

{
if(nrnCoeffName_buff!=NULL) omFree(nrnCoeffName_buff);
size_t l = (size_t)mpz_sizeinbase(r->modBase, 10) + 2;
char* s = (char*) omAlloc(l);
l+=24;
nrnCoeffName_buff=(char*)omAlloc(l);
s= mpz_get_str (s, 10, r->modBase);
int ll=0;
if (nCoeff_is_Zn(r))
{
if (strlen(s)<10)
ll=snprintf(nrnCoeffName_buff,l,"ZZ/(%s)",s);
else
ll=snprintf(nrnCoeffName_buff,l,"ZZ/bigint(%s)",s);
}
else if (nCoeff_is_Ring_PtoM(r))
ll=snprintf(nrnCoeffName_buff,l,"ZZ/(bigint(%s)^%lu)",s,r->modExponent);
assume(ll<(int)l); // otherwise nrnCoeffName_buff too small
omFreeSize((ADDRESS)s, l-22);
return nrnCoeffName_buff;
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
l
int l
Definition cfEzgcd.cc:100
nCoeff_is_Ring_PtoM
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r)
Definition coeffs.h:729
nCoeff_is_Zn
static FORCE_INLINE BOOLEAN nCoeff_is_Zn(const coeffs r)
Definition coeffs.h:821
assume
#define assume(x)
Definition mod2.h:389
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
NULL
#define NULL
Definition omList.c:12
nrnCoeffName_buff
STATIC_VAR char * nrnCoeffName_buff
Definition rmodulon.cc:63

## nrnConvFactoryNSingN()

number nrnConvFactoryNSingN | ( | const CanonicalForm | n,
|  | const coeffs | r )

static

Definition at line 979 of file rmodulon.cc.

{
return nrnInit(n.intval(),r);
}
CanonicalForm::intval
long intval() const
conversion functions
Definition canonicalform.cc:200
nrnInit
static number nrnInit(long i, const coeffs r)
Definition rmodulon.cc:158

## nrnConvSingNFactoryN()

CanonicalForm nrnConvSingNFactoryN | ( | number | n,
|  | BOOLEAN | setChar,
|  | const coeffs | r )

static

Definition at line 984 of file rmodulon.cc.

{
if (setChar) setCharacteristic( r->ch );
return CanonicalForm(nrnInt( n,r ));
}
setCharacteristic
void FACTORY_PUBLIC setCharacteristic(int c)
Definition cf_char.cc:28
CanonicalForm
factory's main class
Definition canonicalform.h:86
nrnInt
static long nrnInt(number &n, const coeffs)
Definition rmodulon.cc:169

## nrnCopy()

number nrnCopy | ( | number | a,
|  | const coeffs | )

static

Definition at line 148 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
mpz_init_set(erg, (mpz_ptr) a);
return (number) erg;
}

## nrnDBTest()

BOOLEAN nrnDBTest | ( | number | a,
|  | const char * | f,
|  | const int | l,
|  | const coeffs | r )

static

Definition at line 915 of file rmodulon.cc.

{
if ( (mpz_sgn1((mpz_ptr) a) < 0) || (mpz_cmp((mpz_ptr) a, r->modNumber) > 0) )
{
Warn("mod-n: out of range at %s:%d\n",f,l);
return FALSE;
}
return TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
f
FILE * f
Definition checklibs.c:9
Warn
#define Warn
Definition emacs.cc:77
mpz_sgn1
#define mpz_sgn1(A)
Definition si_gmp.h:18

## nrnDiv()

number nrnDiv | ( | number | a,
|  | number | b,
|  | const coeffs | r )

static

Definition at line 581 of file rmodulon.cc.

{
if (nrnIsZero(b,r))
{
WerrorS(nDivBy0);
return nrnInit(0,r);
}
else if (r->is_field)
{
number inv=nrnInvers(b,r);
number erg=nrnMult(a,inv,r);
nrnDelete(&inv,r);
return erg;
}
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(erg);
if (mpz_divisible_p((mpz_ptr)a, (mpz_ptr)b))
{
mpz_divexact(erg, (mpz_ptr)a, (mpz_ptr)b);
return (number)erg;
}
else
{
mpz_ptr gcd = (mpz_ptr)nrnGcd(a, b, r);
mpz_divexact(erg, (mpz_ptr)b, gcd);
if (!nrnIsUnit((number)erg, r))
{
WerrorS("Division not possible, even by cancelling zero divisors.");
nrnDelete((number*) &gcd, r);
nrnDelete((number*) &erg, r);
return (number)NULL;
}
// a / gcd(a,b) * [b / gcd (a,b)]^(-1)
mpz_ptr tmp = (mpz_ptr)nrnInvers((number) erg,r);
mpz_divexact(erg, (mpz_ptr)a, gcd);
mpz_mul(erg, erg, tmp);
nrnDelete((number*) &gcd, r);
nrnDelete((number*) &tmp, r);
mpz_mod(erg, erg, r->modNumber);
return (number)erg;
}
}
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
nDivBy0
const char *const nDivBy0
Definition numbers.h:90
nrnIsZero
static BOOLEAN nrnIsZero(number a, const coeffs)
Definition rmodulon.cc:242
nrnIsUnit
static BOOLEAN nrnIsUnit(number a, const coeffs r)
Definition rmodulon.cc:541
nrnDelete
#define nrnDelete
Definition rmodulon.cc:175
nrnInvers
static number nrnInvers(number c, const coeffs r)
Definition rmodulon.cc:255
nrnMult
static number nrnMult(number a, number b, const coeffs r)
Definition rmodulon.cc:195
nrnGcd
static number nrnGcd(number a, number b, const coeffs r)
Definition rmodulon.cc:275
gcd
int gcd(int a, int b)
Definition walkSupport.cc:836

## nrnDivBy()

BOOLEAN nrnDivBy | ( | number | a,
|  | number | b,
|  | const coeffs | r )

static

Definition at line 563 of file rmodulon.cc.

{
/* b divides a iff b/gcd(a, b) is a unit in the given ring: */
number n = nrnGcd(a, b, r);
mpz_tdiv_q((mpz_ptr)n, (mpz_ptr)b, (mpz_ptr)n);
bool result = nrnIsUnit(n, r);
nrnDelete(&n, NULL);
return result;
}
result
return result
Definition facAbsBiFact.cc:76

## nrnDivComp()

int nrnDivComp | ( | number | a,
|  | number | b,
|  | const coeffs | r )

static

Definition at line 573 of file rmodulon.cc.

{
if (nrnEqual(a, b,r)) return 2;
if (mpz_divisible_p((mpz_ptr) a, (mpz_ptr) b)) return -1;
if (mpz_divisible_p((mpz_ptr) b, (mpz_ptr) a)) return 1;
return 0;
}
nrnEqual
static BOOLEAN nrnEqual(number a, number b, const coeffs)
Definition rmodulon.cc:348

## nrnEqual()

BOOLEAN nrnEqual | ( | number | a,
|  | number | b,
|  | const coeffs | )

static

Definition at line 348 of file rmodulon.cc.

{
return 0 == mpz_cmp((mpz_ptr)a, (mpz_ptr)b);
}

## nrnExtGcd()

number nrnExtGcd | ( | number | a,
|  | number | b,
|  | number * | s,
|  | number * | t,
|  | const coeffs | r )

static

Definition at line 327 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_ptr bs = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_ptr bt = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(erg);
mpz_init(bs);
mpz_init(bt);
mpz_gcdext(erg, bs, bt, (mpz_ptr)a, (mpz_ptr)b);
mpz_mod(bs, bs, r->modNumber);
mpz_mod(bt, bt, r->modNumber);
*s = (number)bs;
*t = (number)bt;
return (number)erg;
}

## nrnGcd()

number nrnGcd | ( | number | a,
|  | number | b,
|  | const coeffs | r )

static

Definition at line 275 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init_set(erg, r->modNumber);
if (a != NULL) mpz_gcd(erg, erg, (mpz_ptr)a);
mpz_gcd(erg, erg, (mpz_ptr)b);
if(mpz_cmp(erg,r->modNumber)==0)
{
mpz_clear(erg);
omFreeBin((ADDRESS)erg,gmp_nrz_bin);
return nrnInit(0,r);
}
return (number)erg;
}
omFreeBin
#define omFreeBin(addr, bin)
Definition omAllocDecl.h:259

## nrnGetUnit()

number nrnGetUnit | ( | number | k,
|  | const coeffs | r )

static

Definition at line 353 of file rmodulon.cc.

{
if (mpz_divisible_p(r->modNumber, (mpz_ptr)k)) return nrnInit(1,r);
mpz_ptr unit = (mpz_ptr)nrnGcd(NULL, k, r);
mpz_tdiv_q(unit, (mpz_ptr)k, unit);
mpz_ptr gcd = (mpz_ptr)nrnGcd(NULL, (number)unit, r);
if (!nrnIsOne((number)gcd,r))
{
mpz_ptr ctmp;
// tmp := unit^2
mpz_ptr tmp = (mpz_ptr) nrnMult((number) unit,(number) unit,r);
// gcd_new := gcd(tmp, 0)
mpz_ptr gcd_new = (mpz_ptr) nrnGcd(NULL, (number) tmp, r);
while (!nrnEqual((number) gcd_new,(number) gcd,r))
{
// gcd := gcd_new
ctmp = gcd;
gcd = gcd_new;
gcd_new = ctmp;
// tmp := tmp * unit
mpz_mul(tmp, tmp, unit);
mpz_mod(tmp, tmp, r->modNumber);
// gcd_new := gcd(tmp, 0)
mpz_gcd(gcd_new, tmp, r->modNumber);
}
// unit := unit + modNumber / gcd_new
mpz_tdiv_q(tmp, r->modNumber, gcd_new);
mpz_add(unit, unit, tmp);
mpz_mod(unit, unit, r->modNumber);
nrnDelete((number*) &gcd_new, r);
nrnDelete((number*) &tmp, r);
}
nrnDelete((number*) &gcd, r);
return (number)unit;
}
nrnIsOne
static BOOLEAN nrnIsOne(number a, const coeffs)
Definition rmodulon.cc:343

## nrnGreater()

BOOLEAN nrnGreater | ( | number | a,
|  | number | b,
|  | const coeffs | )

static

Definition at line 500 of file rmodulon.cc.

{
return 0 < mpz_cmp((mpz_ptr)a, (mpz_ptr)b);
}

## nrnGreaterZero()

BOOLEAN nrnGreaterZero | ( | number | k,
|  | const coeffs | cf )

static

Definition at line 505 of file rmodulon.cc.

{
if (cf->is_field)
{
if (mpz_cmp_ui(cf->modBase,2)==0)
{
return TRUE;
}
#if 0
mpz_t ch2; mpz_init_set(ch2, cf->modBase);
mpz_sub_ui(ch2,ch2,1); //cf->modBase is odd
mpz_divexact_ui(ch2,ch2,2);
if (mpz_cmp(ch2,(mpz_ptr)k)<0)
{
mpz_clear(ch2);
return FALSE;
}
mpz_clear(ch2);
#endif
}
#if 0
else
{
mpz_t ch2; mpz_init_set(ch2, cf->modBase);
mpz_tdiv_q_ui(ch2,ch2,2);
if (mpz_cmp(ch2,(mpz_ptr)k)<0)
{
mpz_clear(ch2);
return FALSE;
}
mpz_clear(ch2);
}
#endif
return 0 < mpz_sgn1((mpz_ptr)k);
}
cf
CanonicalForm cf
Definition cfModGcd.cc:4091

## nrnInit()

number nrnInit | ( | long | i,
|  | const coeffs | r )

static

Definition at line 158 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
mpz_init_set_si(erg, i);
mpz_mod(erg, erg, r->modNumber);
return (number) erg;
}

## nrnInitCfByName()

coeffs nrnInitCfByName | ( | char * | s,
|  | n_coeffType | n )

Definition at line 33 of file rmodulon.cc.

{
const char start[]="ZZ/bigint(";
const int start_len=strlen(start);
if (strncmp(s,start,start_len)==0)
{
s+=start_len;
mpz_t z;
mpz_init(z);
s=nEatLong(s,z);
ZnmInfo info;
info.base=z;
info.exp= 1;
while ((*s!='\0') && (*s!=')')) s++;
// expect ")" or ")^exp"
if (*s=='\0') { mpz_clear(z); return NULL; }
if (((*s)==')') && (*(s+1)=='^'))
{
s=s+2;
int i;
s=nEati(s,&i,0);
info.exp=(unsigned long)i;
return nInitChar(n_Znm,(void*) &info);
}
else
return nInitChar(n_Zn,(void*) &info);
}
else return NULL;
}
n_Znm
@ n_Znm
only used if HAVE_RINGS is defined
Definition coeffs.h:45
n_Zn
@ n_Zn
only used if HAVE_RINGS is defined
Definition coeffs.h:44
nInitChar
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:412
nEati
char * nEati(char *s, int *i, int m)
divide by the first (leading) number and return it, i.e. make monic
Definition numbers.cc:672
nEatLong
char * nEatLong(char *s, mpz_ptr i)
extracts a long integer from s, returns the rest
Definition numbers.cc:713

## nrnInitChar()

BOOLEAN nrnInitChar | ( | coeffs | r,
|  | void * | p )

Definition at line 991 of file rmodulon.cc.

{
assume( (getCoeffType(r) == n_Zn) || (getCoeffType (r) == n_Znm) );
ZnmInfo * info= (ZnmInfo *) p;
r->modBase= (mpz_ptr)nrnCopy((number)info->base, r); //this circumvents the problem
//in bigintmat.cc where we cannot create a "legal" nrn that can be freed.
//If we take a copy, we can do whatever we want.
nrnInitExp (info->exp, r);
/* next computation may yield wrong characteristic as r->modNumber
is a GMP number */
r->ch = mpz_get_ui(r->modNumber);
r->is_field=FALSE;
r->is_domain=FALSE;
r->rep=n_rep_gmp;
r->cfInit = nrnInit;
r->cfDelete = nrnDelete;
r->cfCopy = nrnCopy;
r->cfSize = nrnSize;
r->cfInt = nrnInt;
r->cfAdd = nrnAdd;
r->cfInpAdd = nrnInpAdd;
r->cfSub = nrnSub;
r->cfMult = nrnMult;
r->cfInpMult = nrnInpMult;
r->cfDiv = nrnDiv;
r->cfAnn = nrnAnn;
r->cfIntMod = nrnMod;
r->cfExactDiv = nrnDiv;
r->cfInpNeg = nrnNeg;
r->cfInvers = nrnInvers;
r->cfDivBy = nrnDivBy;
r->cfDivComp = nrnDivComp;
r->cfGreater = nrnGreater;
r->cfEqual = nrnEqual;
r->cfIsZero = nrnIsZero;
r->cfIsOne = nrnIsOne;
r->cfIsMOne = nrnIsMOne;
r->cfGreaterZero = nrnGreaterZero;
r->cfWriteLong = nrnWrite;
r->cfRead = nrnRead;
r->cfPower = nrnPower;
r->cfSetMap = nrnSetMap;
//r->cfNormalize = ndNormalize;
r->cfLcm = nrnLcm;
r->cfGcd = nrnGcd;
r->cfIsUnit = nrnIsUnit;
r->cfGetUnit = nrnGetUnit;
r->cfExtGcd = nrnExtGcd;
r->cfXExtGcd = nrnXExtGcd;
r->cfQuotRem = nrnQuotRem;
r->cfCoeffName = nrnCoeffName;
r->nCoeffIsEqual = nrnCoeffIsEqual;
r->cfKillChar = nrnKillChar;
r->cfQuot1 = nrnQuot1;
r->cfInitMPZ = nrnInitMPZ;
r->cfMPZ = nrnMPZ;
#if SI_INTEGER_VARIANT==2
r->cfWriteFd = nrzWriteFd;
r->cfWriteFd_S = nrzWriteFd_S;
r->cfReadFd = nrzReadFd;
r->cfReadFd_S = nrzReadFd_S;
#endif
#ifdef LDEBUG
r->cfDBTest = nrnDBTest;
#endif
if ((r->modExponent==1)&&(mpz_size1(r->modBase)==1))
{
long p=mpz_get_si(r->modBase);
if ((p<=FACTORY_MAX_PRIME)&&(p==IsPrime(p))) /*factory limit: <2^29*/
{
r->convFactoryNSingN=nrnConvFactoryNSingN;
r->convSingNFactoryN=nrnConvSingNFactoryN;
}
}
return FALSE;
}
p
int p
Definition cfModGcd.cc:4086
getCoeffType
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition coeffs.h:431
n_rep_gmp
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
Definition coeffs.h:122
FACTORY_MAX_PRIME
#define FACTORY_MAX_PRIME
Definition modulop.h:38
IsPrime
int IsPrime(int p)
Definition prime.cc:61
nrzReadFd
number nrzReadFd(const ssiInfo *d, const coeffs)
nrzWriteFd_S
void nrzWriteFd_S(number n, const coeffs)
nrzReadFd_S
number nrzReadFd_S(char **s, const coeffs)
nrzWriteFd
void nrzWriteFd(number n, const ssiInfo *d, const coeffs)
nrnQuot1
static coeffs nrnQuot1(number c, const coeffs r)
Definition rmodulon.cc:103
nrnDBTest
static BOOLEAN nrnDBTest(number a, const char *f, const int l, const coeffs r)
Definition rmodulon.cc:915
nrnKillChar
static void nrnKillChar(coeffs r)
Definition rmodulon.cc:95
nrnSize
#define nrnSize
Definition rmodulon.cc:176
nrnGreater
static BOOLEAN nrnGreater(number a, number b, const coeffs)
Definition rmodulon.cc:500
nrnConvSingNFactoryN
static CanonicalForm nrnConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition rmodulon.cc:984
nrnExtGcd
static number nrnExtGcd(number a, number b, number *s, number *t, const coeffs r)
Definition rmodulon.cc:327
nrnMPZ
static void nrnMPZ(mpz_t m, number &n, const coeffs)
Definition rmodulon.cc:883
nrnCoeffIsEqual
static BOOLEAN nrnCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition rmodulon.cc:87
nrnInpMult
static void nrnInpMult(number &a, number b, const coeffs r)
Definition rmodulon.cc:204
nrnWrite
void nrnWrite(number a, const coeffs)
Definition rmodulon.cc:777
nrnMod
static number nrnMod(number a, number b, const coeffs r)
Definition rmodulon.cc:624
nrnInitMPZ
static number nrnInitMPZ(mpz_t m, const coeffs r)
Definition rmodulon.cc:875
nrnInitExp
static void nrnInitExp(unsigned long m, coeffs r)
Definition rmodulon.cc:904
nrnAnn
static number nrnAnn(number k, const coeffs r)
Definition rmodulon.cc:549
nrnSetMap
nMapFunc nrnSetMap(const coeffs src, const coeffs dst)
Definition rmodulon.cc:794
nrnConvFactoryNSingN
static number nrnConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition rmodulon.cc:979
nrnDivComp
static int nrnDivComp(number a, number b, const coeffs r)
Definition rmodulon.cc:573
nrnRead
static const char * nrnRead(const char *s, number *a, const coeffs r)
Definition rmodulon.cc:953
nrnXExtGcd
static number nrnXExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
Definition rmodulon.cc:399
nrnQuotRem
static number nrnQuotRem(number a, number b, number *rem, const coeffs r)
Definition rmodulon.cc:671
nrnCopy
static number nrnCopy(number a, const coeffs)
Definition rmodulon.cc:148
nrnSub
static number nrnSub(number a, number b, const coeffs r)
Definition rmodulon.cc:233
nrnLcm
static number nrnLcm(number a, number b, const coeffs r)
Definition rmodulon.cc:294
nrnPower
static void nrnPower(number a, int i, number *result, const coeffs r)
Definition rmodulon.cc:210
nrnNeg
static number nrnNeg(number c, const coeffs r)
Definition rmodulon.cc:247
nrnGetUnit
static number nrnGetUnit(number k, const coeffs r)
Definition rmodulon.cc:353
nrnCoeffName
static char * nrnCoeffName(const coeffs r)
Definition rmodulon.cc:64
nrnDiv
static number nrnDiv(number a, number b, const coeffs r)
Definition rmodulon.cc:581
nrnIsMOne
static BOOLEAN nrnIsMOne(number a, const coeffs r)
Definition rmodulon.cc:490
nrnDivBy
static BOOLEAN nrnDivBy(number a, number b, const coeffs r)
Definition rmodulon.cc:563
nrnGreaterZero
static BOOLEAN nrnGreaterZero(number k, const coeffs cf)
Definition rmodulon.cc:505
nrnAdd
static number nrnAdd(number a, number b, const coeffs r)
Definition rmodulon.cc:218
nrnInpAdd
static void nrnInpAdd(number &a, number b, const coeffs r)
Definition rmodulon.cc:227
mpz_size1
#define mpz_size1(A)
Definition si_gmp.h:17

## nrnInitExp()

void nrnInitExp | ( | unsigned long | m,
|  | coeffs | r )

static

Definition at line 904 of file rmodulon.cc.

{
nrnSetExp(m, r);
assume (r->modNumber != NULL);
//CF: in general, the modulus is computed somewhere. I don't want to
// check it's size before I construct the best ring.
// if (mpz_cmp_ui(r->modNumber,2) <= 0)
// WarnS("nrnInitExp failed (m in Z/m too small)");
}
m
int m
Definition cfEzgcd.cc:128
nrnSetExp
static void nrnSetExp(unsigned long m, coeffs r)
Definition rmodulon.cc:892

## nrnInitMPZ()

number nrnInitMPZ | ( | mpz_t | m,
|  | const coeffs | r )

static

Definition at line 875 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init_set(erg,m);
mpz_mod(erg, erg, r->modNumber);
return (number) erg;
}

## nrnInpAdd()

void nrnInpAdd | ( | number & | a,
|  | number | b,
|  | const coeffs | r )

static

Definition at line 227 of file rmodulon.cc.

{
mpz_add((mpz_ptr)a, (mpz_ptr)a, (mpz_ptr) b);
mpz_mod((mpz_ptr)a, (mpz_ptr)a, r->modNumber);
}

## nrnInpMult()

void nrnInpMult | ( | number & | a,
|  | number | b,
|  | const coeffs | r )

static

Definition at line 204 of file rmodulon.cc.

{
mpz_mul((mpz_ptr)a, (mpz_ptr)a, (mpz_ptr) b);
mpz_mod((mpz_ptr)a, (mpz_ptr)a, r->modNumber);
}

## nrnInt()

long nrnInt | ( | number & | n,
|  | const coeffs | )

static

Definition at line 169 of file rmodulon.cc.

{
return mpz_get_si((mpz_ptr) n);
}

## nrnInvers()

number nrnInvers | ( | number | c,
|  | const coeffs | r )

static

Definition at line 255 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(erg);
if (nrnIsZero(c,r))
{
WerrorS(nDivBy0);
}
else
{
mpz_invert(erg, (mpz_ptr)c, r->modNumber);
}
return (number) erg;
}

## nrnIsMOne()

BOOLEAN nrnIsMOne | ( | number | a,
|  | const coeffs | r )

static

Definition at line 490 of file rmodulon.cc.

{
if((r->ch==2) && (nrnIsOne(a,r))) return FALSE;
mpz_t t; mpz_init_set(t, (mpz_ptr)a);
mpz_add_ui(t, t, 1);
bool erg = (0 == mpz_cmp(t, r->modNumber));
mpz_clear(t);
return erg;
}

## nrnIsOne()

BOOLEAN nrnIsOne | ( | number | a,
|  | const coeffs | )

static

Definition at line 343 of file rmodulon.cc.

{
return 0 == mpz_cmp_si((mpz_ptr)a, 1);
}

## nrnIsUnit()

BOOLEAN nrnIsUnit | ( | number | a,
|  | const coeffs | r )

static

Definition at line 541 of file rmodulon.cc.

{
number tmp = nrnGcd(a, (number)r->modNumber, r);
bool res = nrnIsOne(tmp, r);
nrnDelete(&tmp, r);
return res;
}
res
CanonicalForm res
Definition facAbsFact.cc:60

## nrnIsZero()

BOOLEAN nrnIsZero | ( | number | a,
|  | const coeffs | )

static

Definition at line 242 of file rmodulon.cc.

{
return 0 == mpz_sgn1((mpz_ptr)a);
}

## nrnKillChar()

void nrnKillChar | ( | coeffs | r | ) |

static

Definition at line 95 of file rmodulon.cc.

{
mpz_clear(r->modNumber);
mpz_clear(r->modBase);
omFreeBin((void *) r->modBase, gmp_nrz_bin);
omFreeBin((void *) r->modNumber, gmp_nrz_bin);
}

## nrnLcm()

number nrnLcm | ( | number | a,
|  | number | b,
|  | const coeffs | r )

static

Definition at line 294 of file rmodulon.cc.

{
number erg = nrnGcd(NULL, a, r);
number tmp = nrnGcd(NULL, b, r);
mpz_lcm((mpz_ptr)erg, (mpz_ptr)erg, (mpz_ptr)tmp);
nrnDelete(&tmp, r);
return (number)erg;
}

## nrnMap2toM()

number nrnMap2toM | ( | number | from,
|  | const coeffs | ,
|  | const coeffs | dst )

static

Definition at line 714 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(erg);
mpz_mul_ui(erg, nrnMapCoef, (unsigned long)from);
mpz_mod(erg, erg, dst->modNumber);
return (number)erg;
}
nrnMapCoef
STATIC_VAR mpz_ptr nrnMapCoef
Definition rmodulon.cc:707

## nrnMapGMP()

number nrnMapGMP | ( | number | from,
|  | const coeffs | ,
|  | const coeffs | dst )

Definition at line 733 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(erg);
mpz_mod(erg, (mpz_ptr)from, dst->modNumber);
return (number)erg;
}

## nrnMapModN()

number nrnMapModN | ( | number | from,
|  | const coeffs | ,
|  | const coeffs | dst )

static

Definition at line 709 of file rmodulon.cc.

{
return nrnMult(from, (number) nrnMapCoef, dst);
}

## nrnMapQ()

number nrnMapQ | ( | number | from,
|  | const coeffs | src,
|  | const coeffs | dst )

static

Definition at line 741 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
nlMPZ(erg, from, src);
mpz_mod(erg, erg, dst->modNumber);
return (number)erg;
}
nlMPZ
void nlMPZ(mpz_t m, number &n, const coeffs r)
get numerator as mpz_t
Definition longrat.cc:2790

## nrnMapZ()

number nrnMapZ | ( | number | from,
|  | const coeffs | src,
|  | const coeffs | dst )

static

Definition at line 762 of file rmodulon.cc.

{
if (SR_HDL(from) & SR_INT)
{
long f_i=SR_TO_INT(from);
return nrnInit(f_i,dst);
}
return nrnMapGMP(from,src,dst);
}
SR_INT
#define SR_INT
Definition longrat.h:67
SR_TO_INT
#define SR_TO_INT(SR)
Definition longrat.h:69
nrnMapGMP
number nrnMapGMP(number from, const coeffs, const coeffs dst)
Definition rmodulon.cc:733
SR_HDL
#define SR_HDL(A)
Definition tgb.cc:35

## nrnMapZp()

number nrnMapZp | ( | number | from,
|  | const coeffs | ,
|  | const coeffs | dst )

static

Definition at line 723 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(erg);
// TODO: use npInt(...)
mpz_mul_si(erg, nrnMapCoef, (unsigned long)from);
mpz_mod(erg, erg, dst->modNumber);
return (number)erg;
}
mpz_mul_si
void mpz_mul_si(mpz_ptr r, mpz_srcptr s, long int si)
Definition longrat.cc:177

## nrnMod()

number nrnMod | ( | number | a,
|  | number | b,
|  | const coeffs | r )

static

Definition at line 624 of file rmodulon.cc.

{
/*
We need to return the number rr which is uniquely determined by the
following two properties:
(1) 0 <= rr < |b| (with respect to '<' and '<=' performed in Z x Z)
(2) There exists some k in the integers Z such that a = k * b + rr.
Consider g := gcd(n, |b|). Note that then |b|/g is a unit in Z/n.
Now, there are three cases:
(a) g = 1
Then |b| is a unit in Z/n, i.e. |b| (and also b) divides a.
Thus rr = 0.
(b) g <> 1 and g divides a
Then a = (a/g) * (|b|/g)^(-1) * b (up to sign), i.e. again rr = 0.
(c) g <> 1 and g does not divide a
Then denote the division with remainder of a by g as this:
a = s * g + t. Then t = a - s * g = a - s * (|b|/g)^(-1) * |b|
fulfills (1) and (2), i.e. rr := t is the correct result. Hence
in this third case, rr is the remainder of division of a by g in Z.
Remark: according to mpz_mod: a,b are always non-negative
*/
mpz_ptr g = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_ptr rr = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(g);
mpz_init_set_ui(rr, 0);
mpz_gcd(g, (mpz_ptr)r->modNumber, (mpz_ptr)b); // g is now as above
if (mpz_cmp_si(g, 1L) != 0) mpz_mod(rr, (mpz_ptr)a, g); // the case g <> 1
mpz_clear(g);
omFreeBin(g, gmp_nrz_bin);
return (number)rr;
}
g
g
Definition cfModGcd.cc:4098

## nrnMPZ()

void nrnMPZ | ( | mpz_t | m,
|  | number & | n,
|  | const coeffs | )

static

Definition at line 883 of file rmodulon.cc.

{
mpz_init_set(m, (mpz_ptr)n);
}

## nrnMult()

number nrnMult | ( | number | a,
|  | number | b,
|  | const coeffs | r )

static

Definition at line 195 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(erg);
mpz_mul(erg, (mpz_ptr)a, (mpz_ptr) b);
mpz_mod(erg, erg, r->modNumber);
return (number) erg;
}

## nrnNeg()

number nrnNeg | ( | number | c,
|  | const coeffs | r )

static

Definition at line 247 of file rmodulon.cc.

{
if( !nrnIsZero(c, r) )
// Attention: This method operates in-place.
mpz_sub((mpz_ptr)c, r->modNumber, (mpz_ptr)c);
return c;
}

## nrnPower()

void nrnPower | ( | number | a,
|  | int | i,
|  | number * | result,
|  | const coeffs | r )

static

Definition at line 210 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(erg);
mpz_powm_ui(erg, (mpz_ptr)a, i, r->modNumber);
*result = (number) erg;
}

## nrnQuot1()

coeffs nrnQuot1 | ( | number | c,
|  | const coeffs | r )

static

Definition at line 103 of file rmodulon.cc.

{
coeffs rr;
long ch = r->cfInt(c, r);
mpz_t a,b;
mpz_init_set(a, r->modNumber);
mpz_init_set_ui(b, ch);
mpz_t gcd;
mpz_init(gcd);
mpz_gcd(gcd, a,b);
if(mpz_cmp_ui(gcd, 1) == 0)
{
WerrorS("constant in q-ideal is coprime to modulus in ground ring");
WerrorS("Unable to create qring!");
return NULL;
}
if(r->modExponent == 1)
{
ZnmInfo info;
info.base = gcd;
info.exp = (unsigned long) 1;
rr = nInitChar(n_Zn, (void*)&info);
}
else
{
ZnmInfo info;
info.base = r->modBase;
int kNew = 1;
mpz_t baseTokNew;
mpz_init(baseTokNew);
mpz_set(baseTokNew, r->modBase);
while(mpz_cmp(gcd, baseTokNew) > 0)
{
kNew++;
mpz_mul(baseTokNew, baseTokNew, r->modBase);
}
//printf("\nkNew = %i\n",kNew);
info.exp = kNew;
mpz_clear(baseTokNew);
rr = nInitChar(n_Znm, (void*)&info);
}
mpz_clear(gcd);
return(rr);
}
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.

## nrnQuotRem()

number nrnQuotRem | ( | number | a,
|  | number | b,
|  | number * | rem,
|  | const coeffs | r )

static

Definition at line 671 of file rmodulon.cc.

{
mpz_t g, aa, bb;
mpz_ptr qq = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_ptr rr = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(qq);
mpz_init(rr);
mpz_init(g);
mpz_init_set(aa, (mpz_ptr)a);
mpz_init_set(bb, (mpz_ptr)b);
mpz_gcd(g, bb, r->modNumber);
mpz_mod(rr, aa, g);
mpz_sub(aa, aa, rr);
mpz_gcd(g, aa, g);
mpz_div(aa, aa, g);
mpz_div(bb, bb, g);
mpz_div(g, r->modNumber, g);
mpz_invert(g, bb, g);
mpz_mul(qq, aa, g);
if (rem)
*rem = (number)rr;
else {
mpz_clear(rr);
omFreeBin(rr, gmp_nrz_bin);
}
mpz_clear(g);
mpz_clear(aa);
mpz_clear(bb);
return (number) qq;
}
rem
void rem(unsigned long *a, unsigned long *q, unsigned long p, int &dega, int degq)
Definition minpoly.cc:572

## nrnRead()

const char * nrnRead | ( | const char * | s,
|  | number * | a,
|  | const coeffs | r )

static

Definition at line 953 of file rmodulon.cc.

{
mpz_ptr z = (mpz_ptr) omAllocBin(gmp_nrz_bin);
{
s = nlCPEatLongC((char *)s, z);
}
mpz_mod(z, z, r->modNumber);
if ((*s)=='/')
{
mpz_ptr n = (mpz_ptr) omAllocBin(gmp_nrz_bin);
s++;
s=nlCPEatLongC((char*)s,n);
if (!nrnIsOne((number)n,r))
{
*a=nrnDiv((number)z,(number)n,r);
mpz_clear(z);
omFreeBin((void *)z, gmp_nrz_bin);
mpz_clear(n);
omFreeBin((void *)n, gmp_nrz_bin);
}
}
else
*a = (number) z;
return s;
}
nlCPEatLongC
static const char * nlCPEatLongC(char *s, mpz_ptr i)
Definition rmodulon.cc:929

## nrnSetExp()

void nrnSetExp | ( | unsigned long | m,
|  | coeffs | r )

static

Definition at line 892 of file rmodulon.cc.

{
/* clean up former stuff */
if (r->modNumber != NULL) mpz_clear(r->modNumber);
r->modExponent= m;
r->modNumber = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init_set (r->modNumber, r->modBase);
mpz_pow_ui (r->modNumber, r->modNumber, m);
}

## nrnSetMap()

nMapFunc nrnSetMap | ( | const coeffs | src,
|  | const coeffs | dst )

Definition at line 794 of file rmodulon.cc.

{
/* dst = nrn */
if ((src->rep==n_rep_gmp) && nCoeff_is_Z(src))
{
return nrnMapZ;
}
if ((src->rep==n_rep_gap_gmp) /*&& nCoeff_is_Z(src)*/)
{
return nrnMapZ;
}
if (src->rep==n_rep_gap_rat) /*&& nCoeff_is_Q(src)) or Z*/
{
return nrnMapQ;
}
// Some type of Z/n ring / field
if (nCoeff_is_Zn(src) || nCoeff_is_Ring_PtoM(src) ||
nCoeff_is_Ring_2toM(src) || nCoeff_is_Zp(src))
{
if ( (!nCoeff_is_Zp(src))
&& (mpz_cmp(src->modBase, dst->modBase) == 0)
&& (src->modExponent == dst->modExponent)) return ndCopyMap;
else
{
mpz_ptr nrnMapModul = (mpz_ptr) omAllocBin(gmp_nrz_bin);
// Computing the n of Z/n
if (nCoeff_is_Zp(src))
{
mpz_init_set_si(nrnMapModul, src->ch);
}
else
{
mpz_init(nrnMapModul);
mpz_set(nrnMapModul, src->modNumber);
}
// nrnMapCoef = 1 in dst if dst is a subring of src
// nrnMapCoef = 0 in dst / src if src is a subring of dst
if (nrnMapCoef == NULL)
{
nrnMapCoef = (mpz_ptr) omAllocBin(gmp_nrz_bin);
mpz_init(nrnMapCoef);
}
if (mpz_divisible_p(nrnMapModul, dst->modNumber))
{
mpz_set_ui(nrnMapCoef, 1);
}
else
if (mpz_divisible_p(dst->modNumber,nrnMapModul))
{
mpz_divexact(nrnMapCoef, dst->modNumber, nrnMapModul);
mpz_ptr tmp = dst->modNumber;
dst->modNumber = nrnMapModul;
if (!nrnIsUnit((number) nrnMapCoef,dst))
{
dst->modNumber = tmp;
nrnDelete((number*) &nrnMapModul, dst);
return NULL;
}
mpz_ptr inv = (mpz_ptr) nrnInvers((number) nrnMapCoef,dst);
dst->modNumber = tmp;
mpz_mul(nrnMapCoef, nrnMapCoef, inv);
mpz_mod(nrnMapCoef, nrnMapCoef, dst->modNumber);
nrnDelete((number*) &inv, dst);
}
else
{
nrnDelete((number*) &nrnMapModul, dst);
return NULL;
}
nrnDelete((number*) &nrnMapModul, dst);
if (nCoeff_is_Ring_2toM(src))
return nrnMap2toM;
else if (nCoeff_is_Zp(src))
return nrnMapZp;
else
return nrnMapModN;
}
}
return NULL; // default
}
nCoeff_is_Z
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition coeffs.h:811
ndCopyMap
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition numbers.cc:293
nCoeff_is_Zp
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition coeffs.h:795
nCoeff_is_Ring_2toM
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition coeffs.h:726
n_rep_gap_rat
@ n_rep_gap_rat
(number), see longrat.h
Definition coeffs.h:118
n_rep_gap_gmp
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition coeffs.h:119
nrnMap2toM
static number nrnMap2toM(number from, const coeffs, const coeffs dst)
Definition rmodulon.cc:714
nrnMapZ
static number nrnMapZ(number from, const coeffs src, const coeffs dst)
Definition rmodulon.cc:762
nrnMapZp
static number nrnMapZp(number from, const coeffs, const coeffs dst)
Definition rmodulon.cc:723
nrnMapQ
static number nrnMapQ(number from, const coeffs src, const coeffs dst)
Definition rmodulon.cc:741
nrnMapModN
static number nrnMapModN(number from, const coeffs, const coeffs dst)
Definition rmodulon.cc:709

## nrnSub()

number nrnSub | ( | number | a,
|  | number | b,
|  | const coeffs | r )

static

Definition at line 233 of file rmodulon.cc.

{
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(erg);
mpz_sub(erg, (mpz_ptr)a, (mpz_ptr) b);
mpz_mod(erg, erg, r->modNumber);
return (number) erg;
}

## nrnWrite()

void nrnWrite | ( | number | a,
|  | const coeffs | )

Definition at line 777 of file rmodulon.cc.

{
char *s,*z;
if (a==NULL)
{
StringAppendS("o");
}
else
{
int l=mpz_sizeinbase((mpz_ptr) a, 10) + 2;
s=(char*)omAlloc(l);
z=mpz_get_str(s,10,(mpz_ptr) a);
StringAppendS(z);
omFreeSize((ADDRESS)s,l);
}
}
StringAppendS
void StringAppendS(const char *st)
Definition reporter.cc:107

## nrnXExtGcd()

number nrnXExtGcd | ( | number | a,
|  | number | b,
|  | number * | s,
|  | number * | t,
|  | number * | u,
|  | number * | v,
|  | const coeffs | r )

static

Definition at line 399 of file rmodulon.cc.

{
number xx;
#ifdef CF_DEB
StringSetS("XExtGcd of ");
nrnWrite(a, r);
StringAppendS("\t");
nrnWrite(b, r);
StringAppendS(" modulo ");
nrnWrite(xx = (number)r->modNumber, r);
Print("%s\n", StringEndS());
#endif
mpz_ptr one = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_ptr bs = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_ptr bt = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_ptr bu = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_ptr bv = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init(erg);
mpz_init(one);
mpz_init_set(bs, (mpz_ptr) a);
mpz_init_set(bt, (mpz_ptr) b);
mpz_init(bu);
mpz_init(bv);
mpz_gcd(erg, bs, bt);
#ifdef CF_DEB
StringSetS("1st gcd:");
nrnWrite(xx= (number)erg, r);
#endif
mpz_gcd(erg, erg, r->modNumber);
mpz_div(bs, bs, erg);
mpz_div(bt, bt, erg);
#ifdef CF_DEB
Print("%s\n", StringEndS());
StringSetS("xgcd: ");
#endif
mpz_gcdext(one, bu, bv, bs, bt);
number ui = nrnGetUnit(xx = (number) one, r);
#ifdef CF_DEB
n_Write(xx, r);
StringAppendS("\t");
n_Write(ui, r);
Print("%s\n", StringEndS());
#endif
nrnDelete(&xx, r);
if (!nrnIsOne(ui, r))
{
#ifdef CF_DEB
PrintS("Scaling\n");
#endif
number uii = nrnInvers(ui, r);
nrnDelete(&ui, r);
ui = uii;
mpz_ptr uu = (mpz_ptr)omAllocBin(gmp_nrz_bin);
mpz_init_set(uu, (mpz_ptr)ui);
mpz_mul(bu, bu, uu);
mpz_mul(bv, bv, uu);
mpz_clear(uu);
omFreeBin(uu, gmp_nrz_bin);
}
nrnDelete(&ui, r);
#ifdef CF_DEB
StringSetS("xgcd");
nrnWrite(xx= (number)bs, r);
StringAppendS("*");
nrnWrite(xx= (number)bu, r);
StringAppendS(" + ");
nrnWrite(xx= (number)bt, r);
StringAppendS("*");
nrnWrite(xx= (number)bv, r);
Print("%s\n", StringEndS());
#endif
mpz_mod(bs, bs, r->modNumber);
mpz_mod(bt, bt, r->modNumber);
mpz_mod(bu, bu, r->modNumber);
mpz_mod(bv, bv, r->modNumber);
*s = (number)bu;
*t = (number)bv;
*u = (number)bt;
*u = nrnNeg(*u, r);
*v = (number)bs;
return (number)erg;
}
n_Write
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:594
Print
#define Print
Definition emacs.cc:80
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
StringEndS
char * StringEndS()
Definition reporter.cc:151

## Variable Documentation

## gmp_nrz_bin

EXTERN_VAR omBin gmp_nrz_bin

Definition at line 31 of file rmodulon.cc.

## nrnCoeffName_buff

STATIC_VAR char* nrnCoeffName_buff =NULL

Definition at line 63 of file rmodulon.cc.

## nrnMapCoef

STATIC_VAR mpz_ptr nrnMapCoef = NULL

Definition at line 707 of file rmodulon.cc.