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

501 {
502  assume( getCoeffType(r) == n_Zp );
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 }
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:97
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:293
number nvMult(number a, number b, const coeffs r)
Definition: modulop.cc:820
{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:101
number npDiv(number a, number b, const coeffs r)
Definition: modulop.cc:260
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:335
#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:326
number nvDiv(number a, number b, const coeffs r)
Definition: modulop.cc:881
BOOLEAN npIsMOne(number a, const coeffs r)
Definition: modulop.cc:186
void npCoeffWrite(const coeffs r, BOOLEAN details)
Definition: modulop.cc:926
#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:773
static char * npCoeffString(const coeffs r)
Definition: modulop.cc:470
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
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 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 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:834
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:239
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:645
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:759
static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
Definition: coeffs.h:911
number nlModP(number q, const coeffs Q, const coeffs Zp)
Definition: longrat.cc:1423
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:115
static number npMapLongR(number from, const coeffs, const coeffs dst_r)
Definition: modulop.cc:657
(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:733
number npMapCanonicalForm(number a, const coeffs, const coeffs dst)
Definition: modulop.cc:766

§ 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