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  r->cfCoeffName=npCoeffName;
521  r->cfCoeffWrite=npCoeffWrite;
522 
523  r->cfMult = npMult;
524  r->cfSub = npSub;
525  r->cfAdd = npAdd;
526  r->cfDiv = npDiv;
527  r->cfInit = npInit;
528  //r->cfSize = ndSize;
529  r->cfInt = npInt;
530  #ifdef HAVE_RINGS
531  //r->cfDivComp = NULL; // only for ring stuff
532  //r->cfIsUnit = NULL; // only for ring stuff
533  //r->cfGetUnit = NULL; // only for ring stuff
534  //r->cfExtGcd = NULL; // only for ring stuff
535  // r->cfDivBy = NULL; // only for ring stuff
536  #endif
537  r->cfInpNeg = npNeg;
538  r->cfInvers= npInvers;
539  //r->cfCopy = ndCopy;
540  //r->cfRePart = ndCopy;
541  //r->cfImPart = ndReturn0;
542  r->cfWriteLong = npWrite;
543  r->cfRead = npRead;
544  //r->cfNormalize=ndNormalize;
545  r->cfGreater = npGreater;
546  r->cfEqual = npEqual;
547  r->cfIsZero = npIsZero;
548  r->cfIsOne = npIsOne;
549  r->cfIsMOne = npIsMOne;
550  r->cfGreaterZero = npGreaterZero;
551  //r->cfPower = npPower;
552  //r->cfGetDenom = ndGetDenom;
553  //r->cfGetNumerator = ndGetNumerator;
554  //r->cfGcd = ndGcd;
555  //r->cfLcm = ndGcd;
556  //r->cfDelete= ndDelete;
557  r->cfSetMap = npSetMap;
558  //r->cfName = ndName;
559  //r->cfInpMult=ndInpMult;
560 #ifdef NV_OPS
561  if (c>NV_MAX_PRIME)
562  {
563  r->cfMult = nvMult;
564  r->cfDiv = nvDiv;
565  r->cfExactDiv= nvDiv;
566  r->cfInvers= nvInvers;
567  //r->cfPower= nvPower;
568  }
569 #endif
570 #ifdef LDEBUG
571  // debug stuff
572  r->cfDBTest=npDBTest;
573 #endif
574 
575  r->convSingNFactoryN=npConvSingNFactoryN;
576  r->convFactoryNSingN=npConvFactoryNSingN;
577 
578  r->cfRandom=npRandom;
579 
580  // io via ssi
581  r->cfWriteFd=npWriteFd;
582  r->cfReadFd=npReadFd;
583 
584  // the variables:
585  r->nNULL = (number)0;
586  r->type = n_Zp;
587  r->ch = c;
588  r->has_simple_Alloc=TRUE;
589  r->has_simple_Inverse=TRUE;
590 
591  // the tables
592 #ifdef NV_OPS
593  if (r->ch <=NV_MAX_PRIME)
594 #endif
595  {
596 #if !defined(HAVE_DIV_MOD) || !defined(HAVE_MULT_MOD)
597  r->npExpTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
598  r->npLogTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
599  r->npExpTable[0] = 1;
600  r->npLogTable[0] = 0;
601  if (r->ch > 2)
602  {
603  w = 1;
604  loop
605  {
606  r->npLogTable[1] = 0;
607  w++;
608  i = 0;
609  loop
610  {
611  i++;
612  r->npExpTable[i] =(int)(((long)w * (long)r->npExpTable[i-1]) % r->ch);
613  r->npLogTable[r->npExpTable[i]] = i;
614  if /*(i == r->ch - 1 ) ||*/ (/*(*/ r->npExpTable[i] == 1 /*)*/)
615  break;
616  }
617  if (i == r->ch - 1)
618  break;
619  }
620  }
621  else
622  {
623  r->npExpTable[1] = 1;
624  r->npLogTable[1] = 0;
625  }
626 #endif
627 #ifdef HAVE_DIV_MOD
628  r->npInvTable=(unsigned short*)omAlloc0( r->ch*sizeof(unsigned short) );
629 #endif
630  }
631  return FALSE;
632 }
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:94
return P p
Definition: myNF.cc:203
number nvInvers(number c, const coeffs r)
Definition: modulop.cc:897
static void npWriteFd(number n, FILE *f, const coeffs)
Definition: modulop.cc:482
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:821
{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:98
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:635
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:882
BOOLEAN npIsMOne(number a, const coeffs r)
Definition: modulop.cc:186
void npCoeffWrite(const coeffs r, BOOLEAN details)
Definition: modulop.cc:927
#define assume(x)
Definition: mod2.h:394
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:774
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:477
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:487
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 774 of file modulop.cc.

775 {
776 #ifdef HAVE_RINGS
777  if ((src->rep==n_rep_int) && nCoeff_is_Ring_2toM(src))
778  {
779  return npMapMachineInt;
780  }
781  if (src->rep==n_rep_gmp) //nCoeff_is_Ring_Z(src) || nCoeff_is_Ring_PtoM(src) || nCoeff_is_Ring_ModN(src))
782  {
783  return npMapGMP;
784  }
785  if (src->rep==n_rep_gap_gmp) //nCoeff_is_Ring_Z(src)
786  {
787  return npMapZ;
788  }
789 #endif
790  if (src->rep==n_rep_gap_rat) /* Q, Z */
791  {
792  return nlModP; // npMap0; // FIXME? TODO? // extern number nlModP(number q, const coeffs Q, const coeffs Zp); // Map q \in QQ \to Zp // FIXME!
793  }
794  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src) )
795  {
796  if (n_GetChar(src) == n_GetChar(dst))
797  {
798  return ndCopyMap;
799  }
800  else
801  {
802  return npMapP;
803  }
804  }
805  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
806  {
807  return npMapLongR;
808  }
809  if (nCoeff_is_CF (src))
810  {
811  return npMapCanonicalForm;
812  }
813  return NULL; /* default */
814 }
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:747
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 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:646
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:760
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:658
(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:734
number npMapCanonicalForm(number a, const coeffs, const coeffs dst)
Definition: modulop.cc:767

§ 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