Macros | Functions
modulop.h File Reference
#include <misc/auxiliary.h>

Go to the source code of this file.

Macros

#define NV_OPS
 
#define NV_MAX_PRIME   32749
 
#define npEqualM(A, B, r)   ((A)==(B))
 

Functions

BOOLEAN npInitChar (coeffs r, void *p)
 
static number npMultM (number a, number b, const coeffs r)
 
static number npAddM (number a, number b, const coeffs r)
 
static number npSubM (number a, number b, const coeffs r)
 
static number npNegM (number a, const coeffs r)
 
static BOOLEAN npIsZeroM (number a, const coeffs)
 
long npInt (number &n, const coeffs r)
 
nMapFunc npSetMap (const coeffs src, const coeffs dst)
 

Macro Definition Documentation

◆ npEqualM

#define npEqualM (   A,
  B,
  r 
)    ((A)==(B))

Definition at line 132 of file modulop.h.

◆ NV_MAX_PRIME

#define NV_MAX_PRIME   32749

Definition at line 21 of file modulop.h.

◆ NV_OPS

#define NV_OPS

Definition at line 20 of file modulop.h.

Function Documentation

◆ npAddM()

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

Definition at line 77 of file modulop.h.

78 {
79  unsigned long R = (unsigned long)a + (unsigned long)b;
80  return (number)(R >= r->ch ? R - r->ch : R);
81 }
const poly a
Definition: syzextra.cc:212
const ring R
Definition: DebugPrint.cc:36
const poly b
Definition: syzextra.cc:213

◆ npInitChar()

BOOLEAN npInitChar ( coeffs  r,
void *  p 
)

Definition at line 475 of file modulop.cc.

476 {
477  assume( getCoeffType(r) == n_Zp );
478  const int c = (int) (long) p;
479 
480  assume( c > 0 );
481 
482  int i, w;
483 
484  r->is_field=TRUE;
485  r->is_domain=TRUE;
486  r->rep=n_rep_int;
487 
488  r->ch = c;
489  r->npPminus1M = c /*r->ch*/ - 1;
490 
491  //r->cfInitChar=npInitChar;
492  r->cfKillChar=npKillChar;
493  r->nCoeffIsEqual=npCoeffsEqual;
494  r->cfCoeffString=npCoeffString;
495  r->cfCoeffName=npCoeffName;
496  r->cfCoeffWrite=npCoeffWrite;
497 
498  r->cfMult = npMult;
499  r->cfSub = npSub;
500  r->cfAdd = npAdd;
501  r->cfDiv = npDiv;
502  r->cfInit = npInit;
503  //r->cfSize = ndSize;
504  r->cfInt = npInt;
505  #ifdef HAVE_RINGS
506  //r->cfDivComp = NULL; // only for ring stuff
507  //r->cfIsUnit = NULL; // only for ring stuff
508  //r->cfGetUnit = NULL; // only for ring stuff
509  //r->cfExtGcd = NULL; // only for ring stuff
510  // r->cfDivBy = NULL; // only for ring stuff
511  #endif
512  r->cfInpNeg = npNeg;
513  r->cfInvers= npInvers;
514  //r->cfCopy = ndCopy;
515  //r->cfRePart = ndCopy;
516  //r->cfImPart = ndReturn0;
517  r->cfWriteLong = npWrite;
518  r->cfRead = npRead;
519  //r->cfNormalize=ndNormalize;
520  r->cfGreater = npGreater;
521  r->cfEqual = npEqual;
522  r->cfIsZero = npIsZero;
523  r->cfIsOne = npIsOne;
524  r->cfIsMOne = npIsMOne;
525  r->cfGreaterZero = npGreaterZero;
526  //r->cfPower = npPower;
527  //r->cfGetDenom = ndGetDenom;
528  //r->cfGetNumerator = ndGetNumerator;
529  //r->cfGcd = ndGcd;
530  //r->cfLcm = ndGcd;
531  //r->cfDelete= ndDelete;
532  r->cfSetMap = npSetMap;
533  //r->cfName = ndName;
534  //r->cfInpMult=ndInpMult;
535 #ifdef NV_OPS
536  if (c>NV_MAX_PRIME)
537  {
538  r->cfMult = nvMult;
539  r->cfDiv = nvDiv;
540  r->cfExactDiv= nvDiv;
541  r->cfInvers= nvInvers;
542  //r->cfPower= nvPower;
543  }
544 #endif
545 #ifdef LDEBUG
546  // debug stuff
547  r->cfDBTest=npDBTest;
548 #endif
549 
550  r->convSingNFactoryN=npConvSingNFactoryN;
551  r->convFactoryNSingN=npConvFactoryNSingN;
552 
553  r->cfRandom=npRandom;
554 
555  // io via ssi
556  r->cfWriteFd=npWriteFd;
557  r->cfReadFd=npReadFd;
558 
559  // the variables:
560  r->nNULL = (number)0;
561  r->type = n_Zp;
562  r->has_simple_Alloc=TRUE;
563  r->has_simple_Inverse=TRUE;
564 
565  // the tables
566 #ifdef NV_OPS
567  if (r->ch <=NV_MAX_PRIME)
568 #endif
569  {
570 #if !defined(HAVE_DIV_MOD) || !defined(HAVE_MULT_MOD)
571  r->npExpTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
572  r->npLogTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
573  r->npExpTable[0] = 1;
574  r->npLogTable[0] = 0;
575  if (r->ch > 2)
576  {
577  w = 1;
578  loop
579  {
580  r->npLogTable[1] = 0;
581  w++;
582  i = 0;
583  loop
584  {
585  i++;
586  r->npExpTable[i] =(int)(((long)w * (long)r->npExpTable[i-1]) % r->ch);
587  r->npLogTable[r->npExpTable[i]] = i;
588  if /*(i == r->ch - 1 ) ||*/ (/*(*/ r->npExpTable[i] == 1 /*)*/)
589  break;
590  }
591  if (i == r->ch - 1)
592  break;
593  }
594  }
595  else
596  {
597  r->npExpTable[1] = 1;
598  r->npLogTable[1] = 0;
599  }
600 #endif
601 #ifdef HAVE_DIV_MOD
602  r->npInvTable=(unsigned short*)omAlloc0( r->ch*sizeof(unsigned short) );
603 #endif
604  }
605  return FALSE;
606 }
number npInit(long i, const coeffs r)
Definition: modulop.cc:103
long npInt(number &n, const coeffs r)
Definition: modulop.cc:117
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
number nvInvers(number c, const coeffs r)
Definition: modulop.cc:871
static void npWriteFd(number n, FILE *f, const coeffs)
Definition: modulop.cc:457
number npInvers(number c, const coeffs r)
Definition: modulop.cc:270
static char * npCoeffName(const coeffs cf)
Definition: modulop.cc:445
number nvMult(number a, number b, const coeffs r)
Definition: modulop.cc:795
{p < 2^31}
Definition: coeffs.h:30
number npAdd(number a, number b, const coeffs r)
Definition: modulop.cc:125
void npWrite(number a, const coeffs r)
Definition: modulop.cc:321
#define TRUE
Definition: auxiliary.h:98
number npDiv(number a, number b, const coeffs r)
Definition: modulop.cc:237
BOOLEAN npEqual(number a, number b, const coeffs r)
Definition: modulop.cc:311
#define omAlloc(size)
Definition: omAllocDecl.h:210
BOOLEAN npDBTest(number a, const char *f, const int l, const coeffs r)
Definition: modulop.cc:609
static number npRandom(siRandProc p, number, number, const coeffs cf)
Definition: modulop.cc:470
BOOLEAN npGreater(number a, number b, const coeffs r)
Definition: modulop.cc:302
number nvDiv(number a, number b, const coeffs r)
Definition: modulop.cc:856
BOOLEAN npIsMOne(number a, const coeffs r)
Definition: modulop.cc:163
void npCoeffWrite(const coeffs r, BOOLEAN details)
Definition: modulop.cc:901
#define assume(x)
Definition: mod2.h:394
BOOLEAN npGreaterZero(number k, const coeffs r)
Definition: modulop.cc:72
int i
Definition: cfEzgcd.cc:123
nMapFunc npSetMap(const coeffs src, const coeffs dst)
Definition: modulop.cc:748
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
number npSub(number a, number b, const coeffs r)
Definition: modulop.cc:137
number npConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: modulop.cc:432
#define NV_MAX_PRIME
Definition: modulop.h:21
static char * npCoeffString(const coeffs cf)
Definition: modulop.cc:452
number npNeg(number c, const coeffs r)
Definition: modulop.cc:285
const CanonicalForm & w
Definition: facAbsFact.cc:55
number npMult(number a, number b, const coeffs r)
Definition: modulop.cc:88
CanonicalForm npConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: modulop.cc:425
static number npReadFd(s_buff f, const coeffs)
Definition: modulop.cc:462
static BOOLEAN npCoeffsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: modulop.cc:420
(int), see modulop.h
Definition: coeffs.h:110
void npKillChar(coeffs r)
Definition: modulop.cc:404
const char * npRead(const char *s, number *a, const coeffs r)
Definition: modulop.cc:370
BOOLEAN npIsOne(number a, const coeffs r)
Definition: modulop.cc:156
BOOLEAN npIsZero(number a, const coeffs r)
Definition: modulop.cc:149
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ npInt()

long npInt ( number &  n,
const coeffs  r 
)

Definition at line 117 of file modulop.cc.

118 {
119  n_Test(n, r);
120 
121  if ((long)n > (((long)r->ch) >>1)) return ((long)n -((long)r->ch));
122  else return ((long)n);
123 }
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:742

◆ npIsZeroM()

static BOOLEAN npIsZeroM ( number  a,
const coeffs   
)
inlinestatic

Definition at line 116 of file modulop.h.

117 {
118  return 0 == (long)a;
119 }
const poly a
Definition: syzextra.cc:212

◆ npMultM()

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

Definition at line 49 of file modulop.h.

50 {
51  long x = (long)r->npLogTable[(long)a]+ r->npLogTable[(long)b];
52  return (number)(long)r->npExpTable[x<r->npPminus1M ? x : x- r->npPminus1M];
53 }
const poly a
Definition: syzextra.cc:212
Variable x
Definition: cfModGcd.cc:4023
const poly b
Definition: syzextra.cc:213

◆ npNegM()

static number npNegM ( number  a,
const coeffs  r 
)
inlinestatic

Definition at line 111 of file modulop.h.

112 {
113  return (number)((long)(r->ch)-(long)(a));
114 }
const poly a
Definition: syzextra.cc:212

◆ npSetMap()

nMapFunc npSetMap ( const coeffs  src,
const coeffs  dst 
)

Definition at line 748 of file modulop.cc.

749 {
750 #ifdef HAVE_RINGS
751  if ((src->rep==n_rep_int) && nCoeff_is_Ring_2toM(src))
752  {
753  return npMapMachineInt;
754  }
755  if (src->rep==n_rep_gmp) //nCoeff_is_Ring_Z(src) || nCoeff_is_Ring_PtoM(src) || nCoeff_is_Ring_ModN(src))
756  {
757  return npMapGMP;
758  }
759  if (src->rep==n_rep_gap_gmp) //nCoeff_is_Ring_Z(src)
760  {
761  return npMapZ;
762  }
763 #endif
764  if (src->rep==n_rep_gap_rat) /* Q, Z */
765  {
766  return nlModP; // npMap0; // FIXME? TODO? // extern number nlModP(number q, const coeffs Q, const coeffs Zp); // Map q \in QQ \to Zp // FIXME!
767  }
768  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src) )
769  {
770  if (n_GetChar(src) == n_GetChar(dst))
771  {
772  return ndCopyMap;
773  }
774  else
775  {
776  return npMapP;
777  }
778  }
779  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
780  {
781  return npMapLongR;
782  }
783  if (nCoeff_is_CF (src))
784  {
785  return npMapCanonicalForm;
786  }
787  return NULL; /* default */
788 }
static number npMapMachineInt(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:734
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:834
number nlModP(number q, const coeffs, const coeffs Zp)
Definition: longrat.cc:1440
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:244
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:908
static number npMapP(number from, const coeffs src, const coeffs dst_r)
Definition: modulop.cc:620
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:750
(), see rinteger.h, new impl.
Definition: coeffs.h:112
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:448
static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
Definition: coeffs.h:914
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:115
static number npMapLongR(number from, const coeffs, const coeffs dst_r)
Definition: modulop.cc:632
(number), see longrat.h
Definition: coeffs.h:111
#define NULL
Definition: omList.c:10
(gmp_float), see
Definition: coeffs.h:117
static number npMapCanonicalForm(number a, const coeffs, const coeffs dst)
Definition: modulop.cc:741
static number npMapZ(number from, const coeffs src, const coeffs dst)
Definition: modulop.cc:721
static number npMapGMP(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:708
(int), see modulop.h
Definition: coeffs.h:110

◆ npSubM()

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

Definition at line 82 of file modulop.h.

83 {
84  return (number)((long)a<(long)b ?
85  r->ch-(long)b+(long)a : (long)a-(long)b);
86 }
const poly a
Definition: syzextra.cc:212
const poly b
Definition: syzextra.cc:213