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 504 of file modulop.cc.

505 {
506  assume( getCoeffType(r) == n_Zp );
507  const int c = (int) (long) p;
508 
509  assume( c > 0 );
510 
511  int i, w;
512 
513  r->is_field=TRUE;
514  r->is_domain=TRUE;
515  r->rep=n_rep_int;
516 
517  r->ch = c;
518  r->npPminus1M = c /*r->ch*/ - 1;
519 
520  //r->cfInitChar=npInitChar;
521  r->cfKillChar=npKillChar;
522  r->nCoeffIsEqual=npCoeffsEqual;
523  r->cfCoeffString=npCoeffString;
524  r->cfCoeffName=npCoeffName;
525  r->cfCoeffWrite=npCoeffWrite;
526 
527  r->cfMult = npMult;
528  r->cfSub = npSub;
529  r->cfAdd = npAdd;
530  r->cfDiv = npDiv;
531  r->cfInit = npInit;
532  //r->cfSize = ndSize;
533  r->cfInt = npInt;
534  #ifdef HAVE_RINGS
535  //r->cfDivComp = NULL; // only for ring stuff
536  //r->cfIsUnit = NULL; // only for ring stuff
537  //r->cfGetUnit = NULL; // only for ring stuff
538  //r->cfExtGcd = NULL; // only for ring stuff
539  // r->cfDivBy = NULL; // only for ring stuff
540  #endif
541  r->cfInpNeg = npNeg;
542  r->cfInvers= npInvers;
543  //r->cfCopy = ndCopy;
544  //r->cfRePart = ndCopy;
545  //r->cfImPart = ndReturn0;
546  r->cfWriteLong = npWrite;
547  r->cfRead = npRead;
548  //r->cfNormalize=ndNormalize;
549  r->cfGreater = npGreater;
550  r->cfEqual = npEqual;
551  r->cfIsZero = npIsZero;
552  r->cfIsOne = npIsOne;
553  r->cfIsMOne = npIsMOne;
554  r->cfGreaterZero = npGreaterZero;
555  //r->cfPower = npPower;
556  //r->cfGetDenom = ndGetDenom;
557  //r->cfGetNumerator = ndGetNumerator;
558  //r->cfGcd = ndGcd;
559  //r->cfLcm = ndGcd;
560  //r->cfDelete= ndDelete;
561  r->cfSetMap = npSetMap;
562  //r->cfName = ndName;
563  //r->cfInpMult=ndInpMult;
564 #ifdef NV_OPS
565  if (c>NV_MAX_PRIME)
566  {
567  r->cfMult = nvMult;
568  r->cfDiv = nvDiv;
569  r->cfExactDiv= nvDiv;
570  r->cfInvers= nvInvers;
571  //r->cfPower= nvPower;
572  }
573 #endif
574 #ifdef LDEBUG
575  // debug stuff
576  r->cfDBTest=npDBTest;
577 #endif
578 
579  r->convSingNFactoryN=npConvSingNFactoryN;
580  r->convFactoryNSingN=npConvFactoryNSingN;
581 
582  r->cfRandom=npRandom;
583 
584  // io via ssi
585  r->cfWriteFd=npWriteFd;
586  r->cfReadFd=npReadFd;
587 
588  // the variables:
589  r->nNULL = (number)0;
590  r->type = n_Zp;
591  r->ch = c;
592  r->has_simple_Alloc=TRUE;
593  r->has_simple_Inverse=TRUE;
594 
595  // the tables
596 #ifdef NV_OPS
597  if (r->ch <=NV_MAX_PRIME)
598 #endif
599  {
600 #if !defined(HAVE_DIV_MOD) || !defined(HAVE_MULT_MOD)
601  r->npExpTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
602  r->npLogTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
603  r->npExpTable[0] = 1;
604  r->npLogTable[0] = 0;
605  if (r->ch > 2)
606  {
607  w = 1;
608  loop
609  {
610  r->npLogTable[1] = 0;
611  w++;
612  i = 0;
613  loop
614  {
615  i++;
616  r->npExpTable[i] =(int)(((long)w * (long)r->npExpTable[i-1]) % r->ch);
617  r->npLogTable[r->npExpTable[i]] = i;
618  if /*(i == r->ch - 1 ) ||*/ (/*(*/ r->npExpTable[i] == 1 /*)*/)
619  break;
620  }
621  if (i == r->ch - 1)
622  break;
623  }
624  }
625  else
626  {
627  r->npExpTable[1] = 1;
628  r->npLogTable[1] = 0;
629  }
630 #endif
631 #ifdef HAVE_DIV_MOD
632  r->npInvTable=(unsigned short*)omAlloc0( r->ch*sizeof(unsigned short) );
633 #endif
634  }
635  return FALSE;
636 }
number npInit(long i, const coeffs r)
Definition: modulop.cc:125
long npInt(number &n, const coeffs r)
Definition: modulop.cc:140
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:95
return P p
Definition: myNF.cc:203
number nvInvers(number c, const coeffs r)
Definition: modulop.cc:901
static void npWriteFd(number n, FILE *f, const coeffs)
Definition: modulop.cc:486
number npInvers(number c, const coeffs r)
Definition: modulop.cc:293
static char * npCoeffName(const coeffs cf)
Definition: modulop.cc:470
number nvMult(number a, number b, const coeffs r)
Definition: modulop.cc:825
{p < 2^31}
Definition: coeffs.h:30
number npAdd(number a, number b, const coeffs r)
Definition: modulop.cc:148
void npWrite(number a, const coeffs r)
Definition: modulop.cc:345
#define TRUE
Definition: auxiliary.h:99
number npDiv(number a, number b, const coeffs r)
Definition: modulop.cc:260
BOOLEAN npEqual(number a, number b, const coeffs r)
Definition: modulop.cc:335
#define omAlloc(size)
Definition: omAllocDecl.h:210
BOOLEAN npDBTest(number a, const char *f, const int l, const coeffs r)
Definition: modulop.cc:639
static number npRandom(siRandProc p, number, number, const coeffs cf)
Definition: modulop.cc:499
BOOLEAN npGreater(number a, number b, const coeffs r)
Definition: modulop.cc:326
number nvDiv(number a, number b, const coeffs r)
Definition: modulop.cc:886
BOOLEAN npIsMOne(number a, const coeffs r)
Definition: modulop.cc:186
void npCoeffWrite(const coeffs r, BOOLEAN details)
Definition: modulop.cc:931
#define assume(x)
Definition: mod2.h:403
BOOLEAN npGreaterZero(number k, const coeffs r)
Definition: modulop.cc:94
int i
Definition: cfEzgcd.cc:123
nMapFunc npSetMap(const coeffs src, const coeffs dst)
Definition: modulop.cc:778
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:160
number npConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: modulop.cc:457
#define NV_MAX_PRIME
Definition: modulop.h:21
static char * npCoeffString(const coeffs cf)
Definition: modulop.cc:481
number npNeg(number c, const coeffs r)
Definition: modulop.cc:309
const CanonicalForm & w
Definition: facAbsFact.cc:55
number npMult(number a, number b, const coeffs r)
Definition: modulop.cc:110
CanonicalForm npConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: modulop.cc:450
static number npReadFd(s_buff f, const coeffs)
Definition: modulop.cc:491
static BOOLEAN npCoeffsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: modulop.cc:445
(int), see modulop.h
Definition: coeffs.h:110
void npKillChar(coeffs r)
Definition: modulop.cc:429
const char * npRead(const char *s, number *a, const coeffs r)
Definition: modulop.cc:395
BOOLEAN npIsOne(number a, const coeffs r)
Definition: modulop.cc:179
BOOLEAN npIsZero(number a, const coeffs r)
Definition: modulop.cc:172
#define omAlloc0(size)
Definition: omAllocDecl.h:211

§ npInt()

long npInt ( number &  n,
const coeffs  r 
)

Definition at line 140 of file modulop.cc.

141 {
142  n_Test(n, r);
143 
144  if ((long)n > (((long)r->ch) >>1)) return ((long)n -((long)r->ch));
145  else return ((long)n);
146 }
#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
long npPminus1M
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 778 of file modulop.cc.

779 {
780 #ifdef HAVE_RINGS
781  if ((src->rep==n_rep_int) && nCoeff_is_Ring_2toM(src))
782  {
783  return npMapMachineInt;
784  }
785  if (src->rep==n_rep_gmp) //nCoeff_is_Ring_Z(src) || nCoeff_is_Ring_PtoM(src) || nCoeff_is_Ring_ModN(src))
786  {
787  return npMapGMP;
788  }
789  if (src->rep==n_rep_gap_gmp) //nCoeff_is_Ring_Z(src)
790  {
791  return npMapZ;
792  }
793 #endif
794  if (src->rep==n_rep_gap_rat) /* Q, Z */
795  {
796  return nlModP; // npMap0; // FIXME? TODO? // extern number nlModP(number q, const coeffs Q, const coeffs Zp); // Map q \in QQ \to Zp // FIXME!
797  }
798  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src) )
799  {
800  if (n_GetChar(src) == n_GetChar(dst))
801  {
802  return ndCopyMap;
803  }
804  else
805  {
806  return npMapP;
807  }
808  }
809  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
810  {
811  return npMapLongR;
812  }
813  if (nCoeff_is_CF (src))
814  {
815  return npMapCanonicalForm;
816  }
817  return NULL; /* default */
818 }
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:1425
number npMapZ(number from, const coeffs src, const coeffs dst)
Definition: modulop.cc:751
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:905
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:750
(), see rinteger.h, new impl.
Definition: coeffs.h:112
number npMapP(number from, const coeffs src, const coeffs r)
Definition: modulop.cc:650
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:448
number npMapMachineInt(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:764
static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
Definition: coeffs.h:911
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:115
static number npMapLongR(number from, const coeffs, const coeffs dst_r)
Definition: modulop.cc:662
(number), see longrat.h
Definition: coeffs.h:111
#define NULL
Definition: omList.c:10
(gmp_float), see
Definition: coeffs.h:117
(int), see modulop.h
Definition: coeffs.h:110
number npMapGMP(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:738
number npMapCanonicalForm(number a, const coeffs, const coeffs dst)
Definition: modulop.cc:771

§ 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