My Project  debian-1:4.1.2-p1+ds-2
Macros | Functions
modulop.cc File Reference
#include "misc/auxiliary.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 346 of file modulop.cc.

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

◆ npCoeffsEqual()

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

Definition at line 322 of file modulop.cc.

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

◆ npCoeffString()

static char* npCoeffString ( const coeffs  cf)
static

Definition at line 353 of file modulop.cc.

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

◆ npCoeffWrite()

void npCoeffWrite ( const coeffs  r,
BOOLEAN  details 
)

Definition at line 765 of file modulop.cc.

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

◆ npConvFactoryNSingN()

number npConvFactoryNSingN ( const CanonicalForm  n,
const coeffs  r 
)

Definition at line 333 of file modulop.cc.

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

◆ npConvSingNFactoryN()

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

Definition at line 327 of file modulop.cc.

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

◆ npDBTest()

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

Definition at line 514 of file modulop.cc.

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

◆ npDiv()

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

Definition at line 148 of file modulop.cc.

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

◆ npEati()

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

Definition at line 264 of file modulop.cc.

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

◆ npEqual()

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

Definition at line 224 of file modulop.cc.

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

◆ npGreater()

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

Definition at line 215 of file modulop.cc.

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

◆ npGreaterZero()

BOOLEAN npGreaterZero ( number  k,
const coeffs  r 
)

Definition at line 69 of file modulop.cc.

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

◆ npInit()

number npInit ( long  i,
const coeffs  r 
)

Definition at line 112 of file modulop.cc.

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

◆ npInitChar()

BOOLEAN npInitChar ( coeffs  r,
void *  p 
)

Definition at line 376 of file modulop.cc.

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

◆ npInpMult()

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

Definition at line 97 of file modulop.cc.

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

◆ npInt()

long npInt ( number &  n,
const coeffs  r 
)

Definition at line 126 of file modulop.cc.

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

◆ npInvers()

number npInvers ( number  c,
const coeffs  r 
)

Definition at line 183 of file modulop.cc.

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

◆ npIsMOne()

BOOLEAN npIsMOne ( number  a,
const coeffs  r 
)

Definition at line 141 of file modulop.cc.

143 {
144  n_Test(a, r);
145 
146  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 134 of file modulop.cc.

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

◆ npKillChar()

void npKillChar ( coeffs  r)

Definition at line 303 of file modulop.cc.

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

◆ npMapCanonicalForm()

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

Definition at line 646 of file modulop.cc.

648 {
649  setCharacteristic (dst ->ch);
651  return (number) (f.intval());

◆ npMapGMP()

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

Definition at line 613 of file modulop.cc.

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

◆ npMapLongR()

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

Definition at line 537 of file modulop.cc.

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

◆ npMapMachineInt()

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

Definition at line 639 of file modulop.cc.

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

◆ npMapP()

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

Definition at line 525 of file modulop.cc.

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

◆ npMapZ()

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

Definition at line 626 of file modulop.cc.

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

◆ npMult()

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

Definition at line 85 of file modulop.cc.

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

◆ npNeg()

number npNeg ( number  c,
const coeffs  r 
)

Definition at line 198 of file modulop.cc.

200 {
201  n_Test(c, r);
202 
203  if ((long)c==0L) return c;
204 
205 #if 0
206  number d = npNegM(c,r);
207  n_Test(d, r);
208  return d;
209 #else
210  c = npNegM(c,r);
211  n_Test(c, r);
212  return c;
213 #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 371 of file modulop.cc.

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

◆ npRead()

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

Definition at line 269 of file modulop.cc.

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

◆ npReadFd()

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

Definition at line 363 of file modulop.cc.

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

◆ npSetMap()

nMapFunc npSetMap ( const coeffs  src,
const coeffs  dst 
)

Definition at line 653 of file modulop.cc.

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

◆ npWrite()

void npWrite ( number  a,
const coeffs  r 
)

Definition at line 234 of file modulop.cc.

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

◆ npWriteFd()

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

Definition at line 358 of file modulop.cc.

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

◆ nvDiv()

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

Definition at line 720 of file modulop.cc.

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

◆ nvInpMult()

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

Definition at line 708 of file modulop.cc.

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

◆ nvInvers()

number nvInvers ( number  c,
const coeffs  r 
)

Definition at line 735 of file modulop.cc.

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

◆ nvInversM()

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

Definition at line 714 of file modulop.cc.

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

◆ nvMult()

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

Definition at line 700 of file modulop.cc.

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

◆ nvMultM()

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

Definition at line 51 of file modulop.cc.

53 {
54  assume( getCoeffType(r) == n_Zp );
55 
56 #if SIZEOF_LONG == 4
57 #define ULONG64 (unsigned long long)(unsigned long)
58 #else
59 #define ULONG64 (unsigned long)
60 #endif
61  return (number)
62  (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:96
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:700
npWrite
void npWrite(number a, const coeffs r)
Definition: modulop.cc:234
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:51
npSetMap
nMapFunc npSetMap(const coeffs src, const coeffs dst)
Definition: modulop.cc:653
s_readint
int s_readint(s_buff F)
Definition: s_buff.cc:112
npEqualM
#define npEqualM(A, B, r)
Definition: modulop.h:270
npMultM
static number npMultM(number a, number b, const coeffs r)
Definition: modulop.h:67
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:353
npIsOne
BOOLEAN npIsOne(number a, const coeffs r)
h
STATIC_VAR Poly * h
Definition: janet.cc:971
npRead
const char * npRead(const char *s, number *a, const coeffs r)
Definition: modulop.cc:269
cf
CanonicalForm cf
Definition: cfModGcd.cc:4024
npReadFd
static number npReadFd(const ssiInfo *d, const coeffs)
Definition: modulop.cc:363
STATIC_VAR
#define STATIC_VAR
Definition: globaldefs.h:7
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:261
ndCopyMap
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
nvInvers
number nvInvers(number c, const coeffs r)
Definition: modulop.cc:735
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:79
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:646
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:112
npCoeffWrite
void npCoeffWrite(const coeffs r, BOOLEAN details)
Definition: modulop.cc:765
gmp_float::_mpfp
mpf_t * _mpfp()
Definition: mpr_complex.h:133
npInvers
number npInvers(number c, const coeffs r)
Definition: modulop.cc:183
CanonicalForm
factory's main class
Definition: canonicalform.h:77
npMapZ
static number npMapZ(number from, const coeffs src, const coeffs dst)
Definition: modulop.cc:626
nvDiv
number nvDiv(number a, number b, const coeffs r)
Definition: modulop.cc:720
npCoeffName
static char * npCoeffName(const coeffs cf)
Definition: modulop.cc:346
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:358
npEqual
BOOLEAN npEqual(number a, number b, const coeffs r)
Definition: modulop.cc:224
TRUE
#define TRUE
Definition: auxiliary.h:100
i
int i
Definition: cfEzgcd.cc:125
npAddM
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:120
res
CanonicalForm res
Definition: facAbsFact.cc:64
npSubM
static number npSubM(number a, number b, const coeffs r)
Definition: modulop.h:130
nDivBy0
const char *const nDivBy0
Definition: numbers.h:87
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:258
npNegM
static number npNegM(number a, const coeffs r)
Definition: modulop.h:170
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:85
npEati
static const char * npEati(const char *s, int *i, const coeffs r)
Definition: modulop.cc:264
nlModP
number nlModP(number q, const coeffs, const coeffs Zp)
Definition: longrat.cc:1433
npInvMod
static long npInvMod(long a, const coeffs R)
Definition: modulop.h:184
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:125
ULONG64
#define ULONG64
npInpMult
void npInpMult(number &a, number b, const coeffs r)
Definition: modulop.cc:97
npGreaterZero
BOOLEAN npGreaterZero(number k, const coeffs r)
Definition: modulop.cc:69
npDiv
number npDiv(number a, number b, const coeffs r)
Definition: modulop.cc:148
SR_INT
#define SR_INT
Definition: longrat.h:65
npIsMOne
BOOLEAN npIsMOne(number a, const coeffs r)
Definition: modulop.cc:141
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:322
npInt
long npInt(number &n, const coeffs r)
Definition: modulop.cc:126
npMapP
static number npMapP(number from, const coeffs src, const coeffs dst_r)
Definition: modulop.cc:525
npMapGMP
static number npMapGMP(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:613
npKillChar
void npKillChar(coeffs r)
Definition: modulop.cc:303
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:537
nvInversM
static number nvInversM(number c, const coeffs r)
Definition: modulop.cc:714
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:11
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:630
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:371
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
npConvSingNFactoryN
CanonicalForm npConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: modulop.cc:327
npDBTest
BOOLEAN npDBTest(number a, const char *f, const int l, const coeffs r)
Definition: modulop.cc:514
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:198
npIsZero
BOOLEAN npIsZero(number a, const coeffs r)
Definition: modulop.cc:134
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:209
gmp_float
Definition: mpr_complex.h:30
if
if(yy_init)
Definition: libparse.cc:1419
npConvFactoryNSingN
number npConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: modulop.cc:333
nvInpMult
void nvInpMult(number &a, number b, const coeffs r)
Definition: modulop.cc:708
npInversM
static number npInversM(number c, const coeffs r)
Definition: modulop.h:229
npMapMachineInt
static number npMapMachineInt(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:639
npGreater
BOOLEAN npGreater(number a, number b, const coeffs r)
Definition: modulop.cc:215
n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:111