Loading...
Searching...
No Matches
flintcf_Zn.cc File Reference
`#include <ctype.h>`
`#include "misc/auxiliary.h"`
`#include <flint/flint.h>`
`#include <flint/nmod_poly.h>`
`#include "factory/factory.h"`
`#include "coeffs/coeffs.h"`
`#include "coeffs/numbers.h"`
`#include "coeffs/longrat.h"`
`#include "coeffs/modulop.h"`
`#include "coeffs/flintcf_Zn.h"`

Go to the source code of this file.

## Typedefs

typedef nmod_poly_struct * | nmod_poly_ptr

## Functions

static const char * | Eati (const char *s, int *i)
static BOOLEAN | CoeffIsEqual (const coeffs r, n_coeffType n, void *parameter)
static void | KillChar (coeffs cf)
static void | SetChar (const coeffs r)
static number | Mult (number a, number b, const coeffs c)
static number | Sub (number a, number b, const coeffs c)
static number | Add (number a, number b, const coeffs c)
static number | Div (number a, number b, const coeffs c)
static number | ExactDiv (number a, number b, const coeffs c)
static number | IntMod (number a, number b, const coeffs c)
static number | Init (long i, const coeffs r)
static number | InitMPZ (mpz_t i, const coeffs r)
static int | Size (number n, const coeffs r)
static long | Int (number &n, const coeffs r)
static void | MPZ (mpz_t result, number &n, const coeffs r)
static number | Neg (number a, const coeffs r)
static number | Invers (number a, const coeffs r)
static number | Copy (number a, const coeffs r)
static BOOLEAN | IsOne (number a, const coeffs r)
static BOOLEAN | IsZero (number a, const coeffs r)
static void | WriteShort (number a, const coeffs r)
static const char * | Read (const char *st, number *a, const coeffs r)
static void | Normalize (number &a, const coeffs r)
static BOOLEAN | Greater (number a, number b, const coeffs r)
static BOOLEAN | Equal (number a, number b, const coeffs r)
static BOOLEAN | IsMOne (number k, const coeffs r)
static BOOLEAN | GreaterZero (number k, const coeffs r)
static void | Power (number a, int i, number *result, const coeffs r)
static number | Gcd (number a, number b, const coeffs r)
static number | ExtGcd (number a, number b, number *s, number *t, const coeffs r)
static number | Lcm (number a, number b, const coeffs r)
static void | Delete (number *a, const coeffs r)
static nMapFunc | SetMap (const coeffs src, const coeffs dst)
static number | Init_bigint (number i, const coeffs dummy, const coeffs dst)
static number | Farey (number p, number n, const coeffs)
static number | ChineseRemainder (number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs)
static int | ParDeg (number x, const coeffs r)
static number | Parameter (const int i, const coeffs r)
static char * | CoeffName (const coeffs r)
coeffs | flintZnInitCfByName (char *s, n_coeffType n)
static void | WriteFd (number a, const ssiInfo *d, const coeffs)
static number | ReadFd (const ssiInfo *d, const coeffs r)
static BOOLEAN | DBTest (number a, const char *f, const int l, const coeffs r)
BOOLEAN | flintZn_InitChar (coeffs cf, void *infoStruct)

## Typedef Documentation

## nmod_poly_ptr

typedef nmod_poly_struct* nmod_poly_ptr

Definition at line 24 of file flintcf_Zn.cc.

## Function Documentation

## Add()

number Add | ( | number | a,
|  | number | b,
|  | const coeffs | c )

static

Definition at line 77 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,c->ch);
nmod_poly_add(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
return (number)res;
}
b
CanonicalForm b
Definition cfModGcd.cc:4111
res
CanonicalForm res
Definition facAbsFact.cc:60
nmod_poly_init
nmod_poly_init(FLINTmipo, getCharacteristic())
nmod_poly_ptr
nmod_poly_struct * nmod_poly_ptr
Definition flintcf_Zn.cc:24
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210

## ChineseRemainder()

number ChineseRemainder | ( | number * | x,
|  | number * | q,
|  | int | rl,
|  | BOOLEAN | sym,
|  | CFArray & | inv_cache,
|  | const coeffs | )

static

Definition at line 394 of file flintcf_Zn.cc.

{
WerrorS("not yet: ChineseRemainder");
return NULL;
}
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
NULL
#define NULL
Definition omList.c:12

## CoeffIsEqual()

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

static

Definition at line 47 of file flintcf_Zn.cc.

{
flintZn_struct *pp=(flintZn_struct*)parameter;
return (r->type==n) &&(r->ch==pp->ch)
&&(r->pParameterNames!=NULL)
&&(strcmp(r->pParameterNames[0],pp->name)==0);
}
pp
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f ).
Definition cf_gcd.cc:676
flintZn_struct
Definition flintcf_Zn.h:17

## CoeffName()

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

static

Definition at line 426 of file flintcf_Zn.cc.

{
STATIC_VAR char CoeffName_flint_Zn[20];
snprintf(CoeffName_flint_Zn,20,"flint:Z/%d[%s]",r->ch,r->pParameterNames[0]);
return (char*)CoeffName_flint_Zn;
}
STATIC_VAR
#define STATIC_VAR
Definition globaldefs.h:7

## Copy()

number Copy | ( | number | a,
|  | const coeffs | r )

static

Definition at line 197 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,r->ch);
nmod_poly_set(res,(nmod_poly_ptr)a);
return (number)res;
}

## DBTest()

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

static

Definition at line 481 of file flintcf_Zn.cc.

{
return TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101

## Delete()

void Delete | ( | number * | a,
|  | const coeffs | r )

static

Definition at line 349 of file flintcf_Zn.cc.

{
if ((*a)!=NULL)
{
nmod_poly_clear((nmod_poly_ptr)*a);
omFree(*a);
*a=NULL;
}
}
nmod_poly_clear
nmod_poly_clear(FLINTmipo)
omFree
#define omFree(addr)
Definition omAllocDecl.h:261

## Div()

number Div | ( | number | a,
|  | number | b,
|  | const coeffs | c )

static

Definition at line 84 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,c->ch);
if(nmod_poly_is_zero((nmod_poly_ptr)b))
{
WerrorS(nDivBy0);
}
else
{
nmod_poly_div(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
nmod_poly_t mod;
nmod_poly_init(mod,c->ch);
nmod_poly_rem(mod,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
if (!nmod_poly_is_zero((nmod_poly_ptr)mod))
{
WerrorS("cannot divide");
}
nmod_poly_clear(mod);
}
return (number)res;
}
mod
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
nDivBy0
const char *const nDivBy0
Definition numbers.h:90

## Eati()

const char * Eati | ( | const char * | s,
|  | int * | i )

static

Definition at line 29 of file flintcf_Zn.cc.

{
if (((*s) >= '0') && ((*s) <= '9'))
{
unsigned long ii=0L;
do
{
ii *= 10;
ii += *s++ - '0';
}
while (((*s) >= '0') && ((*s) <= '9'));
*i=(int)ii;
}
else (*i) = 1;
return s;
}
i
int i
Definition cfEzgcd.cc:132
s
const CanonicalForm int s
Definition facAbsFact.cc:51

## Equal()

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

static

Definition at line 297 of file flintcf_Zn.cc.

{
return (nmod_poly_equal((nmod_poly_ptr)a,(nmod_poly_ptr)b));
}

## ExactDiv()

number ExactDiv | ( | number | a,
|  | number | b,
|  | const coeffs | c )

static

Definition at line 106 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,c->ch);
if(nmod_poly_is_zero((nmod_poly_ptr)b))
{
WerrorS(nDivBy0);
}
else
nmod_poly_div(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
return (number)res;
}

## ExtGcd()

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

static

Definition at line 335 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,r->ch);
nmod_poly_init((nmod_poly_ptr)*s,r->ch);
nmod_poly_init((nmod_poly_ptr)*t,r->ch);
nmod_poly_xgcd(res,(nmod_poly_ptr)*s,(nmod_poly_ptr)*t,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
return (number)res;
}

## Farey()

number Farey | ( | number | p,
|  | number | n,
|  | const coeffs | )

static

Definition at line 389 of file flintcf_Zn.cc.

{
WerrorS("not yet: Farey");
return NULL;
}

## flintZn_InitChar()

BOOLEAN flintZn_InitChar | ( | coeffs | cf,
|  | void * | infoStruct )

Definition at line 486 of file flintcf_Zn.cc.

{
flintZn_struct *pp=(flintZn_struct*)infoStruct;
cf->ch=pp->ch;
cf->cfCoeffName = CoeffName;
cf->nCoeffIsEqual = CoeffIsEqual;
cf->cfKillChar = KillChar;
cf->cfSetChar = SetChar;
cf->cfMult = Mult;
cf->cfSub = Sub;
cf->cfAdd = Add;
cf->cfDiv = Div;
cf->cfExactDiv = ExactDiv; // ???
cf->cfInit = Init;
cf->cfInitMPZ = InitMPZ;
cf->cfSize = Size;
cf->cfInt = Int;
cf->cfMPZ = MPZ;
cf->cfInpNeg = Neg;
cf->cfInvers = Invers;
cf->cfCopy = Copy;
cf->cfRePart = Copy;
// default: cf->cfImPart = ndReturn0;
cf->cfWriteLong = WriteShort; //WriteLong;
cf->cfWriteShort = WriteShort;
cf->cfRead = Read;
cf->cfNormalize = Normalize;
//cf->cfDivComp=
//cf->cfIsUnit=
//cf->cfGetUnit=
//cf->cfDivBy=
cf->cfGreater=Greater;
cf->cfEqual =Equal;
cf->cfIsZero =IsZero;
cf->cfIsOne =IsOne;
cf->cfIsMOne =IsMOne;
cf->cfGreaterZero=GreaterZero;
cf->cfPower = Power;
//default: cf->cfGetDenom = GetDenom;
//default: cf->cfGetNumerator = GetNumerator;
cf->cfGcd = Gcd;
cf->cfExtGcd = ExtGcd;
cf->cfLcm = Lcm;
cf->cfDelete = Delete;
cf->cfSetMap = SetMap;
// default: cf->cfInpMult
// default: cf->cfInpAdd
cf->cfFarey =Farey;
cf->cfChineseRemainder=ChineseRemainder;
cf->cfParDeg = ParDeg;
cf->cfParameter = Parameter;
// cf->cfClearContent = ClearContent;
// cf->cfClearDenominators = ClearDenominators;
//cf->convFactoryNSingN=ConvFactoryNSingN;
//cf->convSingNFactoryN=ConvSingNFactoryN;
cf->cfWriteFd = WriteFd;
cf->cfReadFd = ReadFd;
#ifdef LDEBUG
cf->cfDBTest = DBTest;
#endif
cf->iNumberOfParameters = 1;
char **pn=(char**)omAlloc0(sizeof(char*));
pn[0]=(char*)omStrDup(pp->name);
cf->pParameterNames = (const char **)pn;
cf->has_simple_Inverse= FALSE;
cf->has_simple_Alloc= FALSE;
cf->is_field=FALSE;
return FALSE;
}
FALSE
#define FALSE
Definition auxiliary.h:97
cf
CanonicalForm cf
Definition cfModGcd.cc:4091
ExtGcd
static number ExtGcd(number a, number b, number *s, number *t, const coeffs)
Definition flintcf_Q.cc:447
WriteShort
static void WriteShort(number a, const coeffs r)
Definition flintcf_Q.cc:233
Copy
static number Copy(number a, const coeffs)
Definition flintcf_Q.cc:215
ChineseRemainder
static number ChineseRemainder(number *, number *, int, BOOLEAN, CFArray &, const coeffs)
Definition flintcf_Q.cc:500
Normalize
static void Normalize(number &a, const coeffs)
Definition flintcf_Q.cc:373
SetChar
static void SetChar(const coeffs)
Definition flintcf_Q.cc:53
SetMap
static nMapFunc SetMap(const coeffs, const coeffs)
Definition flintcf_Q.cc:470
Farey
static number Farey(number, number, const coeffs)
Definition flintcf_Q.cc:495
Read
static const char * Read(const char *st, number *a, const coeffs r)
Definition flintcf_Q.cc:326
IsOne
static BOOLEAN IsOne(number a, const coeffs)
Definition flintcf_Q.cc:389
CoeffName
char * CoeffName(const coeffs r)
Definition flintcf_Q.cc:601
InitMPZ
static number InitMPZ(mpz_t i, const coeffs)
Definition flintcf_Q.cc:128
Size
static int Size(number n, const coeffs)
Definition flintcf_Q.cc:139
Add
static number Add(number a, number b, const coeffs)
Definition flintcf_Q.cc:71
Div
static number Div(number a, number b, const coeffs)
Definition flintcf_Q.cc:78
WriteFd
static void WriteFd(number a, const ssiInfo *d, const coeffs)
Definition flintcf_Q.cc:516
Delete
static void Delete(number *a, const coeffs)
Definition flintcf_Q.cc:461
Parameter
static number Parameter(const int, const coeffs)
Definition flintcf_Q.cc:509
DBTest
static BOOLEAN DBTest(number, const char *, const int, const coeffs)
Definition flintcf_Q.cc:626
KillChar
static void KillChar(coeffs cf)
Definition flintcf_Q.cc:631
Init
static number Init(long i, const coeffs)
Definition flintcf_Q.cc:121
MPZ
static void MPZ(mpz_t result, number &n, const coeffs)
Definition flintcf_Q.cc:159
ReadFd
static number ReadFd(const ssiInfo *d, const coeffs)
Definition flintcf_Q.cc:561
ExactDiv
static number ExactDiv(number a, number b, const coeffs)
Definition flintcf_Q.cc:100
Power
static void Power(number a, int i, number *result, const coeffs)
Definition flintcf_Q.cc:416
IsMOne
static BOOLEAN IsMOne(number k, const coeffs)
Definition flintcf_Q.cc:393
Sub
static number Sub(number a, number b, const coeffs)
Definition flintcf_Q.cc:64
GreaterZero
static BOOLEAN GreaterZero(number, const coeffs)
Definition flintcf_Q.cc:410
Gcd
static number Gcd(number a, number b, const coeffs)
Definition flintcf_Q.cc:440
CoeffIsEqual
static BOOLEAN CoeffIsEqual(const coeffs r, n_coeffType n, void *)
Definition flintcf_Q.cc:49
Mult
static number Mult(number a, number b, const coeffs)
Definition flintcf_Q.cc:57
Invers
static number Invers(number a, const coeffs)
Definition flintcf_Q.cc:195
Lcm
static number Lcm(number, number, const coeffs)
Definition flintcf_Q.cc:456
ParDeg
static int ParDeg(number x, const coeffs)
Definition flintcf_Q.cc:505
IsZero
static BOOLEAN IsZero(number a, const coeffs)
Definition flintcf_Q.cc:385
Neg
static number Neg(number a, const coeffs)
Definition flintcf_Q.cc:190
Equal
static BOOLEAN Equal(number a, number b, const coeffs)
Definition flintcf_Q.cc:381
Int
static long Int(number &n, const coeffs)
Definition flintcf_Q.cc:143
Greater
static bool Greater(mono_type m1, mono_type m2)
Definition interpolation.cc:285
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211

## flintZnInitCfByName()

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

Definition at line 432 of file flintcf_Zn.cc.

{
const char start[]="flint:Z/";
const int start_len=strlen(start);
if (strncmp(s,start,start_len)==0)
{
s+=start_len;
int p;
char st[10];
int l=sscanf(s,"%d[%s",&p,st);
if (l==2)
{
flintZn_struct info;
info.ch=p;
while (st[strlen(st)-1]==']') st[strlen(st)-1]='\0';
info.name=st;
return nInitChar(n,(void*)&info);
}
}
return NULL;
}
l
int l
Definition cfEzgcd.cc:100
p
int p
Definition cfModGcd.cc:4086
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
info
#define info
Definition libparse.cc:1256

## Gcd()

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

static

Definition at line 328 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,r->ch);
nmod_poly_gcd(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
return (number)res;
}

## Greater()

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

static

Definition at line 282 of file flintcf_Zn.cc.

{
if (nmod_poly_length((nmod_poly_ptr)a)>nmod_poly_length((nmod_poly_ptr)b))
return TRUE;
else if (nmod_poly_length((nmod_poly_ptr)a)<nmod_poly_length((nmod_poly_ptr)b))
return FALSE;
for(int i=nmod_poly_length((nmod_poly_ptr)a);i>=0;i--)
{
slong ac=nmod_poly_get_coeff_ui((nmod_poly_ptr)a,i);
slong bc=nmod_poly_get_coeff_ui((nmod_poly_ptr)b,i);
if (ac>bc) return TRUE;
else if (ac<bc) return FALSE;
}
return FALSE;
}
slong
#define slong

## GreaterZero()

BOOLEAN GreaterZero | ( | number | k,
|  | const coeffs | r )

static

Definition at line 315 of file flintcf_Zn.cc.

{
// does it have a leading sign?
// no: 0 and 1 do not have, everything else is in (...)
return TRUE;
}

## Init()

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

static

Definition at line 125 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,r->ch);
i= i%r->ch;
if (i<0) i+=r->ch;
nmod_poly_set_coeff_ui(res,0,i);
return (number)res;
}

## Init_bigint()

number Init_bigint | ( | number | i,
|  | const coeffs | dummy,
|  | const coeffs | dst )

static

Definition at line 369 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,dst->ch);
long ii;
if (SR_HDL(i) & SR_INT)
{
ii=SR_TO_INT(i) % dst->ch;
}
else
{
mpz_t tmp;
mpz_init(tmp);
ii=mpz_mod_ui(tmp,i->z,dst->ch);
mpz_clear(tmp);
}
if (ii<0) ii+=dst->ch;
nmod_poly_set_coeff_ui(res,0,ii);
return (number)res;
}
SR_INT
#define SR_INT
Definition longrat.h:67
SR_TO_INT
#define SR_TO_INT(SR)
Definition longrat.h:69
SR_HDL
#define SR_HDL(A)
Definition tgb.cc:35

## InitMPZ()

number InitMPZ | ( | mpz_t | i,
|  | const coeffs | r )

static

Definition at line 134 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,r->ch);
mpz_t tmp;
mpz_init(tmp);
slong ii=mpz_mod_ui(tmp,i,r->ch);
mpz_clear(tmp);
nmod_poly_set_coeff_ui(res,0,ii);
return (number)res;
}

## Int()

long Int | ( | number & | n,
|  | const coeffs | r )

static

Definition at line 149 of file flintcf_Zn.cc.

{
if (nmod_poly_degree((nmod_poly_ptr)n)==0)
{
slong m;
m=nmod_poly_get_coeff_ui((nmod_poly_ptr)n,0);
return (long)m;
}
return 0;
}
m
int m
Definition cfEzgcd.cc:128

## IntMod()

number IntMod | ( | number | a,
|  | number | b,
|  | const coeffs | c )

static

Definition at line 118 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,c->ch);
nmod_poly_rem(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
return (number)res;
}

## Invers()

number Invers | ( | number | a,
|  | const coeffs | r )

static

Definition at line 174 of file flintcf_Zn.cc.

{
if(nmod_poly_is_zero((nmod_poly_ptr)a))
{
WerrorS(nDivBy0);
return NULL;
}
if (nmod_poly_degree((nmod_poly_ptr)a)==0)
{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,r->ch);
slong c=nmod_poly_get_coeff_ui((nmod_poly_ptr)a,0);
extern number nvInvers (number c, const coeffs r);
c=(slong)nvInvers((number)c,r);
nmod_poly_set_coeff_ui((nmod_poly_ptr)a,0,c);
return (number)res;
}
else
{
WerrorS("not invertable");
return NULL;
}
}
nvInvers
number nvInvers(number c, const coeffs r)
Definition modulop.cc:682
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.

## IsMOne()

BOOLEAN IsMOne | ( | number | k,
|  | const coeffs | r )

static

Definition at line 309 of file flintcf_Zn.cc.

{
if (nmod_poly_length((nmod_poly_ptr)k)>0) return FALSE;
slong m=nmod_poly_get_coeff_ui((nmod_poly_ptr)k,0);
return (m+1==r->ch);
}
k
int k
Definition cfEzgcd.cc:99

## IsOne()

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

static

Definition at line 305 of file flintcf_Zn.cc.

{
return nmod_poly_is_one((nmod_poly_ptr)a);
}

## IsZero()

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

static

Definition at line 301 of file flintcf_Zn.cc.

{
return nmod_poly_is_zero((nmod_poly_ptr)a);
}

## KillChar()

void KillChar | ( | coeffs | cf | ) |

static

Definition at line 54 of file flintcf_Zn.cc.

{
omFree((ADDRESS)(cf->pParameterNames[0]));
omFreeSize(cf->pParameterNames,sizeof(char*));
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260

## Lcm()

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

static

Definition at line 344 of file flintcf_Zn.cc.

{
WerrorS("not yet: Lcm");
return NULL;
}

## MPZ()

void MPZ | ( | mpz_t | result,
|  | number & | n,
|  | const coeffs | r )

static

Definition at line 159 of file flintcf_Zn.cc.

{
mpz_init(result);
if (nmod_poly_degree((nmod_poly_ptr)n)==0)
{
slong m;
m=nmod_poly_get_coeff_ui((nmod_poly_ptr)n,0);
mpz_set_ui(result,m);
}
}
result
return result
Definition facAbsBiFact.cc:76

## Mult()

number Mult | ( | number | a,
|  | number | b,
|  | const coeffs | c )

static

Definition at line 63 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(*res));
nmod_poly_init(res,c->ch);
nmod_poly_mul(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
return (number)res;
}

## Neg()

number Neg | ( | number | a,
|  | const coeffs | r )

static

Definition at line 169 of file flintcf_Zn.cc.

{
nmod_poly_neg((nmod_poly_ptr)a,(nmod_poly_ptr)a);
return a;
}

## Normalize()

void Normalize | ( | number & | a,
|  | const coeffs | r )

static

Definition at line 279 of file flintcf_Zn.cc.

{
}

## Parameter()

number Parameter | ( | const int | i,
|  | const coeffs | r )

static

Definition at line 403 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,r->ch);
nmod_poly_set_coeff_ui(res,1,1);
return (number)res;
}

## ParDeg()

int ParDeg | ( | number | x,
|  | const coeffs | r )

static

Definition at line 399 of file flintcf_Zn.cc.

{
return nmod_poly_degree((nmod_poly_ptr)x);
}
x
Variable x
Definition cfModGcd.cc:4090

## Power()

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

static

Definition at line 321 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,r->ch);
*result=(number)res;
nmod_poly_pow((nmod_poly_ptr)(*result),(nmod_poly_ptr)a,i);
}

## Read()

const char * Read | ( | const char * | st,
|  | number * | a,
|  | const coeffs | r )

static

Definition at line 245 of file flintcf_Zn.cc.

{
// we only read "monomials" (i.e. [-][digits][parameter]),
// everything else (+,*,^,()) is left to the singular interpreter
const char *s=st;
*a=(number)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init((nmod_poly_ptr)(*a),r->ch);
BOOLEAN neg=FALSE;
if (*s=='-') { neg=TRUE; s++;}
if (isdigit(*s))
{
int z;
s=Eati((char *)s, &z);
nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),0,z);
}
else if(strncmp(s,r->pParameterNames[0],strlen(r->pParameterNames[0]))==0)
{
nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),1,1);
s+=strlen(r->pParameterNames[0]);
if(isdigit(*s))
{
int i=1;
s=Eati(s,&i);
if (i!=1)
{
nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),1,0);
nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),i,1);
}
}
}
if (neg)
nmod_poly_neg((nmod_poly_ptr)(*a),(nmod_poly_ptr)(*a));
return s;
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
Eati
static const char * Eati(const char *s, int *i)
Definition flintcf_Zn.cc:29

## ReadFd()

number ReadFd | ( | const ssiInfo * | d,
|  | const coeffs | r )

static

Definition at line 466 of file flintcf_Zn.cc.

{
// format: len a_len .. a_0
nmod_poly_ptr aa=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(aa,r->ch);
int l=s_readint(d->f_read);
unsigned long ul;
for (int i=l;i>=0;i--)
{
unsigned long ul=s_readlong(d->f_read);
nmod_poly_set_coeff_ui(aa,i,ul);
}
return (number)aa;
}
s_readint
int s_readint(s_buff F)
Definition s_buff.cc:113
s_readlong
long s_readlong(s_buff F)
Definition s_buff.cc:160
ssiInfo::f_read
s_buff f_read
Definition s_buff.h:22

## SetChar()

void SetChar | ( | const coeffs | r | ) |

static

Definition at line 59 of file flintcf_Zn.cc.

{
// dummy
}

## SetMap()

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

static

Definition at line 358 of file flintcf_Zn.cc.

{
WerrorS("not yet: SetMap");
return NULL;
}

## Size()

int Size | ( | number | n,
|  | const coeffs | r )

static

Definition at line 145 of file flintcf_Zn.cc.

{
return nmod_poly_degree((nmod_poly_ptr)n);
}

## Sub()

number Sub | ( | number | a,
|  | number | b,
|  | const coeffs | c )

static

Definition at line 70 of file flintcf_Zn.cc.

{
nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
nmod_poly_init(res,c->ch);
nmod_poly_sub(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
return (number)res;
}

## WriteFd()

void WriteFd | ( | number | a,
|  | const ssiInfo * | d,
|  | const coeffs | )

static

Definition at line 453 of file flintcf_Zn.cc.

{
// format: len a_len .. a_0
nmod_poly_ptr aa=(nmod_poly_ptr)a;
int l=nmod_poly_length(aa);
fprintf(d->f_write,"%d ",l);
for(int i=l; i>=0; i--)
{
ulong ul=nmod_poly_get_coeff_ui(aa,i);
fprintf(d->f_write,"%lu ", ul);
}
}
ssiInfo::f_write
FILE * f_write
Definition s_buff.h:23

## WriteShort()

void WriteShort | ( | number | a,
|  | const coeffs | r )

static

Definition at line 215 of file flintcf_Zn.cc.

{
//nmod_poly_print_pretty((nmod_poly_ptr)a,r->pParameterNames[0]);
if (IsOne(a,r)) StringAppendS("1");
else if (IsZero(a,r)) StringAppendS("0");
else
{
StringAppendS("(");
BOOLEAN need_plus=FALSE;
for(int i=nmod_poly_length((nmod_poly_ptr)a);i>=0;i--)
{
slong m=nmod_poly_get_coeff_ui((nmod_poly_ptr)a,i);
if (m!=0)
{
if (need_plus) StringAppendS("+");
need_plus=TRUE;
if (i>0)
{
if (m!=1) StringAppend("%d*",(int)m);
if (i>1)
StringAppend("%s^%d",r->pParameterNames[0],i);
else if (i==1)
StringAppend("%s",r->pParameterNames[0]);
}
else StringAppend("%d",(int)m);
}
}
StringAppendS(")");
}
}
StringAppend
#define StringAppend
Definition emacs.cc:79
IsOne
static BOOLEAN IsOne(number a, const coeffs r)
Definition flintcf_Zn.cc:305
IsZero
static BOOLEAN IsZero(number a, const coeffs r)
Definition flintcf_Zn.cc:301
StringAppendS
void StringAppendS(const char *st)
Definition reporter.cc:107