Loading...
Searching...
No Matches
rmodulon.h File Reference
`#include "misc/auxiliary.h"`
`#include "coeffs/coeffs.h"`
`#include "coeffs/rintegers.h"`

Go to the source code of this file.

## Data Structures

struct | ZnmInfo

## Functions

BOOLEAN | nrnInitChar (coeffs r, void *)
number | nrnMapGMP (number from, const coeffs, const coeffs dst)
nMapFunc | nrnSetMap (const coeffs src, const coeffs dst)
coeffs | nrnInitCfByName (char *name, n_coeffType n)

## Data Structure Documentation

## ZnmInfo

struct ZnmInfo

Definition at line 17 of file rmodulon.h.

Data Fields
mpz_ptr | base |
unsigned long | exp |

## Function Documentation

## nrnInitCfByName()

coeffs nrnInitCfByName | ( | char * | name,
|  | 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;
}
i
int i
Definition cfEzgcd.cc:132
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
s
const CanonicalForm int s
Definition facAbsFact.cc:51
info
#define info
Definition libparse.cc:1256
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
NULL
#define NULL
Definition omList.c:12
ZnmInfo
Definition rmodulon.h:17

## 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;
}
FALSE
#define FALSE
Definition auxiliary.h:97
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
assume
#define assume(x)
Definition mod2.h:389
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
nrnInit
static number nrnInit(long i, const coeffs r)
Definition rmodulon.cc:158
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
nrnIsZero
static BOOLEAN nrnIsZero(number a, const coeffs)
Definition rmodulon.cc:242
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
nrnIsUnit
static BOOLEAN nrnIsUnit(number a, const coeffs r)
Definition rmodulon.cc:541
nrnDelete
#define nrnDelete
Definition rmodulon.cc:175
nrnSetMap
nMapFunc nrnSetMap(const coeffs src, const coeffs dst)
Definition rmodulon.cc:794
nrnInvers
static number nrnInvers(number c, const coeffs r)
Definition rmodulon.cc:255
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
nrnEqual
static BOOLEAN nrnEqual(number a, number b, const coeffs)
Definition rmodulon.cc:348
nrnQuotRem
static number nrnQuotRem(number a, number b, number *rem, const coeffs r)
Definition rmodulon.cc:671
nrnInt
static long nrnInt(number &n, const coeffs)
Definition rmodulon.cc:169
nrnIsOne
static BOOLEAN nrnIsOne(number a, const coeffs)
Definition rmodulon.cc:343
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
nrnMult
static number nrnMult(number a, number b, const coeffs r)
Definition rmodulon.cc:195
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
nrnGcd
static number nrnGcd(number a, number b, const coeffs r)
Definition rmodulon.cc:275
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

## 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;
}
omAllocBin
#define omAllocBin(bin)
Definition omAllocDecl.h:205
gmp_nrz_bin
VAR omBin gmp_nrz_bin
Definition rintegers.cc:23

## 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_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
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
nrnMapCoef
STATIC_VAR mpz_ptr nrnMapCoef
Definition rmodulon.cc:707
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