My Project  UNKNOWN_GIT_VERSION
Macros | Functions
modulop.cc File Reference
#include "misc/auxiliary.h"
#include "omalloc/omalloc.h"
#include "factory/factory.h"
#include "misc/mylimits.h"
#include "misc/sirandom.h"
#include "reporter/reporter.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "coeffs/mpr_complex.h"
#include "coeffs/longrat.h"
#include "coeffs/modulop.h"
#include <string.h>

Go to the source code of this file.

Macros

#define ULONG64   (unsigned long)
 

Functions

BOOLEAN npGreaterZero (number k, const coeffs r)
 
number npMult (number a, number b, const coeffs r)
 
number npInit (long i, const coeffs r)
 
long npInt (number &n, const coeffs r)
 
void npPower (number a, int i, number *result, const coeffs r)
 
BOOLEAN npIsZero (number a, const coeffs r)
 
BOOLEAN npIsOne (number a, const coeffs r)
 
BOOLEAN npIsMOne (number a, const coeffs r)
 
number npDiv (number a, number b, const coeffs r)
 
number npNeg (number c, const coeffs r)
 
number npInvers (number c, const coeffs r)
 
BOOLEAN npGreater (number a, number b, const coeffs r)
 
BOOLEAN npEqual (number a, number b, const coeffs r)
 
void npWrite (number a, const coeffs r)
 
void npCoeffWrite (const coeffs r, BOOLEAN details)
 
const char * npRead (const char *s, number *a, const coeffs r)
 
void nvInpMult (number &a, number b, const coeffs r)
 
BOOLEAN npDBTest (number a, const char *f, const int l, const coeffs r)
 
nMapFunc npSetMap (const coeffs src, const coeffs dst)
 
static number nvMultM (number a, number b, const coeffs r)
 
number nvMult (number a, number b, const coeffs r)
 
number nvDiv (number a, number b, const coeffs r)
 
number nvInvers (number c, const coeffs r)
 
void npInpMult (number &a, number b, const coeffs r)
 
static const char * npEati (const char *s, int *i, const coeffs r)
 
void npKillChar (coeffs r)
 
static BOOLEAN npCoeffsEqual (const coeffs r, n_coeffType n, void *parameter)
 
CanonicalForm npConvSingNFactoryN (number n, BOOLEAN setChar, const coeffs r)
 
number npConvFactoryNSingN (const CanonicalForm n, const coeffs r)
 
static char * npCoeffName (const coeffs cf)
 
static char * npCoeffString (const coeffs cf)
 
static void npWriteFd (number n, const ssiInfo *d, const coeffs)
 
static number npReadFd (const ssiInfo *d, const coeffs)
 
static number npRandom (siRandProc p, number, number, const coeffs cf)
 
BOOLEAN npInitChar (coeffs r, void *p)
 
static number npMapP (number from, const coeffs src, const coeffs dst_r)
 
static number npMapLongR (number from, const coeffs, const coeffs dst_r)
 
static number npMapGMP (number from, const coeffs, const coeffs dst)
 
static number npMapZ (number from, const coeffs src, const coeffs dst)
 
static number npMapMachineInt (number from, const coeffs, const coeffs dst)
 
static number npMapCanonicalForm (number a, const coeffs, const coeffs dst)
 
static number nvInversM (number c, const coeffs r)
 

Macro Definition Documentation

◆ ULONG64

#define ULONG64   (unsigned long)

Function Documentation

◆ npCoeffName()

static char* npCoeffName ( const coeffs  cf)
static

Definition at line 347 of file modulop.cc.

349 {
350  static char npCoeffName_buf[15];
351  snprintf(npCoeffName_buf,14,"ZZ/%d",cf->ch);
352  return npCoeffName_buf;

◆ npCoeffsEqual()

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

Definition at line 323 of file modulop.cc.

325 {
326  /* test, if r is an instance of nInitCoeffs(n,parameter) */
327  return (n==n_Zp) && (r->ch==(int)(long)parameter);

◆ npCoeffString()

static char* npCoeffString ( const coeffs  cf)
static

Definition at line 354 of file modulop.cc.

356 {
357  return omStrDup(npCoeffName(cf));

◆ npCoeffWrite()

void npCoeffWrite ( const coeffs  r,
BOOLEAN  details 
)

Definition at line 766 of file modulop.cc.

768 {
769  Print("ZZ/%d",r->ch);

◆ npConvFactoryNSingN()

number npConvFactoryNSingN ( const CanonicalForm  n,
const coeffs  r 
)

Definition at line 334 of file modulop.cc.

336 {
337  if (n.isImm())
338  {
339  return npInit(n.intval(),r);
340  }
341  else
342  {
343  assume(0);
344  return NULL;
345  }

◆ npConvSingNFactoryN()

CanonicalForm npConvSingNFactoryN ( number  n,
BOOLEAN  setChar,
const coeffs  r 
)

Definition at line 328 of file modulop.cc.

330 {
331  if (setChar) setCharacteristic( r->ch );
332  return CanonicalForm(npInt( n,r ));

◆ npDBTest()

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

Definition at line 515 of file modulop.cc.

517 {
518  if (((long)a<0L) || ((long)a>(long)r->ch))
519  {
520  Print("wrong mod p number %ld at %s,%d\n",(long)a,f,l);
521  return FALSE;
522  }
523  return TRUE;

◆ npDiv()

number npDiv ( number  a,
number  b,
const coeffs  r 
)

Definition at line 149 of file modulop.cc.

151 {
152  n_Test(a, r);
153  n_Test(b, r);
154 
155  if ((long)b==0L)
156  {
157  WerrorS(nDivBy0);
158  return (number)0L;
159  }
160  if ((long)a==0) return (number)0L;
161 
162  number d;
163 #ifndef HAVE_GENERIC_MULT
164  int s = r->npLogTable[(long)a] - r->npLogTable[(long)b];
165  #ifdef HAVE_GENERIC_ADD
166  if (s < 0)
167  s += r->npPminus1M;
168  #else
169  #if SIZEOF_LONG == 8
170  s += ((long)s >> 63) & r->npPminus1M;
171  #else
172  s += ((long)s >> 31) & r->npPminus1M;
173  #endif
174  #endif
175  d = (number)(long)r->npExpTable[s];
176 #else
177  number inv=npInversM(b,r);
178  d = npMultM(a,inv,r);
179 #endif
180 
181  n_Test(d, r);
182  return d;
183 

◆ npEati()

static const char* npEati ( const char *  s,
int *  i,
const coeffs  r 
)
inlinestatic

Definition at line 265 of file modulop.cc.

267 {
268  return nEati((char *)s,i,(int)r->ch);

◆ npEqual()

BOOLEAN npEqual ( number  a,
number  b,
const coeffs  r 
)

Definition at line 225 of file modulop.cc.

227 {
228  n_Test(a, r);
229  n_Test(b, r);
230 
231 // return (long)a == (long)b;
232 
233  return npEqualM(a,b,r);

◆ npGreater()

BOOLEAN npGreater ( number  a,
number  b,
const coeffs  r 
)

Definition at line 216 of file modulop.cc.

218 {
219  n_Test(a, r);
220  n_Test(b, r);
221 
222  //return (long)a != (long)b;
223  return ((long)a) > ((long)b);

◆ npGreaterZero()

BOOLEAN npGreaterZero ( number  k,
const coeffs  r 
)

Definition at line 70 of file modulop.cc.

72 {
73  n_Test(k, r);
74 
75  int h = (int)((long) k);
76  return ((int)h !=0) && (h <= (r->ch>>1));

◆ npInit()

number npInit ( long  i,
const coeffs  r 
)

Definition at line 113 of file modulop.cc.

115 {
116  long ii=i % (long)r->ch;
117  if (ii < 0L) ii += (long)r->ch;
118 
119  number c = (number)ii;
120  n_Test(c, r);
121  return c;

◆ npInitChar()

BOOLEAN npInitChar ( coeffs  r,
void *  p 
)

Definition at line 377 of file modulop.cc.

379 {
380  assume( getCoeffType(r) == n_Zp );
381  const int c = (int) (long) p;
382 
383  assume( c > 0 );
384 
385  int i, w;
386 
387  r->is_field=TRUE;
388  r->is_domain=TRUE;
389  r->rep=n_rep_int;
390 
391  r->ch = c;
392  r->npPminus1M = c /*r->ch*/ - 1;
393 
394  //r->cfInitChar=npInitChar;
395  r->cfKillChar=npKillChar;
396  r->nCoeffIsEqual=npCoeffsEqual;
397  r->cfCoeffString=npCoeffString;
398  r->cfCoeffName=npCoeffName;
399  r->cfCoeffWrite=npCoeffWrite;
400 
401  r->cfMult = npMult;
402  r->cfInpMult = npInpMult;
403  r->cfSub = npSubM;
404  r->cfAdd = npAddM;
405  r->cfInpAdd = npInpAddM;
406  r->cfDiv = npDiv;
407  r->cfInit = npInit;
408  //r->cfSize = ndSize;
409  r->cfInt = npInt;
410  #ifdef HAVE_RINGS
411  //r->cfDivComp = NULL; // only for ring stuff
412  //r->cfIsUnit = NULL; // only for ring stuff
413  //r->cfGetUnit = NULL; // only for ring stuff
414  //r->cfExtGcd = NULL; // only for ring stuff
415  // r->cfDivBy = NULL; // only for ring stuff
416  #endif
417  r->cfInpNeg = npNeg;
418  r->cfInvers= npInvers;
419  //r->cfCopy = ndCopy;
420  //r->cfRePart = ndCopy;
421  //r->cfImPart = ndReturn0;
422  r->cfWriteLong = npWrite;
423  r->cfRead = npRead;
424  //r->cfNormalize=ndNormalize;
425  r->cfGreater = npGreater;
426  r->cfEqual = npEqual;
427  r->cfIsZero = npIsZero;
428  r->cfIsOne = npIsOne;
429  r->cfIsMOne = npIsMOne;
430  r->cfGreaterZero = npGreaterZero;
431  //r->cfPower = npPower;
432  //r->cfGetDenom = ndGetDenom;
433  //r->cfGetNumerator = ndGetNumerator;
434  //r->cfGcd = ndGcd;
435  //r->cfLcm = ndGcd;
436  //r->cfDelete= ndDelete;
437  r->cfSetMap = npSetMap;
438  //r->cfName = ndName;
439  //r->cfInpMult=ndInpMult;
440  r->convSingNFactoryN=npConvSingNFactoryN;
441  r->convFactoryNSingN=npConvFactoryNSingN;
442  r->cfRandom=npRandom;
443 #ifdef LDEBUG
444  // debug stuff
445  r->cfDBTest=npDBTest;
446 #endif
447 
448  // io via ssi
449  r->cfWriteFd=npWriteFd;
450  r->cfReadFd=npReadFd;
451 
452  // the variables:
453  r->type = n_Zp;
454  r->has_simple_Alloc=TRUE;
455  r->has_simple_Inverse=TRUE;
456 
457  // the tables
458 #ifdef NV_OPS
459  if (r->ch <=NV_MAX_PRIME)
460 #endif
461  {
462 #ifdef HAVE_INVTABLE
463  r->npInvTable=(unsigned short*)omAlloc0( r->ch*sizeof(unsigned short) );
464 #endif
465 #ifndef HAVE_GENERIC_MULT
466  r->npExpTable=(unsigned short *)omAlloc0( r->ch*sizeof(unsigned short) );
467  r->npLogTable=(unsigned short *)omAlloc0( r->ch*sizeof(unsigned short) );
468  r->npExpTable[0] = 1;
469  r->npLogTable[0] = 0;
470  if (r->ch > 2)
471  {
472  w = 1;
473  loop
474  {
475  r->npLogTable[1] = 0;
476  w++;
477  i = 0;
478  loop
479  {
480  i++;
481  r->npExpTable[i] =(int)(((long)w * (long)r->npExpTable[i-1]) % r->ch);
482  r->npLogTable[r->npExpTable[i]] = i;
483  if /*(i == r->ch - 1 ) ||*/ (/*(*/ r->npExpTable[i] == 1 /*)*/)
484  break;
485  }
486  if (i == r->ch - 1)
487  break;
488  }
489  }
490  else
491  {
492  r->npExpTable[1] = 1;
493  r->npLogTable[1] = 0;
494  }
495 #endif
496  }
497 #ifdef NV_OPS
498  else /*if (c>NV_MAX_PRIME)*/
499  {
500  r->cfMult = nvMult;
501  r->cfDiv = nvDiv;
502  r->cfExactDiv = nvDiv;
503  r->cfInvers = nvInvers;
504  r->cfInpMult = nvInpMult;
505  //r->cfPower= nvPower;
506  //if (c>FACTORY_MAX_PRIME) // factory will catch this error
507  //{
508  // r->convSingNFactoryN=ndConvSingNFactoryN;
509  //}
510  }
511 #endif
512  return FALSE;

◆ npInpMult()

void npInpMult ( number &  a,
number  b,
const coeffs  r 
)

Definition at line 98 of file modulop.cc.

100 {
101  n_Test(a, r);
102  n_Test(b, r);
103 
104  if (((long)a == 0) || ((long)b == 0))
105  a=(number)0;
106  else
107  a = npMultM(a,b, r);
108  n_Test(a, r);

◆ npInt()

long npInt ( number &  n,
const coeffs  r 
)

Definition at line 127 of file modulop.cc.

129 {
130  n_Test(n, r);
131 
132  if ((long)n > (((long)r->ch) >>1)) return ((long)n -((long)r->ch));
133  else return ((long)n);

◆ npInvers()

number npInvers ( number  c,
const coeffs  r 
)

Definition at line 184 of file modulop.cc.

186 {
187  n_Test(c, r);
188 
189  if ((long)c==0L)
190  {
191  WerrorS("1/0");
192  return (number)0L;
193  }
194  number d = npInversM(c,r);
195 
196  n_Test(d, r);
197  return d;

◆ npIsMOne()

BOOLEAN npIsMOne ( number  a,
const coeffs  r 
)

Definition at line 142 of file modulop.cc.

144 {
145  n_Test(a, r);
146 
147  return ((r->npPminus1M == (long)a) &&(1L!=(long)a))/*for char 2*/;

◆ npIsOne()

BOOLEAN npIsOne ( number  a,
const coeffs  r 
)

◆ npIsZero()

BOOLEAN npIsZero ( number  a,
const coeffs  r 
)

Definition at line 135 of file modulop.cc.

137 {
138  n_Test(a, r);
139 
140  return 0 == (long)a;

◆ npKillChar()

void npKillChar ( coeffs  r)

Definition at line 304 of file modulop.cc.

306 {
307  #ifdef HAVE_INVTABLE
308  if (r->npInvTable!=NULL)
309  {
310  omFreeSize( (void *)r->npInvTable, r->ch*sizeof(unsigned short) );
311  r->npInvTable=NULL;
312  }
313  #endif
314  #ifndef HAVE_GENERIC_MULT
315  if (r->npExpTable!=NULL)
316  {
317  omFreeSize( (void *)r->npExpTable, r->ch*sizeof(unsigned short) );
318  omFreeSize( (void *)r->npLogTable, r->ch*sizeof(unsigned short) );
319  r->npExpTable=NULL; r->npLogTable=NULL;
320  }
321  #endif

◆ npMapCanonicalForm()

static number npMapCanonicalForm ( number  a,
const  coeffs,
const coeffs  dst 
)
static

Definition at line 647 of file modulop.cc.

649 {
650  setCharacteristic (dst ->ch);
652  return (number) (f.intval());

◆ npMapGMP()

static number npMapGMP ( number  from,
const  coeffs,
const coeffs  dst 
)
static

Definition at line 614 of file modulop.cc.

616 {
617  mpz_ptr erg = (mpz_ptr) omAlloc(sizeof(mpz_t)); // evtl. spaeter mit bin
618  mpz_init(erg);
619 
620  mpz_mod_ui(erg, (mpz_ptr) from, dst->ch);
621  number r = (number) mpz_get_si(erg);
622 
623  mpz_clear(erg);
624  omFree((void *) erg);
625  return (number) r;

◆ npMapLongR()

static number npMapLongR ( number  from,
const  coeffs,
const coeffs  dst_r 
)
static

Definition at line 538 of file modulop.cc.

540 {
541  gmp_float *ff=(gmp_float*)from;
542  mpf_t *f=ff->_mpfp();
543  number res;
544  mpz_ptr dest,ndest;
545  int size,i;
546  int e,al,bl;
547  long iz;
548  mp_ptr qp,dd,nn;
549 
550  size = (*f)[0]._mp_size;
551  if (size == 0)
552  return npInit(0,dst_r);
553  if(size<0)
554  size = -size;
555 
556  qp = (*f)[0]._mp_d;
557  while(qp[0]==0)
558  {
559  qp++;
560  size--;
561  }
562 
563  if(dst_r->ch>2)
564  e=(*f)[0]._mp_exp-size;
565  else
566  e=0;
567  res = ALLOC_RNUMBER();
568 #if defined(LDEBUG)
569  res->debug=123456;
570 #endif
571  dest = res->z;
572 
573  long in=0;
574  if (e<0)
575  {
576  al = dest->_mp_size = size;
577  if (al<2) al = 2;
578  dd = (mp_ptr)omAlloc(sizeof(mp_limb_t)*al);
579  for (i=0;i<size;i++) dd[i] = qp[i];
580  bl = 1-e;
581  nn = (mp_ptr)omAlloc(sizeof(mp_limb_t)*bl);
582  nn[bl-1] = 1;
583  for (i=bl-2;i>=0;i--) nn[i] = 0;
584  ndest = res->n;
585  ndest->_mp_d = nn;
586  ndest->_mp_alloc = ndest->_mp_size = bl;
587  res->s = 0;
588  in=mpz_fdiv_ui(ndest,dst_r->ch);
589  mpz_clear(ndest);
590  }
591  else
592  {
593  al = dest->_mp_size = size+e;
594  if (al<2) al = 2;
595  dd = (mp_ptr)omAlloc(sizeof(mp_limb_t)*al);
596  for (i=0;i<size;i++) dd[i+e] = qp[i];
597  for (i=0;i<e;i++) dd[i] = 0;
598  res->s = 3;
599  }
600 
601  dest->_mp_d = dd;
602  dest->_mp_alloc = al;
603  iz=mpz_fdiv_ui(dest,dst_r->ch);
604  mpz_clear(dest);
605  if(res->s==0)
606  iz=(long)npDiv((number)iz,(number)in,dst_r);
607  FREE_RNUMBER(res); // Q!?
608  return (number)iz;

◆ npMapMachineInt()

static number npMapMachineInt ( number  from,
const  coeffs,
const coeffs  dst 
)
static

Definition at line 640 of file modulop.cc.

642 {
643  long i = (long) (((unsigned long) from) % dst->ch);
644  return (number) i;

◆ npMapP()

static number npMapP ( number  from,
const coeffs  src,
const coeffs  dst_r 
)
static

Definition at line 526 of file modulop.cc.

528 {
529  long i = (long)from;
530  if (i>src->ch/2)
531  {
532  i-=src->ch;
533  while (i < 0) i+=dst_r->ch;
534  }
535  i%=dst_r->ch;
536  return (number)i;

◆ npMapZ()

static number npMapZ ( number  from,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 627 of file modulop.cc.

629 {
630  if (SR_HDL(from) & SR_INT)
631  {
632  long f_i=SR_TO_INT(from);
633  return npInit(f_i,dst);
634  }
635  return npMapGMP(from,src,dst);

◆ npMult()

number npMult ( number  a,
number  b,
const coeffs  r 
)

Definition at line 86 of file modulop.cc.

88 {
89  n_Test(a, r);
90  n_Test(b, r);
91 
92  if (((long)a == 0) || ((long)b == 0))
93  return (number)0;
94  number c = npMultM(a,b, r);
95  n_Test(c, r);
96  return c;

◆ npNeg()

number npNeg ( number  c,
const coeffs  r 
)

Definition at line 199 of file modulop.cc.

201 {
202  n_Test(c, r);
203 
204  if ((long)c==0L) return c;
205 
206 #if 0
207  number d = npNegM(c,r);
208  n_Test(d, r);
209  return d;
210 #else
211  c = npNegM(c,r);
212  n_Test(c, r);
213  return c;
214 #endif

◆ npPower()

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

◆ npRandom()

static number npRandom ( siRandProc  p,
number  ,
number  ,
const coeffs  cf 
)
static

Definition at line 372 of file modulop.cc.

374 {
375  return npInit(p(),cf);

◆ npRead()

const char * npRead ( const char *  s,
number *  a,
const coeffs  r 
)

Definition at line 270 of file modulop.cc.

272 {
273  int z;
274  int n=1;
275 
276  s = npEati(s, &z, r);
277  if ((*s) == '/')
278  {
279  s++;
280  s = npEati(s, &n, r);
281  }
282  if (n == 1)
283  *a = (number)(long)z;
284  else
285  {
286  if ((z==0)&&(n==0)) WerrorS(nDivBy0);
287  else
288  {
289 #ifdef NV_OPS
290  if (r->ch>NV_MAX_PRIME)
291  *a = nvDiv((number)(long)z,(number)(long)n,r);
292  else
293 #endif
294  *a = npDiv((number)(long)z,(number)(long)n,r);
295  }
296  }
297  n_Test(*a, r);
298  return s;

◆ npReadFd()

static number npReadFd ( const ssiInfo d,
const  coeffs 
)
static

Definition at line 364 of file modulop.cc.

366 {
367  // read int
368  int dd;
369  dd=s_readint(d->f_read);
370  return (number)(long)dd;

◆ npSetMap()

nMapFunc npSetMap ( const coeffs  src,
const coeffs  dst 
)

Definition at line 654 of file modulop.cc.

656 {
657 #ifdef HAVE_RINGS
658  if ((src->rep==n_rep_int) && nCoeff_is_Ring_2toM(src))
659  {
660  return npMapMachineInt;
661  }
662  if (src->rep==n_rep_gmp) //nCoeff_is_Z(src) || nCoeff_is_Ring_PtoM(src) || nCoeff_is_Zn(src))
663  {
664  return npMapGMP;
665  }
666  if (src->rep==n_rep_gap_gmp) //nCoeff_is_Z(src)
667  {
668  return npMapZ;
669  }
670 #endif
671  if (src->rep==n_rep_gap_rat) /* Q, Z */
672  {
673  return nlModP; // npMap0; // FIXME? TODO? // extern number nlModP(number q, const coeffs Q, const coeffs Zp); // Map q \in QQ \to Zp // FIXME!
674  }
675  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src) )
676  {
677  if (n_GetChar(src) == n_GetChar(dst))
678  {
679  return ndCopyMap;
680  }
681  else
682  {
683  return npMapP;
684  }
685  }
686  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
687  {
688  return npMapLongR;
689  }
690  if (nCoeff_is_CF (src))
691  {
692  return npMapCanonicalForm;
693  }
694  return NULL; /* default */

◆ npWrite()

void npWrite ( number  a,
const coeffs  r 
)

Definition at line 235 of file modulop.cc.

237 {
238  n_Test(a, r);
239 
240  if ((long)a>(((long)r->ch) >>1)) StringAppend("-%d",(int)(((long)r->ch)-((long)a)));
241  else StringAppend("%d",(int)((long)a));

◆ npWriteFd()

static void npWriteFd ( number  n,
const ssiInfo d,
const  coeffs 
)
static

Definition at line 359 of file modulop.cc.

361 {
362  fprintf(d->f_write,"%d ",(int)(long)n);

◆ nvDiv()

number nvDiv ( number  a,
number  b,
const coeffs  r 
)

Definition at line 721 of file modulop.cc.

723 {
724  if ((long)a==0L)
725  return (number)0L;
726  else if ((long)b==0L)
727  {
728  WerrorS(nDivBy0);
729  return (number)0L;
730  }
731  else
732  {
733  number inv=nvInversM(b,r);
734  return nvMultM(a,inv,r);
735  }

◆ nvInpMult()

void nvInpMult ( number &  a,
number  b,
const coeffs  r 
)

Definition at line 709 of file modulop.cc.

711 {
712  number n=nvMultM(a,b,r);
713  a=n;

◆ nvInvers()

number nvInvers ( number  c,
const coeffs  r 
)

Definition at line 736 of file modulop.cc.

738 {
739  if ((long)c==0L)
740  {
741  WerrorS(nDivBy0);
742  return (number)0L;
743  }
744  return nvInversM(c,r);

◆ nvInversM()

static number nvInversM ( number  c,
const coeffs  r 
)
inlinestatic

Definition at line 715 of file modulop.cc.

717 {
718  long inv=npInvMod((long)c,r);
719  return (number)inv;

◆ nvMult()

number nvMult ( number  a,
number  b,
const coeffs  r 
)

Definition at line 701 of file modulop.cc.

703 {
704  //if (((long)a == 0) || ((long)b == 0))
705  // return (number)0;
706  //else
707  return nvMultM(a,b,r);

◆ nvMultM()

static number nvMultM ( number  a,
number  b,
const coeffs  r 
)
inlinestatic

Definition at line 52 of file modulop.cc.

54 {
55  assume( getCoeffType(r) == n_Zp );
56 
57 #if SIZEOF_LONG == 4
58 #define ULONG64 (unsigned long long)(unsigned long)
59 #else
60 #define ULONG64 (unsigned long)
61 #endif
62  return (number)
63  (unsigned long)((ULONG64 a)*(ULONG64 b) % (ULONG64 r->ch));
getCoeffType
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:420
n_rep_gap_rat
(number), see longrat.h
Definition: coeffs.h:110
FALSE
#define FALSE
Definition: auxiliary.h:94
n_rep_gmp
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:114
nvMult
number nvMult(number a, number b, const coeffs r)
Definition: modulop.cc:701
npWrite
void npWrite(number a, const coeffs r)
Definition: modulop.cc:235
ALLOC_RNUMBER
#define ALLOC_RNUMBER()
Definition: coeffs.h:86
nCoeff_is_Zp
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:821
f
FILE * f
Definition: checklibs.c:9
omFree
#define omFree(addr)
Definition: omAllocDecl.h:259
k
int k
Definition: cfEzgcd.cc:92
nCoeff_is_Ring_2toM
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:745
nvMultM
static number nvMultM(number a, number b, const coeffs r)
Definition: modulop.cc:52
npSetMap
nMapFunc npSetMap(const coeffs src, const coeffs dst)
Definition: modulop.cc:654
s_readint
int s_readint(s_buff F)
Definition: s_buff.cc:110
npEqualM
#define npEqualM(A, B, r)
Definition: modulop.h:274
npMultM
static number npMultM(number a, number b, const coeffs r)
Definition: modulop.h:71
n_GetChar
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:443
npCoeffString
static char * npCoeffString(const coeffs cf)
Definition: modulop.cc:354
npIsOne
BOOLEAN npIsOne(number a, const coeffs r)
npRead
const char * npRead(const char *s, number *a, const coeffs r)
Definition: modulop.cc:270
cf
CanonicalForm cf
Definition: cfModGcd.cc:4024
npReadFd
static number npReadFd(const ssiInfo *d, const coeffs)
Definition: modulop.cc:364
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:261
ndCopyMap
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:252
nvInvers
number nvInvers(number c, const coeffs r)
Definition: modulop.cc:736
InternalCF
virtual class for internal CanonicalForm's
Definition: int_cf.h:41
n_rep_int
(int), see modulop.h
Definition: coeffs.h:109
loop
#define loop
Definition: structs.h:77
ssiInfo::f_read
s_buff f_read
Definition: s_buff.h:22
npMapCanonicalForm
static number npMapCanonicalForm(number a, const coeffs, const coeffs dst)
Definition: modulop.cc:647
w
const CanonicalForm & w
Definition: facAbsFact.cc:55
CanonicalForm::isImm
bool isImm() const
Definition: canonicalform.h:107
b
CanonicalForm b
Definition: cfModGcd.cc:4044
npInit
number npInit(long i, const coeffs r)
Definition: modulop.cc:113
npCoeffWrite
void npCoeffWrite(const coeffs r, BOOLEAN details)
Definition: modulop.cc:766
gmp_float::_mpfp
mpf_t * _mpfp()
Definition: mpr_complex.h:133
npInvers
number npInvers(number c, const coeffs r)
Definition: modulop.cc:184
CanonicalForm
factory's main class
Definition: canonicalform.h:77
npMapZ
static number npMapZ(number from, const coeffs src, const coeffs dst)
Definition: modulop.cc:627
nvDiv
number nvDiv(number a, number b, const coeffs r)
Definition: modulop.cc:721
npCoeffName
static char * npCoeffName(const coeffs cf)
Definition: modulop.cc:347
CanonicalForm::intval
long intval() const
conversion functions
Definition: canonicalform.cc:197
npWriteFd
static void npWriteFd(number n, const ssiInfo *d, const coeffs)
Definition: modulop.cc:359
npEqual
BOOLEAN npEqual(number a, number b, const coeffs r)
Definition: modulop.cc:225
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
npAddM
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:124
res
CanonicalForm res
Definition: facAbsFact.cc:64
npSubM
static number npSubM(number a, number b, const coeffs r)
Definition: modulop.h:134
nDivBy0
const char *const nDivBy0
Definition: numbers.h:88
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:258
npNegM
static number npNegM(number a, const coeffs r)
Definition: modulop.h:174
h
static Poly * h
Definition: janet.cc:972
setCharacteristic
void setCharacteristic(int c)
Definition: cf_char.cc:23
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
nCoeff_is_long_R
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:912
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:208
FREE_RNUMBER
#define FREE_RNUMBER(x)
Definition: coeffs.h:85
npMult
number npMult(number a, number b, const coeffs r)
Definition: modulop.cc:86
npEati
static const char * npEati(const char *s, int *i, const coeffs r)
Definition: modulop.cc:265
nlModP
number nlModP(number q, const coeffs, const coeffs Zp)
Definition: longrat.cc:1434
npInvMod
static long npInvMod(long a, const coeffs R)
Definition: modulop.h:188
ssiInfo::f_write
FILE * f_write
Definition: s_buff.h:23
nCoeff_is_CF
static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
Definition: coeffs.h:918
npInpAddM
static void npInpAddM(number &a, number b, const coeffs r)
Definition: modulop.h:129
ULONG64
#define ULONG64
npInpMult
void npInpMult(number &a, number b, const coeffs r)
Definition: modulop.cc:98
npGreaterZero
BOOLEAN npGreaterZero(number k, const coeffs r)
Definition: modulop.cc:70
npDiv
number npDiv(number a, number b, const coeffs r)
Definition: modulop.cc:149
SR_INT
#define SR_INT
Definition: longrat.h:65
npIsMOne
BOOLEAN npIsMOne(number a, const coeffs r)
Definition: modulop.cc:142
SR_TO_INT
#define SR_TO_INT(SR)
Definition: longrat.h:67
npCoeffsEqual
static BOOLEAN npCoeffsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: modulop.cc:323
npInt
long npInt(number &n, const coeffs r)
Definition: modulop.cc:127
npMapP
static number npMapP(number from, const coeffs src, const coeffs dst_r)
Definition: modulop.cc:526
npMapGMP
static number npMapGMP(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:614
npKillChar
void npKillChar(coeffs r)
Definition: modulop.cc:304
n_Zp
\F{p < 2^31}
Definition: coeffs.h:29
n_rep_gmp_float
(gmp_float), see
Definition: coeffs.h:116
NV_MAX_PRIME
#define NV_MAX_PRIME
Definition: modulop.h:28
Print
#define Print
Definition: emacs.cc:79
npMapLongR
static number npMapLongR(number from, const coeffs, const coeffs dst_r)
Definition: modulop.cc:538
nvInversM
static number nvInversM(number c, const coeffs r)
Definition: modulop.cc:715
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
SR_HDL
#define SR_HDL(A)
Definition: tgb.cc:35
assume
#define assume(x)
Definition: mod2.h:384
NULL
#define NULL
Definition: omList.c:9
l
int l
Definition: cfEzgcd.cc:93
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:631
StringAppend
#define StringAppend
Definition: emacs.cc:78
p
int p
Definition: cfModGcd.cc:4019
npRandom
static number npRandom(siRandProc p, number, number, const coeffs cf)
Definition: modulop.cc:372
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
npConvSingNFactoryN
CanonicalForm npConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: modulop.cc:328
npDBTest
BOOLEAN npDBTest(number a, const char *f, const int l, const coeffs r)
Definition: modulop.cc:515
n_Test
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:737
npNeg
number npNeg(number c, const coeffs r)
Definition: modulop.cc:199
npIsZero
BOOLEAN npIsZero(number a, const coeffs r)
Definition: modulop.cc:135
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:209
gmp_float
Definition: mpr_complex.h:30
if
if(yy_init)
Definition: libparse.cc:1417
npConvFactoryNSingN
number npConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: modulop.cc:334
nvInpMult
void nvInpMult(number &a, number b, const coeffs r)
Definition: modulop.cc:709
npInversM
static number npInversM(number c, const coeffs r)
Definition: modulop.h:233
npMapMachineInt
static number npMapMachineInt(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:640
npGreater
BOOLEAN npGreater(number a, number b, const coeffs r)
Definition: modulop.cc:216
n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:111