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

499 {
500  assume( getCoeffType(r) == ID );
501  const int c = (int) (long) p;
502 
503  assume( c > 0 );
504 
505  int i, w;
506 
507  r->is_field=TRUE;
508  r->is_domain=TRUE;
509  r->rep=n_rep_int;
510 
511  r->ch = c;
512  r->npPminus1M = c /*r->ch*/ - 1;
513 
514  //r->cfInitChar=npInitChar;
515  r->cfKillChar=npKillChar;
516  r->nCoeffIsEqual=npCoeffsEqual;
517  r->cfCoeffString=npCoeffString;
518 
519  r->cfMult = npMult;
520  r->cfSub = npSub;
521  r->cfAdd = npAdd;
522  r->cfDiv = npDiv;
523  r->cfInit = npInit;
524  //r->cfSize = ndSize;
525  r->cfInt = npInt;
526  #ifdef HAVE_RINGS
527  //r->cfDivComp = NULL; // only for ring stuff
528  //r->cfIsUnit = NULL; // only for ring stuff
529  //r->cfGetUnit = NULL; // only for ring stuff
530  //r->cfExtGcd = NULL; // only for ring stuff
531  // r->cfDivBy = NULL; // only for ring stuff
532  #endif
533  r->cfInpNeg = npNeg;
534  r->cfInvers= npInvers;
535  //r->cfCopy = ndCopy;
536  //r->cfRePart = ndCopy;
537  //r->cfImPart = ndReturn0;
538  r->cfWriteLong = npWrite;
539  r->cfRead = npRead;
540  //r->cfNormalize=ndNormalize;
541  r->cfGreater = npGreater;
542  r->cfEqual = npEqual;
543  r->cfIsZero = npIsZero;
544  r->cfIsOne = npIsOne;
545  r->cfIsMOne = npIsMOne;
546  r->cfGreaterZero = npGreaterZero;
547  //r->cfPower = npPower;
548  //r->cfGetDenom = ndGetDenom;
549  //r->cfGetNumerator = ndGetNumerator;
550  //r->cfGcd = ndGcd;
551  //r->cfLcm = ndGcd;
552  //r->cfDelete= ndDelete;
553  r->cfSetMap = npSetMap;
554  //r->cfName = ndName;
555  //r->cfInpMult=ndInpMult;
556 #ifdef NV_OPS
557  if (c>NV_MAX_PRIME)
558  {
559  r->cfMult = nvMult;
560  r->cfDiv = nvDiv;
561  r->cfExactDiv= nvDiv;
562  r->cfInvers= nvInvers;
563  //r->cfPower= nvPower;
564  }
565 #endif
566  r->cfCoeffWrite=npCoeffWrite;
567 #ifdef LDEBUG
568  // debug stuff
569  r->cfDBTest=npDBTest;
570 #endif
571 
572  r->convSingNFactoryN=npConvSingNFactoryN;
573  r->convFactoryNSingN=npConvFactoryNSingN;
574 
575  r->cfRandom=npRandom;
576 
577  // io via ssi
578  r->cfWriteFd=npWriteFd;
579  r->cfReadFd=npReadFd;
580 
581  // the variables:
582  r->nNULL = (number)0;
583  r->type = n_Zp;
584  r->ch = c;
585  r->has_simple_Alloc=TRUE;
586  r->has_simple_Inverse=TRUE;
587 
588  // the tables
589 #ifdef NV_OPS
590  if (r->ch <=NV_MAX_PRIME)
591 #endif
592  {
593 #if !defined(HAVE_DIV_MOD) || !defined(HAVE_MULT_MOD)
594  r->npExpTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
595  r->npLogTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
596  r->npExpTable[0] = 1;
597  r->npLogTable[0] = 0;
598  if (r->ch > 2)
599  {
600  w = 1;
601  loop
602  {
603  r->npLogTable[1] = 0;
604  w++;
605  i = 0;
606  loop
607  {
608  i++;
609  r->npExpTable[i] =(int)(((long)w * (long)r->npExpTable[i-1]) % r->ch);
610  r->npLogTable[r->npExpTable[i]] = i;
611  if /*(i == r->ch - 1 ) ||*/ (/*(*/ r->npExpTable[i] == 1 /*)*/)
612  break;
613  }
614  if (i == r->ch - 1)
615  break;
616  }
617  }
618  else
619  {
620  r->npExpTable[1] = 1;
621  r->npLogTable[1] = 0;
622  }
623 #endif
624 #ifdef HAVE_DIV_MOD
625  r->npInvTable=(unsigned short*)omAlloc0( r->ch*sizeof(unsigned short) );
626 #endif
627  }
628  return FALSE;
629 }
number npInit(long i, const coeffs r)
Definition: modulop.cc:128
long npInt(number &n, const coeffs r)
Definition: modulop.cc:143
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:894
number npInvers(number c, const coeffs r)
Definition: modulop.cc:296
number nvMult(number a, number b, const coeffs r)
Definition: modulop.cc:818
{p < 2^31}
Definition: coeffs.h:30
number npAdd(number a, number b, const coeffs r)
Definition: modulop.cc:151
void npWrite(number a, const coeffs r)
Definition: modulop.cc:348
#define TRUE
Definition: auxiliary.h:144
number npDiv(number a, number b, const coeffs r)
Definition: modulop.cc:263
static number npReadFd(s_buff f, const coeffs r)
Definition: modulop.cc:485
BOOLEAN npEqual(number a, number b, const coeffs r)
Definition: modulop.cc:338
#define omAlloc(size)
Definition: omAllocDecl.h:210
BOOLEAN npDBTest(number a, const char *f, const int l, const coeffs r)
Definition: modulop.cc:632
static void npWriteFd(number n, FILE *f, const coeffs r)
Definition: modulop.cc:480
static number npRandom(siRandProc p, number, number, const coeffs cf)
Definition: modulop.cc:493
BOOLEAN npGreater(number a, number b, const coeffs r)
Definition: modulop.cc:329
number nvDiv(number a, number b, const coeffs r)
Definition: modulop.cc:879
BOOLEAN npIsMOne(number a, const coeffs r)
Definition: modulop.cc:189
void npCoeffWrite(const coeffs r, BOOLEAN details)
Definition: modulop.cc:924
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:97
int i
Definition: cfEzgcd.cc:123
nMapFunc npSetMap(const coeffs src, const coeffs dst)
Definition: modulop.cc:771
static char * npCoeffString(const coeffs r)
Definition: modulop.cc:473
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
number npSub(number a, number b, const coeffs r)
Definition: modulop.cc:163
number npConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: modulop.cc:460
#define NV_MAX_PRIME
Definition: modulop.h:21
number npNeg(number c, const coeffs r)
Definition: modulop.cc:312
const CanonicalForm & w
Definition: facAbsFact.cc:55
number npMult(number a, number b, const coeffs r)
Definition: modulop.cc:113
CanonicalForm npConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: modulop.cc:453
static BOOLEAN npCoeffsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: modulop.cc:448
(int), see modulop.h
Definition: coeffs.h:109
void npKillChar(coeffs r)
Definition: modulop.cc:432
const char * npRead(const char *s, number *a, const coeffs r)
Definition: modulop.cc:398
BOOLEAN npIsOne(number a, const coeffs r)
Definition: modulop.cc:182
BOOLEAN npIsZero(number a, const coeffs r)
Definition: modulop.cc:175
#define omAlloc0(size)
Definition: omAllocDecl.h:211
long npInt ( number &  n,
const coeffs  r 
)

Definition at line 143 of file modulop.cc.

144 {
145  n_Test(n, r);
146 
147  if ((long)n > (((long)r->ch) >>1)) return ((long)n -((long)r->ch));
148  else return ((long)n);
149 }
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:923
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 771 of file modulop.cc.

772 {
773 #ifdef HAVE_RINGS
774  if ((src->rep==n_rep_int) && nCoeff_is_Ring_2toM(src))
775  {
776  return npMapMachineInt;
777  }
778  if (src->rep==n_rep_gmp) //nCoeff_is_Ring_Z(src) || nCoeff_is_Ring_PtoM(src) || nCoeff_is_Ring_ModN(src))
779  {
780  return npMapGMP;
781  }
782  if (src->rep==n_rep_gap_gmp) //nCoeff_is_Ring_Z(src)
783  {
784  return npMapZ;
785  }
786 #endif
787  if (src->rep==n_rep_gap_rat) /* Q, Z */
788  {
789  return nlModP; // npMap0; // FIXME? TODO? // extern number nlModP(number q, const coeffs Q, const coeffs Zp); // Map q \in QQ \to Zp // FIXME!
790  }
791  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src) )
792  {
793  if (n_GetChar(src) == n_GetChar(dst))
794  {
795  return ndCopyMap;
796  }
797  else
798  {
799  return npMapP;
800  }
801  }
802  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
803  {
804  return npMapLongR;
805  }
806  if (nCoeff_is_CF (src))
807  {
808  return npMapCanonicalForm;
809  }
810  return NULL; /* default */
811 }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:818
number npMapZ(number from, const coeffs src, const coeffs dst)
Definition: modulop.cc:744
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:239
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:892
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:741
(), see rinteger.h, new impl.
Definition: coeffs.h:111
number npMapP(number from, const coeffs src, const coeffs r)
Definition: modulop.cc:643
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:445
number npMapMachineInt(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:757
static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
Definition: coeffs.h:898
number nlModP(number q, const coeffs Q, const coeffs Zp)
Definition: longrat.cc:1368
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:114
static number npMapLongR(number from, const coeffs, const coeffs dst_r)
Definition: modulop.cc:655
(number), see longrat.h
Definition: coeffs.h:110
#define NULL
Definition: omList.c:10
(gmp_float), see
Definition: coeffs.h:116
(int), see modulop.h
Definition: coeffs.h:109
number npMapGMP(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:731
number npMapCanonicalForm(number a, const coeffs, const coeffs dst)
Definition: modulop.cc:764
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