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   32003
 
#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

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

Definition at line 132 of file modulop.h.

#define NV_MAX_PRIME   32003

Definition at line 21 of file modulop.h.

#define NV_OPS

Definition at line 20 of file modulop.h.

Function Documentation

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
#define R
Definition: sirandom.c:26
const poly b
Definition: syzextra.cc:213
BOOLEAN npInitChar ( coeffs  r,
void *  p 
)

Definition at line 500 of file modulop.cc.

501 {
502  assume( getCoeffType(r) == ID );
503  const int c = (int) (long) p;
504 
505  assume( c > 0 );
506 
507  int i, w;
508 
509  r->is_field=TRUE;
510  r->is_domain=TRUE;
511  r->rep=n_rep_int;
512 
513  r->ch = c;
514  r->npPminus1M = c /*r->ch*/ - 1;
515 
516  //r->cfInitChar=npInitChar;
517  r->cfKillChar=npKillChar;
518  r->nCoeffIsEqual=npCoeffsEqual;
519  r->cfCoeffString=npCoeffString;
520 
521  r->cfMult = npMult;
522  r->cfSub = npSub;
523  r->cfAdd = npAdd;
524  r->cfDiv = npDiv;
525  r->cfInit = npInit;
526  //r->cfSize = ndSize;
527  r->cfInt = npInt;
528  #ifdef HAVE_RINGS
529  //r->cfDivComp = NULL; // only for ring stuff
530  //r->cfIsUnit = NULL; // only for ring stuff
531  //r->cfGetUnit = NULL; // only for ring stuff
532  //r->cfExtGcd = NULL; // only for ring stuff
533  // r->cfDivBy = NULL; // only for ring stuff
534  #endif
535  r->cfInpNeg = npNeg;
536  r->cfInvers= npInvers;
537  //r->cfCopy = ndCopy;
538  //r->cfRePart = ndCopy;
539  //r->cfImPart = ndReturn0;
540  r->cfWriteLong = npWrite;
541  r->cfRead = npRead;
542  //r->cfNormalize=ndNormalize;
543  r->cfGreater = npGreater;
544  r->cfEqual = npEqual;
545  r->cfIsZero = npIsZero;
546  r->cfIsOne = npIsOne;
547  r->cfIsMOne = npIsMOne;
548  r->cfGreaterZero = npGreaterZero;
549  //r->cfPower = npPower;
550  //r->cfGetDenom = ndGetDenom;
551  //r->cfGetNumerator = ndGetNumerator;
552  //r->cfGcd = ndGcd;
553  //r->cfLcm = ndGcd;
554  //r->cfDelete= ndDelete;
555  r->cfSetMap = npSetMap;
556  //r->cfName = ndName;
557  //r->cfInpMult=ndInpMult;
558 #ifdef NV_OPS
559  if (c>NV_MAX_PRIME)
560  {
561  r->cfMult = nvMult;
562  r->cfDiv = nvDiv;
563  r->cfExactDiv= nvDiv;
564  r->cfInvers= nvInvers;
565  //r->cfPower= nvPower;
566  }
567 #endif
568  r->cfCoeffWrite=npCoeffWrite;
569 #ifdef LDEBUG
570  // debug stuff
571  r->cfDBTest=npDBTest;
572 #endif
573 
574  r->convSingNFactoryN=npConvSingNFactoryN;
575  r->convFactoryNSingN=npConvFactoryNSingN;
576 
577  r->cfRandom=npRandom;
578 
579  // io via ssi
580  r->cfWriteFd=npWriteFd;
581  r->cfReadFd=npReadFd;
582 
583  // the variables:
584  r->nNULL = (number)0;
585  r->type = n_Zp;
586  r->ch = c;
587  r->has_simple_Alloc=TRUE;
588  r->has_simple_Inverse=TRUE;
589 
590  // the tables
591 #ifdef NV_OPS
592  if (r->ch <=NV_MAX_PRIME)
593 #endif
594  {
595 #if !defined(HAVE_DIV_MOD) || !defined(HAVE_MULT_MOD)
596  r->npExpTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
597  r->npLogTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
598  r->npExpTable[0] = 1;
599  r->npLogTable[0] = 0;
600  if (r->ch > 2)
601  {
602  w = 1;
603  loop
604  {
605  r->npLogTable[1] = 0;
606  w++;
607  i = 0;
608  loop
609  {
610  i++;
611  r->npExpTable[i] =(int)(((long)w * (long)r->npExpTable[i-1]) % r->ch);
612  r->npLogTable[r->npExpTable[i]] = i;
613  if /*(i == r->ch - 1 ) ||*/ (/*(*/ r->npExpTable[i] == 1 /*)*/)
614  break;
615  }
616  if (i == r->ch - 1)
617  break;
618  }
619  }
620  else
621  {
622  r->npExpTable[1] = 1;
623  r->npLogTable[1] = 0;
624  }
625 #endif
626 #ifdef HAVE_DIV_MOD
627  r->npInvTable=(unsigned short*)omAlloc0( r->ch*sizeof(unsigned short) );
628 #endif
629  }
630  return FALSE;
631 }
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
number npInit(long i, const coeffs r)
Definition: modulop.cc:130
long npInt(number &n, const coeffs r)
Definition: modulop.cc:145
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
number nvInvers(number c, const coeffs r)
Definition: modulop.cc:896
number npInvers(number c, const coeffs r)
Definition: modulop.cc:298
number nvMult(number a, number b, const coeffs r)
Definition: modulop.cc:820
{p < 2^31}
Definition: coeffs.h:29
number npAdd(number a, number b, const coeffs r)
Definition: modulop.cc:153
#define TRUE
Definition: auxiliary.h:144
number npDiv(number a, number b, const coeffs r)
Definition: modulop.cc:265
static number npReadFd(s_buff f, const coeffs r)
Definition: modulop.cc:487
BOOLEAN npEqual(number a, number b, const coeffs r)
Definition: modulop.cc:340
#define omAlloc(size)
Definition: omAllocDecl.h:210
BOOLEAN npDBTest(number a, const char *f, const int l, const coeffs r)
Definition: modulop.cc:634
static void npWriteFd(number n, FILE *f, const coeffs r)
Definition: modulop.cc:482
static number npRandom(siRandProc p, number, number, const coeffs cf)
Definition: modulop.cc:495
BOOLEAN npGreater(number a, number b, const coeffs r)
Definition: modulop.cc:331
number nvDiv(number a, number b, const coeffs r)
Definition: modulop.cc:881
BOOLEAN npIsMOne(number a, const coeffs r)
Definition: modulop.cc:191
void npCoeffWrite(const coeffs r, BOOLEAN details)
Definition: modulop.cc:926
static const n_coeffType ID
Our Type!
Definition: modulop.cc:28
#define assume(x)
Definition: mod2.h:405
BOOLEAN npGreaterZero(number k, const coeffs r)
Definition: modulop.cc:99
int i
Definition: cfEzgcd.cc:123
nMapFunc npSetMap(const coeffs src, const coeffs dst)
Definition: modulop.cc:773
static char * npCoeffString(const coeffs r)
Definition: modulop.cc:475
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
void npWrite(number &a, const coeffs r)
Definition: modulop.cc:350
number npSub(number a, number b, const coeffs r)
Definition: modulop.cc:165
number npConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: modulop.cc:462
#define NV_MAX_PRIME
Definition: modulop.h:21
number npNeg(number c, const coeffs r)
Definition: modulop.cc:314
const CanonicalForm & w
Definition: facAbsFact.cc:55
number npMult(number a, number b, const coeffs r)
Definition: modulop.cc:115
CanonicalForm npConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: modulop.cc:455
static BOOLEAN npCoeffsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: modulop.cc:450
(int), see modulop.h
Definition: coeffs.h:108
void npKillChar(coeffs r)
Definition: modulop.cc:434
const char * npRead(const char *s, number *a, const coeffs r)
Definition: modulop.cc:400
BOOLEAN npIsOne(number a, const coeffs r)
Definition: modulop.cc:184
BOOLEAN npIsZero(number a, const coeffs r)
Definition: modulop.cc:177
#define omAlloc0(size)
Definition: omAllocDecl.h:211
long npInt ( number &  n,
const coeffs  r 
)

Definition at line 145 of file modulop.cc.

146 {
147  n_Test(n, r);
148 
149  if ((long)n > (((long)r->ch) >>1)) return ((long)n -((long)r->ch));
150  else return ((long)n);
151 }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:918
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
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
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
nMapFunc npSetMap ( const coeffs  src,
const coeffs  dst 
)

Definition at line 773 of file modulop.cc.

774 {
775 #ifdef HAVE_RINGS
776  if ((src->rep==n_rep_int) && nCoeff_is_Ring_2toM(src))
777  {
778  return npMapMachineInt;
779  }
780  if (src->rep==n_rep_gmp) //nCoeff_is_Ring_Z(src) || nCoeff_is_Ring_PtoM(src) || nCoeff_is_Ring_ModN(src))
781  {
782  return npMapGMP;
783  }
784  if (src->rep==n_rep_gap_gmp) //nCoeff_is_Ring_Z(src)
785  {
786  return npMapZ;
787  }
788 #endif
789  if (src->rep==n_rep_gap_rat) /* Q, Z */
790  {
791  return nlModP; // npMap0; // FIXME? TODO? // extern number nlModP(number q, const coeffs Q, const coeffs Zp); // Map q \in QQ \to Zp // FIXME!
792  }
793  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src) )
794  {
795  if (n_GetChar(src) == n_GetChar(dst))
796  {
797  return ndCopyMap;
798  }
799  else
800  {
801  return npMapP;
802  }
803  }
804  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
805  {
806  return npMapLongR;
807  }
808  if (nCoeff_is_CF (src))
809  {
810  return npMapCanonicalForm;
811  }
812  return NULL; /* default */
813 }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:816
number npMapZ(number from, const coeffs src, const coeffs dst)
Definition: modulop.cc:746
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:228
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:887
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:739
(), see rinteger.h, new impl.
Definition: coeffs.h:110
number npMapP(number from, const coeffs src, const coeffs r)
Definition: modulop.cc:645
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:444
number npMapMachineInt(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:759
static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
Definition: coeffs.h:893
number nlModP(number q, const coeffs Q, const coeffs Zp)
Definition: longrat.cc:1355
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:113
static number npMapLongR(number from, const coeffs, const coeffs dst_r)
Definition: modulop.cc:657
(number), see longrat.h
Definition: coeffs.h:109
#define NULL
Definition: omList.c:10
(gmp_float), see
Definition: coeffs.h:115
(int), see modulop.h
Definition: coeffs.h:108
number npMapGMP(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:733
number npMapCanonicalForm(number a, const coeffs, const coeffs dst)
Definition: modulop.cc:766
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