My Project  debian-1:4.1.2-p1+ds-2
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 void CoeffWrite (const coeffs r, BOOLEAN details)
 
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 number ConvFactoryNSingN (const CanonicalForm n, const coeffs r)
 
static CanonicalForm ConvSingNFactoryN (number n, BOOLEAN setChar, const coeffs r)
 
static char * CoeffName (const coeffs r)
 
static char * CoeffString (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 82 of file flintcf_Zn.cc.

83 {
84  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
85  nmod_poly_init(res,c->ch);
86  nmod_poly_add(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
87  return (number)res;
88 }
CanonicalForm b
Definition: cfModGcd.cc:4044
CanonicalForm res
Definition: facAbsFact.cc:64
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 397 of file flintcf_Zn.cc.

398 {
399  WerrorS("not yet: ChineseRemainder");
400 }
void WerrorS(const char *s)
Definition: feFopen.cc:24

◆ CoeffIsEqual()

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

Definition at line 52 of file flintcf_Zn.cc.

53 {
54  flintZn_struct *pp=(flintZn_struct*)parameter;
55  return (r->type==n) &&(r->ch==pp->ch)
56  &&(r->pParameterNames!=NULL)
57  &&(strcmp(r->pParameterNames[0],pp->name)==0);
58 }
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:248
#define NULL
Definition: omList.c:12

◆ CoeffName()

static char* CoeffName ( const coeffs  r)
static

Definition at line 421 of file flintcf_Zn.cc.

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

◆ CoeffString()

static char* CoeffString ( const coeffs  r)
static

Definition at line 427 of file flintcf_Zn.cc.

428 {
429  char *buf=(char*)omAlloc(12+10 /*ch*/+strlen(r->pParameterNames[0]));
430  sprintf(buf,"flintZn(%d,\"%s\")",r->ch,r->pParameterNames[0]);
431  return buf;
432 }
int status int void * buf
Definition: si_signals.h:59

◆ CoeffWrite()

static void CoeffWrite ( const coeffs  r,
BOOLEAN  details 
)
static

Definition at line 47 of file flintcf_Zn.cc.

48 {
49  Print("flint:Z/%d[%s]",r->ch,r->pParameterNames[0]);
50 }
#define Print
Definition: emacs.cc:80

◆ ConvFactoryNSingN()

static number ConvFactoryNSingN ( const CanonicalForm  n,
const coeffs  r 
)
static

Definition at line 414 of file flintcf_Zn.cc.

415 {
416 }

◆ ConvSingNFactoryN()

static CanonicalForm ConvSingNFactoryN ( number  n,
BOOLEAN  setChar,
const coeffs  r 
)
static

Definition at line 417 of file flintcf_Zn.cc.

418 {
419  WerrorS("not yet: ConvSingNFactoryN");
420 }

◆ Copy()

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

Definition at line 202 of file flintcf_Zn.cc.

203 {
204  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
205  nmod_poly_init(res,r->ch);
206  nmod_poly_set(res,(nmod_poly_ptr)a);
207  return (number)res;
208 }

◆ DBTest()

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

Definition at line 482 of file flintcf_Zn.cc.

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

◆ Delete()

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

Definition at line 353 of file flintcf_Zn.cc.

354 {
355  if ((*a)!=NULL)
356  {
358  omFree(*a);
359  *a=NULL;
360  }
361 }
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 89 of file flintcf_Zn.cc.

90 {
91  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
92  nmod_poly_init(res,c->ch);
93  if(nmod_poly_is_zero((nmod_poly_ptr)b))
94  {
96  }
97  else
98  {
99  nmod_poly_div(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
100  nmod_poly_t mod;
101  nmod_poly_init(mod,c->ch);
102  nmod_poly_rem(mod,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
103  if (!nmod_poly_is_zero((nmod_poly_ptr)mod))
104  {
105  WerrorS("cannot divide");
106  }
108  }
109  return (number)res;
110 }
CF_NO_INLINE CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
Definition: cf_inline.cc:564
const char *const nDivBy0
Definition: numbers.h:88

◆ 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:125
const CanonicalForm int s
Definition: facAbsFact.cc:55

◆ Equal()

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

Definition at line 302 of file flintcf_Zn.cc.

303 {
304  return (nmod_poly_equal((nmod_poly_ptr)a,(nmod_poly_ptr)b));
305 }

◆ ExactDiv()

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

Definition at line 111 of file flintcf_Zn.cc.

112 {
113  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
114  nmod_poly_init(res,c->ch);
115  if(nmod_poly_is_zero((nmod_poly_ptr)b))
116  {
117  WerrorS(nDivBy0);
118  }
119  else
120  nmod_poly_div(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
121  return (number)res;
122 }

◆ ExtGcd()

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

Definition at line 340 of file flintcf_Zn.cc.

341 {
342  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
343  nmod_poly_init(res,r->ch);
344  nmod_poly_init((nmod_poly_ptr)*s,r->ch);
345  nmod_poly_init((nmod_poly_ptr)*t,r->ch);
346  nmod_poly_xgcd(res,(nmod_poly_ptr)*s,(nmod_poly_ptr)*t,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
347  return (number)res;
348 }

◆ Farey()

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

Definition at line 393 of file flintcf_Zn.cc.

394 {
395  WerrorS("not yet: Farey");
396 }

◆ flintZn_InitChar()

BOOLEAN flintZn_InitChar ( coeffs  cf,
void *  infoStruct 
)

Definition at line 487 of file flintcf_Zn.cc.

488 {
489  flintZn_struct *pp=(flintZn_struct*)infoStruct;
490  cf->ch=pp->ch;
491 
492  cf->cfCoeffString = CoeffString;
493  cf->cfCoeffName = CoeffName;
494  cf->cfCoeffWrite = CoeffWrite;
495  cf->nCoeffIsEqual = CoeffIsEqual;
496  cf->cfKillChar = KillChar;
497  cf->cfSetChar = SetChar;
498  cf->cfMult = Mult;
499  cf->cfSub = Sub;
500  cf->cfAdd = Add;
501  cf->cfDiv = Div;
502  cf->cfExactDiv = ExactDiv; // ???
503  cf->cfInit = Init;
504  cf->cfInitMPZ = InitMPZ;
505  cf->cfSize = Size;
506  cf->cfInt = Int;
507  cf->cfMPZ = MPZ;
508  cf->cfInpNeg = Neg;
509  cf->cfInvers = Invers;
510  cf->cfCopy = Copy;
511  cf->cfRePart = Copy;
512  // default: cf->cfImPart = ndReturn0;
513  cf->cfWriteLong = WriteShort; //WriteLong;
514  cf->cfWriteShort = WriteShort;
515  cf->cfRead = Read;
516  cf->cfNormalize = Normalize;
517 
518  //cf->cfDivComp=
519  //cf->cfIsUnit=
520  //cf->cfGetUnit=
521  //cf->cfDivBy=
522 
523  cf->cfGreater=Greater;
524  cf->cfEqual =Equal;
525  cf->cfIsZero =IsZero;
526  cf->cfIsOne =IsOne;
527  cf->cfIsMOne =IsMOne;
528  cf->cfGreaterZero=GreaterZero;
529 
530  cf->cfPower = Power;
531  //default: cf->cfGetDenom = GetDenom;
532  //default: cf->cfGetNumerator = GetNumerator;
533  cf->cfGcd = Gcd;
534  cf->cfExtGcd = ExtGcd;
535  cf->cfLcm = Lcm;
536  cf->cfDelete = Delete;
537  cf->cfSetMap = SetMap;
538  // default: cf->cfInpMult
539  // default: cf->cfInpAdd
540  cf->cfFarey =Farey;
541  cf->cfChineseRemainder=ChineseRemainder;
542  cf->cfParDeg = ParDeg;
543  cf->cfParameter = Parameter;
544  // cf->cfClearContent = ClearContent;
545  // cf->cfClearDenominators = ClearDenominators;
546  cf->convFactoryNSingN=ConvFactoryNSingN;
547  cf->convSingNFactoryN=ConvSingNFactoryN;
548  cf->cfWriteFd = WriteFd;
549  cf->cfReadFd = ReadFd;
550 #ifdef LDEBUG
551  cf->cfDBTest = DBTest;
552 #endif
553 
554  cf->iNumberOfParameters = 1;
555  char **pn=(char**)omAlloc0(sizeof(char*));
556  pn[0]=(char*)omStrDup(pp->name);
557  cf->pParameterNames = (const char **)pn;
558  cf->has_simple_Inverse= FALSE;
559  cf->has_simple_Alloc= FALSE;
560  cf->is_field=FALSE;
561 
562  return FALSE;
563 }
#define FALSE
Definition: auxiliary.h:96
CanonicalForm cf
Definition: cfModGcd.cc:4024
static void WriteShort(number a, const coeffs r)
Definition: flintcf_Zn.cc:220
static number Lcm(number a, number b, const coeffs r)
Definition: flintcf_Zn.cc:349
static number ConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: flintcf_Zn.cc:414
static void MPZ(mpz_t result, number &n, const coeffs r)
Definition: flintcf_Zn.cc:164
static number Neg(number a, const coeffs r)
Definition: flintcf_Zn.cc:174
static BOOLEAN Greater(number a, number b, const coeffs r)
Definition: flintcf_Zn.cc:287
static number Mult(number a, number b, const coeffs c)
Definition: flintcf_Zn.cc:68
static number Sub(number a, number b, const coeffs c)
Definition: flintcf_Zn.cc:75
static long Int(number &n, const coeffs r)
Definition: flintcf_Zn.cc:154
static number Init(long i, const coeffs r)
Definition: flintcf_Zn.cc:130
static BOOLEAN CoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: flintcf_Zn.cc:52
static void Normalize(number &a, const coeffs r)
Definition: flintcf_Zn.cc:284
static number Gcd(number a, number b, const coeffs r)
Definition: flintcf_Zn.cc:333
static char * CoeffString(const coeffs r)
Definition: flintcf_Zn.cc:427
static number ExtGcd(number a, number b, number *s, number *t, const coeffs r)
Definition: flintcf_Zn.cc:340
static void WriteFd(number a, const ssiInfo *d, const coeffs)
Definition: flintcf_Zn.cc:454
static BOOLEAN GreaterZero(number k, const coeffs r)
Definition: flintcf_Zn.cc:320
static BOOLEAN DBTest(number a, const char *f, const int l, const coeffs r)
Definition: flintcf_Zn.cc:482
static void Delete(number *a, const coeffs r)
Definition: flintcf_Zn.cc:353
static number ReadFd(const ssiInfo *d, const coeffs r)
Definition: flintcf_Zn.cc:467
static CanonicalForm ConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: flintcf_Zn.cc:417
static void KillChar(coeffs cf)
Definition: flintcf_Zn.cc:59
static number Copy(number a, const coeffs r)
Definition: flintcf_Zn.cc:202
static number InitMPZ(mpz_t i, const coeffs r)
Definition: flintcf_Zn.cc:139
static number Div(number a, number b, const coeffs c)
Definition: flintcf_Zn.cc:89
static void CoeffWrite(const coeffs r, BOOLEAN details)
Definition: flintcf_Zn.cc:47
static void Power(number a, int i, number *result, const coeffs r)
Definition: flintcf_Zn.cc:326
static BOOLEAN Equal(number a, number b, const coeffs r)
Definition: flintcf_Zn.cc:302
static number Add(number a, number b, const coeffs c)
Definition: flintcf_Zn.cc:82
static BOOLEAN IsOne(number a, const coeffs r)
Definition: flintcf_Zn.cc:310
static number Farey(number p, number n, const coeffs)
Definition: flintcf_Zn.cc:393
static BOOLEAN IsZero(number a, const coeffs r)
Definition: flintcf_Zn.cc:306
static int ParDeg(number x, const coeffs r)
Definition: flintcf_Zn.cc:401
static nMapFunc SetMap(const coeffs src, const coeffs dst)
Definition: flintcf_Zn.cc:362
static number ChineseRemainder(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs)
Definition: flintcf_Zn.cc:397
static BOOLEAN IsMOne(number k, const coeffs r)
Definition: flintcf_Zn.cc:314
static void SetChar(const coeffs r)
Definition: flintcf_Zn.cc:64
static number Parameter(const int i, const coeffs r)
Definition: flintcf_Zn.cc:405
static number Invers(number a, const coeffs r)
Definition: flintcf_Zn.cc:179
static char * CoeffName(const coeffs r)
Definition: flintcf_Zn.cc:421
static const char * Read(const char *st, number *a, const coeffs r)
Definition: flintcf_Zn.cc:250
static int Size(number n, const coeffs r)
Definition: flintcf_Zn.cc:150
static number ExactDiv(number a, number b, const coeffs c)
Definition: flintcf_Zn.cc:111
#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 433 of file flintcf_Zn.cc.

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

◆ Gcd()

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

Definition at line 333 of file flintcf_Zn.cc.

334 {
335  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
336  nmod_poly_init(res,r->ch);
337  nmod_poly_gcd(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
338  return (number)res;
339 }

◆ Greater()

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

Definition at line 287 of file flintcf_Zn.cc.

288 {
289  if (nmod_poly_length((nmod_poly_ptr)a)>nmod_poly_length((nmod_poly_ptr)b))
290  return TRUE;
291  else if (nmod_poly_length((nmod_poly_ptr)a)<nmod_poly_length((nmod_poly_ptr)b))
292  return FALSE;
293  for(int i=nmod_poly_length((nmod_poly_ptr)a);i>=0;i--)
294  {
295  slong ac=nmod_poly_get_coeff_ui((nmod_poly_ptr)a,i);
296  slong bc=nmod_poly_get_coeff_ui((nmod_poly_ptr)b,i);
297  if (ac>bc) return TRUE;
298  else if (ac<bc) return FALSE;
299  }
300  return FALSE;
301 }
#define slong

◆ GreaterZero()

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

Definition at line 320 of file flintcf_Zn.cc.

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

◆ Init()

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

Definition at line 130 of file flintcf_Zn.cc.

131 {
132  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
133  nmod_poly_init(res,r->ch);
134  i= i%r->ch;
135  if (i<0) i+=r->ch;
136  nmod_poly_set_coeff_ui(res,0,i);
137  return (number)res;
138 }

◆ Init_bigint()

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

Definition at line 373 of file flintcf_Zn.cc.

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

◆ InitMPZ()

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

Definition at line 139 of file flintcf_Zn.cc.

140 {
141  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
142  nmod_poly_init(res,r->ch);
143  mpz_t tmp;
144  mpz_init(tmp);
145  slong ii=mpz_mod_ui(tmp,i,r->ch);
146  mpz_clear(tmp);
147  nmod_poly_set_coeff_ui(res,0,ii);
148  return (number)res;
149 }

◆ Int()

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

Definition at line 154 of file flintcf_Zn.cc.

155 {
156  if (nmod_poly_degree((nmod_poly_ptr)n)==0)
157  {
158  slong m;
159  m=nmod_poly_get_coeff_ui((nmod_poly_ptr)n,0);
160  return (long)m;
161  }
162  return 0;
163 }
int m
Definition: cfEzgcd.cc:121

◆ IntMod()

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

Definition at line 123 of file flintcf_Zn.cc.

124 {
125  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
126  nmod_poly_init(res,c->ch);
127  nmod_poly_rem(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
128  return (number)res;
129 }

◆ Invers()

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

Definition at line 179 of file flintcf_Zn.cc.

180 {
181  if(nmod_poly_is_zero((nmod_poly_ptr)a))
182  {
183  WerrorS(nDivBy0);
184  return NULL;
185  }
186  if (nmod_poly_degree((nmod_poly_ptr)a)==0)
187  {
188  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
189  nmod_poly_init(res,r->ch);
190  slong c=nmod_poly_get_coeff_ui((nmod_poly_ptr)a,0);
191  extern number nvInvers (number c, const coeffs r);
192  c=(slong)nvInvers((number)c,r);
193  nmod_poly_set_coeff_ui((nmod_poly_ptr)a,0,c);
194  return (number)res;
195  }
196  else
197  {
198  WerrorS("not invertable");
199  return NULL;
200  }
201 }
number nvInvers(number c, const coeffs r)
Definition: modulop.cc:736
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 314 of file flintcf_Zn.cc.

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

◆ IsOne()

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

Definition at line 310 of file flintcf_Zn.cc.

311 {
312  return nmod_poly_is_one((nmod_poly_ptr)a);
313 }

◆ IsZero()

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

Definition at line 306 of file flintcf_Zn.cc.

307 {
308  return nmod_poly_is_zero((nmod_poly_ptr)a);
309 }

◆ KillChar()

static void KillChar ( coeffs  cf)
static

Definition at line 59 of file flintcf_Zn.cc.

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

◆ Lcm()

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

Definition at line 349 of file flintcf_Zn.cc.

350 {
351  WerrorS("not yet: Lcm");
352 }

◆ MPZ()

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

Definition at line 164 of file flintcf_Zn.cc.

165 {
166  mpz_init(result);
167  if (nmod_poly_degree((nmod_poly_ptr)n)==0)
168  {
169  slong m;
170  m=nmod_poly_get_coeff_ui((nmod_poly_ptr)n,0);
171  mpz_set_ui(result,m);
172  }
173 }
return result
Definition: facAbsBiFact.cc:76

◆ Mult()

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

Definition at line 68 of file flintcf_Zn.cc.

69 {
71  nmod_poly_init(res,c->ch);
72  nmod_poly_mul(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
73  return (number)res;
74 }

◆ Neg()

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

Definition at line 174 of file flintcf_Zn.cc.

175 {
176  nmod_poly_neg((nmod_poly_ptr)a,(nmod_poly_ptr)a);
177  return a;
178 }

◆ Normalize()

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

Definition at line 284 of file flintcf_Zn.cc.

285 {
286 }

◆ Parameter()

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

Definition at line 405 of file flintcf_Zn.cc.

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

◆ ParDeg()

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

Definition at line 401 of file flintcf_Zn.cc.

402 {
403  return nmod_poly_degree((nmod_poly_ptr)x);
404 }
Variable x
Definition: cfModGcd.cc:4023

◆ Power()

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

Definition at line 326 of file flintcf_Zn.cc.

327 {
328  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
329  nmod_poly_init(res,r->ch);
330  *result=(number)res;
331  nmod_poly_pow((nmod_poly_ptr)(*result),(nmod_poly_ptr)a,i);
332 }

◆ Read()

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

Definition at line 250 of file flintcf_Zn.cc.

251 {
252 // we only read "monomials" (i.e. [-][digits][parameter]),
253 // everythings else (+,*,^,()) is left to the singular interpreter
254  const char *s=st;
255  *a=(number)omAlloc(sizeof(nmod_poly_t));
256  nmod_poly_init((nmod_poly_ptr)(*a),r->ch);
257  BOOLEAN neg=FALSE;
258  if (*s=='-') { neg=TRUE; s++;}
259  if (isdigit(*s))
260  {
261  int z;
262  s=Eati((char *)s, &z);
263  nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),0,z);
264  }
265  else if(strncmp(s,r->pParameterNames[0],strlen(r->pParameterNames[0]))==0)
266  {
267  nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),1,1);
268  s+=strlen(r->pParameterNames[0]);
269  if(isdigit(*s))
270  {
271  int i=1;
272  s=Eati(s,&i);
273  if (i!=1)
274  {
275  nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),1,0);
276  nmod_poly_set_coeff_ui((nmod_poly_ptr)(*a),i,1);
277  }
278  }
279  }
280  if (neg)
281  nmod_poly_neg((nmod_poly_ptr)(*a),(nmod_poly_ptr)(*a));
282  return s;
283 }
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 467 of file flintcf_Zn.cc.

468 {
469  // format: len a_len .. a_0
470  nmod_poly_ptr aa=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
471  nmod_poly_init(aa,r->ch);
472  int l=s_readint(d->f_read);
473  unsigned long ul;
474  for (int i=l;i>=0;i--)
475  {
476  unsigned long ul=s_readlong(d->f_read);
477  nmod_poly_set_coeff_ui(aa,i,ul);
478  }
479  return (number)aa;
480 }
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 64 of file flintcf_Zn.cc.

65 {
66  // dummy
67 }

◆ SetMap()

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

Definition at line 362 of file flintcf_Zn.cc.

363 {
364  WerrorS("not yet: SetMap");
365  return NULL;
366 }

◆ Size()

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

Definition at line 150 of file flintcf_Zn.cc.

151 {
152  return nmod_poly_degree((nmod_poly_ptr)n);
153 }

◆ Sub()

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

Definition at line 75 of file flintcf_Zn.cc.

76 {
77  nmod_poly_ptr res=(nmod_poly_ptr)omAlloc(sizeof(nmod_poly_t));
78  nmod_poly_init(res,c->ch);
79  nmod_poly_sub(res,(nmod_poly_ptr)a,(nmod_poly_ptr)b);
80  return (number)res;
81 }

◆ WriteFd()

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

Definition at line 454 of file flintcf_Zn.cc.

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

◆ WriteShort()

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

Definition at line 220 of file flintcf_Zn.cc.

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