My Project
Loading...
Searching...
No Matches
Typedefs | Functions
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()

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

Definition at line 77 of file flintcf_Zn.cc.

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

◆ ChineseRemainder()

static 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.

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

◆ CoeffIsEqual()

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

Definition at line 47 of file flintcf_Zn.cc.

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

◆ CoeffName()

static char * CoeffName ( const coeffs  r)
static

Definition at line 426 of file flintcf_Zn.cc.

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

◆ Copy()

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

Definition at line 197 of file flintcf_Zn.cc.

198{
199 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
200 nmod_poly_init(res,r->ch);
201 nmod_poly_set(res,(nmod_poly_ptr)a);
202 return (number)res;
203}

◆ DBTest()

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

Definition at line 481 of file flintcf_Zn.cc.

482{
483 return TRUE;
484}
#define TRUE
Definition: auxiliary.h:100

◆ Delete()

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

Definition at line 349 of file flintcf_Zn.cc.

350{
351 if ((*a)!=NULL)
352 {
354 omFree(*a);
355 *a=NULL;
356 }
357}
nmod_poly_clear(FLINTmipo)
#define omFree(addr)
Definition: omAllocDecl.h:261

◆ Div()

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

Definition at line 84 of file flintcf_Zn.cc.

85{
86 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
87 nmod_poly_init(res,c->ch);
88 if(nmod_poly_is_zero((nmod_poly_ptr)b))
89 {
91 }
92 else
93 {
94 nmod_poly_div(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
95 nmod_poly_t mod;
96 nmod_poly_init(mod,c->ch);
97 nmod_poly_rem(mod,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
98 if (!nmod_poly_is_zero((nmod_poly_ptr)mod))
99 {
100 WerrorS("cannot divide");
101 }
103 }
104 return (number)res;
105}
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
const char *const nDivBy0
Definition: numbers.h:89

◆ Eati()

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

Definition at line 29 of file flintcf_Zn.cc.

30{
31
32 if (((*s) >= '0') && ((*s) <= '9'))
33 {
34 unsigned long ii=0L;
35 do
36 {
37 ii *= 10;
38 ii += *s++ - '0';
39 }
40 while (((*s) >= '0') && ((*s) <= '9'));
41 *i=(int)ii;
42 }
43 else (*i) = 1;
44 return s;
45}
int i
Definition: cfEzgcd.cc:132
const CanonicalForm int s
Definition: facAbsFact.cc:51

◆ Equal()

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

Definition at line 297 of file flintcf_Zn.cc.

298{
299 return (nmod_poly_equal((nmod_poly_ptr)a,(nmod_poly_ptr)b));
300}

◆ ExactDiv()

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

Definition at line 106 of file flintcf_Zn.cc.

107{
108 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
109 nmod_poly_init(res,c->ch);
110 if(nmod_poly_is_zero((nmod_poly_ptr)b))
111 {
113 }
114 else
115 nmod_poly_div(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
116 return (number)res;
117}

◆ ExtGcd()

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

Definition at line 335 of file flintcf_Zn.cc.

336{
337 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
338 nmod_poly_init(res,r->ch);
340 nmod_poly_init((nmod_poly_ptr)*t,r->ch);
341 nmod_poly_xgcd(res,(nmod_poly_ptr)*s,(nmod_poly_ptr)*t,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
342 return (number)res;
343}

◆ Farey()

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

Definition at line 389 of file flintcf_Zn.cc.

390{
391 WerrorS("not yet: Farey");
392 return NULL;
393}

◆ flintZn_InitChar()

BOOLEAN flintZn_InitChar ( coeffs  cf,
void *  infoStruct 
)

Definition at line 486 of file flintcf_Zn.cc.

487{
488 flintZn_struct *pp=(flintZn_struct*)infoStruct;
489 cf->ch=pp->ch;
490
491 cf->cfCoeffName = CoeffName;
492 cf->nCoeffIsEqual = CoeffIsEqual;
493 cf->cfKillChar = KillChar;
494 cf->cfSetChar = SetChar;
495 cf->cfMult = Mult;
496 cf->cfSub = Sub;
497 cf->cfAdd = Add;
498 cf->cfDiv = Div;
499 cf->cfExactDiv = ExactDiv; // ???
500 cf->cfInit = Init;
501 cf->cfInitMPZ = InitMPZ;
502 cf->cfSize = Size;
503 cf->cfInt = Int;
504 cf->cfMPZ = MPZ;
505 cf->cfInpNeg = Neg;
506 cf->cfInvers = Invers;
507 cf->cfCopy = Copy;
508 cf->cfRePart = Copy;
509 // default: cf->cfImPart = ndReturn0;
510 cf->cfWriteLong = WriteShort; //WriteLong;
511 cf->cfWriteShort = WriteShort;
512 cf->cfRead = Read;
513 cf->cfNormalize = Normalize;
514
515 //cf->cfDivComp=
516 //cf->cfIsUnit=
517 //cf->cfGetUnit=
518 //cf->cfDivBy=
519
520 cf->cfGreater=Greater;
521 cf->cfEqual =Equal;
522 cf->cfIsZero =IsZero;
523 cf->cfIsOne =IsOne;
524 cf->cfIsMOne =IsMOne;
525 cf->cfGreaterZero=GreaterZero;
526
527 cf->cfPower = Power;
528 //default: cf->cfGetDenom = GetDenom;
529 //default: cf->cfGetNumerator = GetNumerator;
530 cf->cfGcd = Gcd;
531 cf->cfExtGcd = ExtGcd;
532 cf->cfLcm = Lcm;
533 cf->cfDelete = Delete;
534 cf->cfSetMap = SetMap;
535 // default: cf->cfInpMult
536 // default: cf->cfInpAdd
537 cf->cfFarey =Farey;
538 cf->cfChineseRemainder=ChineseRemainder;
539 cf->cfParDeg = ParDeg;
540 cf->cfParameter = Parameter;
541 // cf->cfClearContent = ClearContent;
542 // cf->cfClearDenominators = ClearDenominators;
543 //cf->convFactoryNSingN=ConvFactoryNSingN;
544 //cf->convSingNFactoryN=ConvSingNFactoryN;
545 cf->cfWriteFd = WriteFd;
546 cf->cfReadFd = ReadFd;
547#ifdef LDEBUG
548 cf->cfDBTest = DBTest;
549#endif
550
551 cf->iNumberOfParameters = 1;
552 char **pn=(char**)omAlloc0(sizeof(char*));
553 pn[0]=(char*)omStrDup(pp->name);
554 cf->pParameterNames = (const char **)pn;
555 cf->has_simple_Inverse= FALSE;
556 cf->has_simple_Alloc= FALSE;
557 cf->is_field=FALSE;
558
559 return FALSE;
560}
#define FALSE
Definition: auxiliary.h:96
CanonicalForm cf
Definition: cfModGcd.cc:4083
static void WriteShort(number a, const coeffs r)
Definition: flintcf_Zn.cc:215
static char * CoeffName(const coeffs r)
Definition: flintcf_Zn.cc:426
static number Lcm(number a, number b, const coeffs r)
Definition: flintcf_Zn.cc:344
static void MPZ(mpz_t result, number &n, const coeffs r)
Definition: flintcf_Zn.cc:159
static number Neg(number a, const coeffs r)
Definition: flintcf_Zn.cc:169
static BOOLEAN Greater(number a, number b, const coeffs r)
Definition: flintcf_Zn.cc:282
static const char * Read(const char *st, number *a, const coeffs r)
Definition: flintcf_Zn.cc:245
static number Mult(number a, number b, const coeffs c)
Definition: flintcf_Zn.cc:63
static number Sub(number a, number b, const coeffs c)
Definition: flintcf_Zn.cc:70
static long Int(number &n, const coeffs r)
Definition: flintcf_Zn.cc:149
static number Init(long i, const coeffs r)
Definition: flintcf_Zn.cc:125
static BOOLEAN CoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: flintcf_Zn.cc:47
static void Normalize(number &a, const coeffs r)
Definition: flintcf_Zn.cc:279
static number Gcd(number a, number b, const coeffs r)
Definition: flintcf_Zn.cc:328
static number ExtGcd(number a, number b, number *s, number *t, const coeffs r)
Definition: flintcf_Zn.cc:335
static void WriteFd(number a, const ssiInfo *d, const coeffs)
Definition: flintcf_Zn.cc:453
static BOOLEAN GreaterZero(number k, const coeffs r)
Definition: flintcf_Zn.cc:315
static BOOLEAN DBTest(number a, const char *f, const int l, const coeffs r)
Definition: flintcf_Zn.cc:481
static void Delete(number *a, const coeffs r)
Definition: flintcf_Zn.cc:349
static number ReadFd(const ssiInfo *d, const coeffs r)
Definition: flintcf_Zn.cc:466
static void KillChar(coeffs cf)
Definition: flintcf_Zn.cc:54
static number Copy(number a, const coeffs r)
Definition: flintcf_Zn.cc:197
static number InitMPZ(mpz_t i, const coeffs r)
Definition: flintcf_Zn.cc:134
static number Div(number a, number b, const coeffs c)
Definition: flintcf_Zn.cc:84
static void Power(number a, int i, number *result, const coeffs r)
Definition: flintcf_Zn.cc:321
static BOOLEAN Equal(number a, number b, const coeffs r)
Definition: flintcf_Zn.cc:297
static number Add(number a, number b, const coeffs c)
Definition: flintcf_Zn.cc:77
static BOOLEAN IsOne(number a, const coeffs r)
Definition: flintcf_Zn.cc:305
static number Farey(number p, number n, const coeffs)
Definition: flintcf_Zn.cc:389
static BOOLEAN IsZero(number a, const coeffs r)
Definition: flintcf_Zn.cc:301
static int ParDeg(number x, const coeffs r)
Definition: flintcf_Zn.cc:399
static nMapFunc SetMap(const coeffs src, const coeffs dst)
Definition: flintcf_Zn.cc:358
static number ChineseRemainder(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs)
Definition: flintcf_Zn.cc:394
static BOOLEAN IsMOne(number k, const coeffs r)
Definition: flintcf_Zn.cc:309
static void SetChar(const coeffs r)
Definition: flintcf_Zn.cc:59
static number Parameter(const int i, const coeffs r)
Definition: flintcf_Zn.cc:403
static number Invers(number a, const coeffs r)
Definition: flintcf_Zn.cc:174
static int Size(number n, const coeffs r)
Definition: flintcf_Zn.cc:145
static number ExactDiv(number a, number b, const coeffs c)
Definition: flintcf_Zn.cc:106
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ flintZnInitCfByName()

coeffs flintZnInitCfByName ( char *  s,
n_coeffType  n 
)

Definition at line 432 of file flintcf_Zn.cc.

433{
434 const char start[]="flint:Z/";
435 const int start_len=strlen(start);
436 if (strncmp(s,start,start_len)==0)
437 {
438 s+=start_len;
439 int p;
440 char st[10];
441 int l=sscanf(s,"%d[%s",&p,st);
442 if (l==2)
443 {
445 info.ch=p;
446 while (st[strlen(st)-1]==']') st[strlen(st)-1]='\0';
447 info.name=st;
448 return nInitChar(n,(void*)&info);
449 }
450 }
451 return NULL;
452}
int l
Definition: cfEzgcd.cc:100
int p
Definition: cfModGcd.cc:4078
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:413
#define info
Definition: libparse.cc:1256

◆ Gcd()

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

Definition at line 328 of file flintcf_Zn.cc.

329{
330 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
331 nmod_poly_init(res,r->ch);
332 nmod_poly_gcd(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
333 return (number)res;
334}

◆ Greater()

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

Definition at line 282 of file flintcf_Zn.cc.

283{
284 if (nmod_poly_length((nmod_poly_ptr)a)>nmod_poly_length((nmod_poly_ptr)b))
285 return TRUE;
286 else if (nmod_poly_length((nmod_poly_ptr)a)<nmod_poly_length((nmod_poly_ptr)b))
287 return FALSE;
288 for(int i=nmod_poly_length((nmod_poly_ptr)a);i>=0;i--)
289 {
290 slong ac=nmod_poly_get_coeff_ui((nmod_poly_ptr)a,i);
291 slong bc=nmod_poly_get_coeff_ui((nmod_poly_ptr)b,i);
292 if (ac>bc) return TRUE;
293 else if (ac<bc) return FALSE;
294 }
295 return FALSE;
296}
#define slong

◆ GreaterZero()

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

Definition at line 315 of file flintcf_Zn.cc.

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

◆ Init()

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

Definition at line 125 of file flintcf_Zn.cc.

126{
127 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
128 nmod_poly_init(res,r->ch);
129 i= i%r->ch;
130 if (i<0) i+=r->ch;
131 nmod_poly_set_coeff_ui(res,0,i);
132 return (number)res;
133}

◆ Init_bigint()

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

Definition at line 369 of file flintcf_Zn.cc.

370{
371 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
372 nmod_poly_init(res,dst->ch);
373 long ii;
374 if (SR_HDL(i) & SR_INT)
375 {
376 ii=SR_TO_INT(i) % dst->ch;
377 }
378 else
379 {
380 mpz_t tmp;
381 mpz_init(tmp);
382 ii=mpz_mod_ui(tmp,i->z,dst->ch);
383 mpz_clear(tmp);
384 }
385 if (ii<0) ii+=dst->ch;
386 nmod_poly_set_coeff_ui(res,0,ii);
387 return (number)res;
388}
#define SR_INT
Definition: longrat.h:67
#define SR_TO_INT(SR)
Definition: longrat.h:69
#define SR_HDL(A)
Definition: tgb.cc:35

◆ InitMPZ()

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

Definition at line 134 of file flintcf_Zn.cc.

135{
136 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
137 nmod_poly_init(res,r->ch);
138 mpz_t tmp;
139 mpz_init(tmp);
140 slong ii=mpz_mod_ui(tmp,i,r->ch);
141 mpz_clear(tmp);
142 nmod_poly_set_coeff_ui(res,0,ii);
143 return (number)res;
144}

◆ Int()

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

Definition at line 149 of file flintcf_Zn.cc.

150{
151 if (nmod_poly_degree((nmod_poly_ptr)n)==0)
152 {
153 slong m;
154 m=nmod_poly_get_coeff_ui((nmod_poly_ptr)n,0);
155 return (long)m;
156 }
157 return 0;
158}
int m
Definition: cfEzgcd.cc:128

◆ IntMod()

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

Definition at line 118 of file flintcf_Zn.cc.

119{
120 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
121 nmod_poly_init(res,c->ch);
122 nmod_poly_rem(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
123 return (number)res;
124}

◆ Invers()

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

Definition at line 174 of file flintcf_Zn.cc.

175{
176 if(nmod_poly_is_zero((nmod_poly_ptr)a))
177 {
179 return NULL;
180 }
181 if (nmod_poly_degree((nmod_poly_ptr)a)==0)
182 {
183 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
184 nmod_poly_init(res,r->ch);
185 slong c=nmod_poly_get_coeff_ui((nmod_poly_ptr)a,0);
186 extern number nvInvers (number c, const coeffs r);
187 c=(slong)nvInvers((number)c,r);
188 nmod_poly_set_coeff_ui((nmod_poly_ptr)a,0,c);
189 return (number)res;
190 }
191 else
192 {
193 WerrorS("not invertable");
194 return NULL;
195 }
196}
number nvInvers(number c, const coeffs r)
Definition: modulop.cc:673
The main handler for Singular numbers which are suitable for Singular polynomials.

◆ IsMOne()

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

Definition at line 309 of file flintcf_Zn.cc.

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

◆ IsOne()

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

Definition at line 305 of file flintcf_Zn.cc.

306{
307 return nmod_poly_is_one((nmod_poly_ptr)a);
308}

◆ IsZero()

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

Definition at line 301 of file flintcf_Zn.cc.

302{
303 return nmod_poly_is_zero((nmod_poly_ptr)a);
304}

◆ KillChar()

static void KillChar ( coeffs  cf)
static

Definition at line 54 of file flintcf_Zn.cc.

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

◆ Lcm()

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

Definition at line 344 of file flintcf_Zn.cc.

345{
346 WerrorS("not yet: Lcm");
347 return NULL;
348}

◆ MPZ()

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

Definition at line 159 of file flintcf_Zn.cc.

160{
161 mpz_init(result);
162 if (nmod_poly_degree((nmod_poly_ptr)n)==0)
163 {
164 slong m;
165 m=nmod_poly_get_coeff_ui((nmod_poly_ptr)n,0);
166 mpz_set_ui(result,m);
167 }
168}
return result
Definition: facAbsBiFact.cc:75

◆ Mult()

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

Definition at line 63 of file flintcf_Zn.cc.

64{
66 nmod_poly_init(res,c->ch);
67 nmod_poly_mul(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
68 return (number)res;
69}

◆ Neg()

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

Definition at line 169 of file flintcf_Zn.cc.

170{
171 nmod_poly_neg((nmod_poly_ptr)a,(nmod_poly_ptr)a);
172 return a;
173}

◆ Normalize()

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

Definition at line 279 of file flintcf_Zn.cc.

280{
281}

◆ Parameter()

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

Definition at line 403 of file flintcf_Zn.cc.

404{
405 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
406 nmod_poly_init(res,r->ch);
407 nmod_poly_set_coeff_ui(res,1,1);
408 return (number)res;
409}

◆ ParDeg()

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

Definition at line 399 of file flintcf_Zn.cc.

400{
401 return nmod_poly_degree((nmod_poly_ptr)x);
402}
Variable x
Definition: cfModGcd.cc:4082

◆ Power()

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

Definition at line 321 of file flintcf_Zn.cc.

322{
323 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
324 nmod_poly_init(res,r->ch);
325 *result=(number)res;
326 nmod_poly_pow((nmod_poly_ptr)(*result),(nmod_poly_ptr)a,i);
327}

◆ Read()

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

Definition at line 245 of file flintcf_Zn.cc.

246{
247// we only read "monomials" (i.e. [-][digits][parameter]),
248// everythings else (+,*,^,()) is left to the singular interpreter
249 const char *s=st;
250 *a=(number)omAlloc(sizeof(nmod_poly_t));
251 nmod_poly_init((nmod_poly_ptr)(*a),r->ch);
252 BOOLEAN neg=FALSE;
253 if (*s=='-') { neg=TRUE; s++;}
254 if (isdigit(*s))
255 {
256 int z;
257 s=Eati((char *)s, &z);
258 nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),0,z);
259 }
260 else if(strncmp(s,r->pParameterNames[0],strlen(r->pParameterNames[0]))==0)
261 {
262 nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),1,1);
263 s+=strlen(r->pParameterNames[0]);
264 if(isdigit(*s))
265 {
266 int i=1;
267 s=Eati(s,&i);
268 if (i!=1)
269 {
270 nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),1,0);
271 nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),i,1);
272 }
273 }
274 }
275 if (neg)
276 nmod_poly_neg((nmod_poly_ptr)(*a),(nmod_poly_ptr)(*a));
277 return s;
278}
int BOOLEAN
Definition: auxiliary.h:87
static const char * Eati(const char *s, int *i)
Definition: flintcf_Zn.cc:29

◆ ReadFd()

static number ReadFd ( const ssiInfo d,
const coeffs  r 
)
static

Definition at line 466 of file flintcf_Zn.cc.

467{
468 // format: len a_len .. a_0
469 nmod_poly_ptr aa=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
470 nmod_poly_init(aa,r->ch);
471 int l=s_readint(d->f_read);
472 unsigned long ul;
473 for (int i=l;i>=0;i--)
474 {
475 unsigned long ul=s_readlong(d->f_read);
476 nmod_poly_set_coeff_ui(aa,i,ul);
477 }
478 return (number)aa;
479}
int s_readint(s_buff F)
Definition: s_buff.cc:112
long s_readlong(s_buff F)
Definition: s_buff.cc:140
s_buff f_read
Definition: s_buff.h:22

◆ SetChar()

static void SetChar ( const coeffs  r)
static

Definition at line 59 of file flintcf_Zn.cc.

60{
61 // dummy
62}

◆ SetMap()

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

Definition at line 358 of file flintcf_Zn.cc.

359{
360 WerrorS("not yet: SetMap");
361 return NULL;
362}

◆ Size()

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

Definition at line 145 of file flintcf_Zn.cc.

146{
147 return nmod_poly_degree((nmod_poly_ptr)n);
148}

◆ Sub()

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

Definition at line 70 of file flintcf_Zn.cc.

71{
72 nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
73 nmod_poly_init(res,c->ch);
74 nmod_poly_sub(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
75 return (number)res;
76}

◆ WriteFd()

static void WriteFd ( number  a,
const ssiInfo d,
const  coeffs 
)
static

Definition at line 453 of file flintcf_Zn.cc.

454{
455 // format: len a_len .. a_0
457 int l=nmod_poly_length(aa);
458 fprintf(d->f_write,"%d ",l);
459 for(int i=l; i>=0; i--)
460 {
461 ulong ul=nmod_poly_get_coeff_ui(aa,i);
462 fprintf(d->f_write,"%lu ", ul);
463 }
464}
FILE * f_write
Definition: s_buff.h:23

◆ WriteShort()

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

Definition at line 215 of file flintcf_Zn.cc.

216{
217 //nmod_poly_print_pretty((nmod_poly_ptr)a,r->pParameterNames[0]);
218 if (IsOne(a,r)) StringAppendS("1");
219 else if (IsZero(a,r)) StringAppendS("0");
220 else
221 {
222 StringAppendS("(");
223 BOOLEAN need_plus=FALSE;
224 for(int i=nmod_poly_length((nmod_poly_ptr)a);i>=0;i--)
225 {
226 slong m=nmod_poly_get_coeff_ui((nmod_poly_ptr)a,i);
227 if (m!=0)
228 {
229 if (need_plus) StringAppendS("+");
230 need_plus=TRUE;
231 if (i>0)
232 {
233 if (m!=1) StringAppend("%d*",(int)m);
234 if (i>1)
235 StringAppend("%s^%d",r->pParameterNames[0],i);
236 else if (i==1)
237 StringAppend("%s",r->pParameterNames[0]);
238 }
239 else StringAppend("%d",(int)m);
240 }
241 }
242 StringAppendS(")");
243 }
244}
#define StringAppend
Definition: emacs.cc:79
void StringAppendS(const char *st)
Definition: reporter.cc:107