Functions | Variables
numbers.cc File Reference
#include <string.h>
#include <stdlib.h>
#include <misc/auxiliary.h>
#include <omalloc/omalloc.h>
#include <factory/factory.h>
#include <reporter/reporter.h>
#include <coeffs/coeffs.h>
#include <coeffs/numbers.h>
#include <coeffs/longrat.h>
#include <coeffs/modulop.h>
#include <coeffs/gnumpfl.h>
#include <coeffs/gnumpc.h>
#include <coeffs/ffields.h>
#include <coeffs/shortfl.h>
#include <coeffs/rmodulo2m.h>
#include <coeffs/rmodulon.h>
#include <coeffs/rintegers.h>
#include <polys/ext_fields/algext.h>
#include <polys/ext_fields/transext.h>

Go to the source code of this file.

Functions

void nNew (number *d)
 
static void ndDelete (number *d, const coeffs)
 
static number ndAnn (number, const coeffs)
 
static char * ndCoeffString (const coeffs r)
 
static char * ndCoeffName (const coeffs r)
 
static void ndInpMult (number &a, number b, const coeffs r)
 
static void ndInpAdd (number &a, number b, const coeffs r)
 
static void ndPower (number a, int i, number *res, const coeffs r)
 
static BOOLEAN ndIsUnit (number a, const coeffs r)
 
static BOOLEAN ndDBTest (number, const char *, const int, const coeffs)
 
static number ndFarey (number, number, const coeffs r)
 
static number ndChineseRemainder (number *, number *, int, BOOLEAN, CFArray &, const coeffs r)
 
static int ndParDeg (number n, const coeffs r)
 
static number ndParameter (const int, const coeffs r)
 
BOOLEAN n_IsZeroDivisor (number a, const coeffs r)
 Test whether a is a zero divisor in r i.e. not coprime with char. of r very inefficient implementation: should ONLY be used for debug stuff /tests. More...
 
static void ndNormalize (number &, const coeffs)
 
static number ndReturn0 (number, const coeffs r)
 
static number ndGcd (number, number, const coeffs r)
 
static number ndIntMod (number, number, const coeffs r)
 
static number ndGetDenom (number &, const coeffs r)
 
static number ndGetNumerator (number &a, const coeffs r)
 
static int ndSize (number a, const coeffs r)
 
static void ndClearContent (ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs r)
 
static void ndClearDenominators (ICoeffsEnumerator &, number &d, const coeffs r)
 
static number ndCopy (number a, const coeffs)
 
number ndCopyMap (number a, const coeffs aRing, const coeffs r)
 
static void ndKillChar (coeffs)
 
static void ndSetChar (const coeffs)
 
number nd_Copy (number a, const coeffs r)
 
static BOOLEAN ndDivBy (number, number, const coeffs)
 
static int ndDivComp (number, number, const coeffs)
 
static number ndExtGcd (number, number, number *, number *, const coeffs r)
 
static CanonicalForm ndConvSingNFactoryN (number, BOOLEAN, const coeffs)
 
static number ndConvFactoryNSingN (const CanonicalForm, const coeffs)
 [in, out] a bigint number >= 0 More...
 
static void ndMPZ (mpz_t result, number &n, const coeffs r)
 Converts a non-negative bigint number into a GMP number. More...
 
static number ndInitMPZ (mpz_t m, const coeffs r)
 
static BOOLEAN ndCoeffIsEqual (const coeffs r, n_coeffType n, void *)
 
coeffs nInitChar (n_coeffType t, void *parameter)
 one-time initialisations for new coeffs in case of an error return NULL More...
 
void nKillChar (coeffs r)
 undo all initialisations More...
 
n_coeffType nRegister (n_coeffType n, cfInitCharProc p)
 
coeffs nFindCoeffByName (const char *cf_name)
 find an existing coeff by its "CoeffName" More...
 
void n_Print (number &a, const coeffs r)
 print a number (BEWARE of string buffers!) mostly for debugging More...
 
number n_convFactoryNSingN (const CanonicalForm n, const coeffs r)
 
CanonicalForm n_convSingNFactoryN (number n, BOOLEAN setChar, const coeffs r)
 

Variables

n_Procs_scf_root =NULL
 
static n_coeffType nLastCoeffs =n_CF
 
cfInitCharProc nInitCharTableDefault []
 
static cfInitCharProcnInitCharTable =nInitCharTableDefault
 

Function Documentation

§ n_convFactoryNSingN()

number n_convFactoryNSingN ( const CanonicalForm  n,
const coeffs  r 
)

Definition at line 579 of file numbers.cc.

581 { STATISTIC(n_convFactoryNSingN); assume(r != NULL); assume(r->convFactoryNSingN != NULL); return r->convFactoryNSingN(n, r); }
#define STATISTIC(f)
Definition: numstats.h:16
number n_convFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: numbers.cc:579
#define assume(x)
Definition: mod2.h:403
#define NULL
Definition: omList.c:10

§ n_convSingNFactoryN()

CanonicalForm n_convSingNFactoryN ( number  n,
BOOLEAN  setChar,
const coeffs  r 
)

Definition at line 584 of file numbers.cc.

586 { STATISTIC(n_convSingNFactoryN); assume(r != NULL); assume(r->convSingNFactoryN != NULL); return r->convSingNFactoryN(n, setChar, r); }
#define STATISTIC(f)
Definition: numstats.h:16
#define assume(x)
Definition: mod2.h:403
#define NULL
Definition: omList.c:10
CanonicalForm n_convSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: numbers.cc:584

§ n_IsZeroDivisor()

BOOLEAN n_IsZeroDivisor ( number  a,
const coeffs  r 
)

Test whether a is a zero divisor in r i.e. not coprime with char. of r very inefficient implementation: should ONLY be used for debug stuff /tests.

Definition at line 137 of file numbers.cc.

138 {
139  int c = n_GetChar(r);
140  BOOLEAN ret = n_IsZero(a, r);
141  if( (c != 0) && !ret )
142  {
143  number ch = n_Init( c, r );
144  number g = n_Gcd( ch, a, r );
145  ret = !n_IsOne (g, r);
146  n_Delete(&ch, r);
147  n_Delete(&g, r);
148  }
149  return ret;
150 }
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of &#39;a&#39; and &#39;b&#39; in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:690
const poly a
Definition: syzextra.cc:212
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:448
g
Definition: cfModGcd.cc:4031
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
int BOOLEAN
Definition: auxiliary.h:86

§ n_Print()

void n_Print ( number &  a,
const coeffs  r 
)

print a number (BEWARE of string buffers!) mostly for debugging

Definition at line 568 of file numbers.cc.

570 {
571  assume(r != NULL);
572  n_Test(a,r);
573 
574  StringSetS("");
575  n_Write(a, r);
576  { char* s = StringEndS(); Print("%s", s); omFree(s); }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
#define Print
Definition: emacs.cc:83
char * StringEndS()
Definition: reporter.cc:151
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:403
void StringSetS(const char *st)
Definition: reporter.cc:128
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:595
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:742
#define NULL
Definition: omList.c:10

§ nd_Copy()

number nd_Copy ( number  a,
const coeffs  r 
)

Definition at line 257 of file numbers.cc.

257 { return r->cfCopy(a, r); }
const poly a
Definition: syzextra.cc:212

§ ndAnn()

static number ndAnn ( number  ,
const coeffs   
)
static

Definition at line 53 of file numbers.cc.

53 { return NULL;}
#define NULL
Definition: omList.c:10

§ ndChineseRemainder()

static number ndChineseRemainder ( number *  ,
number *  ,
int  ,
BOOLEAN  ,
CFArray ,
const coeffs  r 
)
static

Definition at line 120 of file numbers.cc.

121 {
122  Werror("ChineseRemainder not implemented for %s (c=%d)",r->cfCoeffString(r),getCoeffType(r));
123  return r->cfInit(0,r);
124 }
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ ndClearContent()

static void ndClearContent ( ICoeffsEnumerator numberCollectionEnumerator,
number &  c,
const coeffs  r 
)
static

TODO: move to a separate implementation

Definition at line 160 of file numbers.cc.

161 {
162  assume(r != NULL);
163 
164  // no fractions
165  assume(!( nCoeff_is_Q(r) ));
166  // all coeffs are given by integers!!!
167 
168  numberCollectionEnumerator.Reset();
169 
170  if( !numberCollectionEnumerator.MoveNext() ) // empty zero polynomial?
171  {
172  c = n_Init(1, r);
173  return;
174  }
175 
176  number &curr = numberCollectionEnumerator.Current();
177 
178 #ifdef HAVE_RINGS
179  /// TODO: move to a separate implementation
180  if (nCoeff_is_Ring(r))
181  {
182  if (nCoeff_has_Units(r))
183  {
184  c = n_GetUnit(curr, r);
185 
186  if (!n_IsOne(c, r))
187  {
188  number inv = n_Invers(c, r);
189 
190  n_InpMult(curr, inv, r);
191 
192  while( numberCollectionEnumerator.MoveNext() )
193  {
194  number &n = numberCollectionEnumerator.Current();
195  n_Normalize(n, r); // ?
196  n_InpMult(n, inv, r); // TODO: either this or directly divide!!!?
197  }
198 
199  n_Delete(&inv, r);
200  }
201  } else c = n_Init(1, r);
202 
203  return;
204  }
205 #endif
206 
207  assume(!nCoeff_is_Ring(r));
209 
210  n_Normalize(curr, r); // Q: good/bad/ugly??
211 
212  if (!n_IsOne(curr, r))
213  {
214  number t = curr; // takes over the curr! note: not a reference!!!
215 
216  curr = n_Init(1, r); // ???
217 
218  number inv = n_Invers(t, r);
219 
220  while( numberCollectionEnumerator.MoveNext() )
221  {
222  number &n = numberCollectionEnumerator.Current();
223  n_InpMult(n, inv, r); // TODO: either this or directly divide!!!?
224 // n_Normalize(n, r); // ?
225  }
226 
227  n_Delete(&inv, r);
228 
229  c = t;
230  } else
231  c = n_Copy(curr, r); // c == 1 and nothing else to do...
232 }
static FORCE_INLINE number n_GetUnit(number n, const coeffs r)
in Z: 1 in Z/kZ (where k is not a prime): largest divisor of n (taken in Z) that is co-prime with k i...
Definition: coeffs.h:536
static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r)
Definition: coeffs.h:846
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:834
static FORCE_INLINE BOOLEAN nCoeff_is_Zp_a(const coeffs r)
Definition: coeffs.h:873
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the product a*b
Definition: coeffs.h:645
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:582
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:840
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:762
virtual void Reset()=0
Sets the enumerator to its initial position: -1, which is before the first element in the collection...
#define assume(x)
Definition: mod2.h:403
static FORCE_INLINE BOOLEAN nCoeff_has_Units(const coeffs r)
returns TRUE, if r is not a field and r has non-trivial units
Definition: coeffs.h:831
virtual reference Current()=0
Gets the current element in the collection (read and write).
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of &#39;a&#39;; raise an error if &#39;a&#39; is not invertible ...
Definition: coeffs.h:568
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:853
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:455
virtual bool MoveNext()=0
Advances the enumerator to the next element of the collection. returns true if the enumerator was suc...
static FORCE_INLINE BOOLEAN nCoeff_is_Q_algext(const coeffs r)
is it an alg. ext. of Q?
Definition: coeffs.h:928
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

§ ndClearDenominators()

static void ndClearDenominators ( ICoeffsEnumerator ,
number &  d,
const coeffs  r 
)
static

Definition at line 234 of file numbers.cc.

235 {
236  assume( r != NULL );
239 
240  d = n_Init(1, r);
241 }
static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r)
Definition: coeffs.h:846
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:834
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:840
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:762
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:924
#define assume(x)
Definition: mod2.h:403
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:932
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:853
#define NULL
Definition: omList.c:10

§ ndCoeffIsEqual()

static BOOLEAN ndCoeffIsEqual ( const coeffs  r,
n_coeffType  n,
void *   
)
static

Definition at line 291 of file numbers.cc.

293 {
294  /* test, if r is an instance of nInitCoeffs(n,parameter) */
295  /* if parameter is not needed */
296  return (n==r->type);

§ ndCoeffName()

static char* ndCoeffName ( const coeffs  r)
static

Definition at line 59 of file numbers.cc.

60 {
61  static char s[20];
62  snprintf(s,11,"Coeffs(%d)",r->type);
63  return s;
64 }
const CanonicalForm int s
Definition: facAbsFact.cc:55

§ ndCoeffString()

static char* ndCoeffString ( const coeffs  r)
static

Definition at line 54 of file numbers.cc.

55 {
56  char *s=(char *)omAlloc(11);snprintf(s,11,"Coeffs(%d)",r->type);
57  return s;
58 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omAlloc(size)
Definition: omAllocDecl.h:210

§ ndConvFactoryNSingN()

static number ndConvFactoryNSingN ( const CanonicalForm  ,
const coeffs   
)
static

[in, out] a bigint number >= 0

[out] the GMP equivalent

Definition at line 272 of file numbers.cc.

§ ndConvSingNFactoryN()

static CanonicalForm ndConvSingNFactoryN ( number  ,
BOOLEAN  ,
const coeffs   
)
static

Definition at line 265 of file numbers.cc.

266 {
267  CanonicalForm term(0);
268  WerrorS("no conversion to factory");
269  return term;
270 }
Definition: int_poly.h:33
factory&#39;s main class
Definition: canonicalform.h:75
void WerrorS(const char *s)
Definition: feFopen.cc:24

§ ndCopy()

static number ndCopy ( number  a,
const coeffs   
)
static

Definition at line 243 of file numbers.cc.

243 { return a; }
const poly a
Definition: syzextra.cc:212

§ ndCopyMap()

number ndCopyMap ( number  a,
const coeffs  aRing,
const coeffs  r 
)

Definition at line 244 of file numbers.cc.

245 {
246  // aRing and r need not be the same, but must be the same representation
247  assume(aRing->rep==r->rep);
249  return a;
250  else
251  return r->cfCopy(a, r);
252 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:403
static FORCE_INLINE BOOLEAN nCoeff_has_simple_Alloc(const coeffs r)
TRUE if n_Delete/n_New are empty operations.
Definition: coeffs.h:920

§ ndDBTest()

static BOOLEAN ndDBTest ( number  ,
const char *  ,
const int  ,
const coeffs   
)
static

Definition at line 112 of file numbers.cc.

112 { return TRUE; }
#define TRUE
Definition: auxiliary.h:99

§ ndDelete()

static void ndDelete ( number *  d,
const coeffs   
)
static

Definition at line 52 of file numbers.cc.

52 { *d=NULL; }
#define NULL
Definition: omList.c:10

§ ndDivBy()

static BOOLEAN ndDivBy ( number  ,
number  ,
const coeffs   
)
static

Definition at line 260 of file numbers.cc.

260 { return TRUE; } // assume a,b !=0
#define TRUE
Definition: auxiliary.h:99

§ ndDivComp()

static int ndDivComp ( number  ,
number  ,
const coeffs   
)
static

Definition at line 261 of file numbers.cc.

261 { return 2; }

§ ndExtGcd()

static number ndExtGcd ( number  ,
number  ,
number *  ,
number *  ,
const coeffs  r 
)
static

Definition at line 262 of file numbers.cc.

262 { return r->cfInit(1,r); }

§ ndFarey()

static number ndFarey ( number  ,
number  ,
const coeffs  r 
)
static

Definition at line 115 of file numbers.cc.

116 {
117  Werror("farey not implemented for %s (c=%d)",r->cfCoeffString(r),getCoeffType(r));
118  return NULL;
119 }
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define NULL
Definition: omList.c:10
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ ndGcd()

static number ndGcd ( number  ,
number  ,
const coeffs  r 
)
static

Definition at line 154 of file numbers.cc.

154 { return r->cfInit(1,r); }

§ ndGetDenom()

static number ndGetDenom ( number &  ,
const coeffs  r 
)
static

Definition at line 156 of file numbers.cc.

156 { return r->cfInit(1,r); }

§ ndGetNumerator()

static number ndGetNumerator ( number &  a,
const coeffs  r 
)
static

Definition at line 157 of file numbers.cc.

157 { return r->cfCopy(a,r); }
const poly a
Definition: syzextra.cc:212

§ ndInitMPZ()

static number ndInitMPZ ( mpz_t  m,
const coeffs  r 
)
static

Definition at line 285 of file numbers.cc.

287 {
288  return r->cfInit( mpz_get_si(m), r);
int m
Definition: cfEzgcd.cc:119

§ ndInpAdd()

static void ndInpAdd ( number &  a,
number  b,
const coeffs  r 
)
static

Definition at line 71 of file numbers.cc.

72 {
73  number n=r->cfAdd(a,b,r);
74  r->cfDelete(&a,r);
75  a=n;
76 }
const poly a
Definition: syzextra.cc:212
const poly b
Definition: syzextra.cc:213

§ ndInpMult()

static void ndInpMult ( number &  a,
number  b,
const coeffs  r 
)
static

Definition at line 65 of file numbers.cc.

66 {
67  number n=r->cfMult(a,b,r);
68  r->cfDelete(&a,r);
69  a=n;
70 }
const poly a
Definition: syzextra.cc:212
const poly b
Definition: syzextra.cc:213

§ ndIntMod()

static number ndIntMod ( number  ,
number  ,
const coeffs  r 
)
static

Definition at line 155 of file numbers.cc.

155 { return r->cfInit(0,r); }

§ ndIsUnit()

static BOOLEAN ndIsUnit ( number  a,
const coeffs  r 
)
static

Definition at line 109 of file numbers.cc.

109 { return !r->cfIsZero(a,r); }
const poly a
Definition: syzextra.cc:212

§ ndKillChar()

static void ndKillChar ( coeffs  )
static

Definition at line 254 of file numbers.cc.

254 {}

§ ndMPZ()

static void ndMPZ ( mpz_t  result,
number &  n,
const coeffs  r 
)
static

Converts a non-negative bigint number into a GMP number.

Definition at line 280 of file numbers.cc.

282 {
283  mpz_init_set_si( result, r->cfInt(n, r) );
return result
Definition: facAbsBiFact.cc:76

§ ndNormalize()

static void ndNormalize ( number &  ,
const coeffs   
)
static

Definition at line 152 of file numbers.cc.

152 { }

§ ndParameter()

static number ndParameter ( const int  ,
const coeffs  r 
)
static

Definition at line 131 of file numbers.cc.

132 {
133  Werror("ndParameter: n_Parameter is not implemented/relevant for (coeff_type = %d)",getCoeffType(r));
134  return NULL;
135 }
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define NULL
Definition: omList.c:10
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ ndParDeg()

static int ndParDeg ( number  n,
const coeffs  r 
)
static

Definition at line 126 of file numbers.cc.

127 {
128  return (-r->cfIsZero(n,r));
129 }

§ ndPower()

static void ndPower ( number  a,
int  i,
number *  res,
const coeffs  r 
)
static

Definition at line 78 of file numbers.cc.

79 {
80  if (i==0)
81  {
82  *res = r->cfInit(1, r);
83  }
84  else if (i==1)
85  {
86  *res = r->cfCopy(a, r);
87  }
88  else if (i==2)
89  {
90  *res = r->cfMult(a, a, r);
91  }
92  else if (i<0)
93  {
94  number b = r->cfInvers(a, r);
95  ndPower(b, -i, res, r);
96  r->cfDelete(&b, r);
97  }
98  else
99  {
100  ndPower(a, i/2, res, r);
101  r->cfInpMult(*res, *res, r);
102  if (i&1)
103  {
104  r->cfInpMult(*res, a, r);
105  }
106  }
107 }
const poly a
Definition: syzextra.cc:212
static void ndPower(number a, int i, number *res, const coeffs r)
Definition: numbers.cc:78
poly res
Definition: myNF.cc:322
int i
Definition: cfEzgcd.cc:123
const poly b
Definition: syzextra.cc:213

§ ndReturn0()

static number ndReturn0 ( number  ,
const coeffs  r 
)
static

Definition at line 153 of file numbers.cc.

153 { return r->cfInit(0,r); }

§ ndSetChar()

static void ndSetChar ( const coeffs  )
static

Definition at line 255 of file numbers.cc.

255 {}

§ ndSize()

static int ndSize ( number  a,
const coeffs  r 
)
static

Definition at line 158 of file numbers.cc.

158 { return (int)r->cfIsZero(a,r)==FALSE; }
const poly a
Definition: syzextra.cc:212
#define FALSE
Definition: auxiliary.h:95

§ nFindCoeffByName()

coeffs nFindCoeffByName ( const char *  cf_name)

find an existing coeff by its "CoeffName"

Definition at line 555 of file numbers.cc.

557 {
558  n_Procs_s* n=cf_root;
559  while(n!=NULL)
560  {
561  if ((n->cfCoeffName!=NULL)
562  && (strcmp(cf_name,n->cfCoeffName(n))==0)) return n;
563  n=n->next;
564  }
565  // TODO: parametrized cf, e.g. flint:Z/26[a]
566  return NULL;
coeffs next
Definition: coeffs.h:125
n_Procs_s * cf_root
Definition: numbers.cc:47
#define NULL
Definition: omList.c:10
char *(* cfCoeffName)(const coeffs r)
default name of cf, should substitue cfCoeffWrite, cfCoeffString
Definition: coeffs.h:154

§ nInitChar()

coeffs nInitChar ( n_coeffType  t,
void *  parameter 
)

one-time initialisations for new coeffs in case of an error return NULL

Definition at line 334 of file numbers.cc.

336 {
337  n_Procs_s *n=cf_root;
338 
339  while((n!=NULL) && (n->nCoeffIsEqual!=NULL) && (!n->nCoeffIsEqual(n,t,parameter)))
340  n=n->next;
341 
342  if (n==NULL)
343  {
344  n=(n_Procs_s*)omAlloc0(sizeof(n_Procs_s));
345  n->next=cf_root;
346  n->ref=1;
347  n->type=t;
348 
349  // default entries (different from NULL) for some routines:
351  n->cfSize = ndSize;
354  n->cfImPart=ndReturn0;
355  n->cfDelete= ndDelete;
356  n->cfAnn = ndAnn;
357  n->cfCoeffString = ndCoeffString; // should alway be changed!
358  n->cfCoeffName = ndCoeffName; // should alway be changed!
359  n->cfInpMult=ndInpMult;
360  n->cfInpAdd=ndInpAdd;
361  n->cfCopy = ndCopy;
362  n->cfIntMod=ndIntMod; /* dummy !! */
364  n->cfGcd = ndGcd;
365  n->cfNormalizeHelper = ndGcd; /* tricky, isn't it ?*/
366  n->cfLcm = ndGcd; /* tricky, isn't it ?*/
367  n->cfInitMPZ = ndInitMPZ;
368  n->cfMPZ = ndMPZ;
369  n->cfPower = ndPower;
370 
371  n->cfKillChar = ndKillChar; /* dummy */
372  n->cfSetChar = ndSetChar; /* dummy */
373  // temp. removed to catch all the coeffs which miss to implement this!
374 
376  n->cfFarey = ndFarey;
377  n->cfParDeg = ndParDeg;
378 
380 
383 
384  n->cfIsUnit = ndIsUnit;
385 #ifdef HAVE_RINGS
386  n->cfDivComp = ndDivComp;
387  n->cfDivBy = ndDivBy;
388  n->cfExtGcd = ndExtGcd;
389  //n->cfGetUnit = (nMapFunc)NULL;
390 #endif
391 
392 #ifdef LDEBUG
393  n->cfDBTest=ndDBTest;
394 #endif
395 
398 
399  BOOLEAN nOK=TRUE;
400  // init
401  if ((t<=nLastCoeffs) && (nInitCharTable[t]!=NULL))
402  nOK = (nInitCharTable[t])(n,parameter);
403  else
404  Werror("Sorry: the coeff type [%d] was not registered: it is missing in nInitCharTable", (int)t);
405  if (nOK)
406  {
407  omFreeSize(n,sizeof(*n));
408  return NULL;
409  }
410  cf_root=n;
411  // post init settings:
412  if (n->cfRePart==NULL) n->cfRePart=n->cfCopy;
413  if (n->cfExactDiv==NULL) n->cfExactDiv=n->cfDiv;
414  if (n->cfSubringGcd==NULL) n->cfSubringGcd=n->cfGcd;
415 
416 #ifdef HAVE_RINGS
417  if (n->cfGetUnit==NULL) n->cfGetUnit=n->cfCopy;
418 #endif
419 
420  if(n->cfWriteShort==NULL)
421  n->cfWriteShort = n->cfWriteLong;
422 
424  assume(n->cfSetChar!=NULL);
427  assume(n->cfMult!=NULL);
428  assume(n->cfSub!=NULL);
429  assume(n->cfAdd!=NULL);
430  assume(n->cfDiv!=NULL);
431  assume(n->cfIntMod!=NULL);
432  assume(n->cfExactDiv!=NULL);
433  assume(n->cfInit!=NULL);
434  assume(n->cfInitMPZ!=NULL);
435  assume(n->cfSize!=NULL);
436  assume(n->cfInt!=NULL);
437  assume(n->cfMPZ!=NULL);
438  //assume(n->n->cfDivComp!=NULL);
439  //assume(n->cfIsUnit!=NULL);
440  //assume(n->cfGetUnit!=NULL);
441  //assume(n->cfExtGcd!=NULL);
442  assume(n->cfInpNeg!=NULL);
443  assume(n->cfCopy!=NULL);
444 
445  assume(n->cfWriteLong!=NULL);
446  assume(n->cfWriteShort!=NULL);
447 
448  assume(n->iNumberOfParameters>= 0);
449 
450  assume( (n->iNumberOfParameters == 0 && n->pParameterNames == NULL) ||
451  (n->iNumberOfParameters > 0 && n->pParameterNames != NULL) );
452 
453  assume(n->cfParameter!=NULL);
454  assume(n->cfParDeg!=NULL);
455 
456  assume(n->cfRead!=NULL);
457  assume(n->cfNormalize!=NULL);
458  assume(n->cfGreater!=NULL);
459  //assume(n->cfDivBy!=NULL);
460  assume(n->cfEqual!=NULL);
461  assume(n->cfIsZero!=NULL);
462  assume(n->cfIsOne!=NULL);
463  assume(n->cfIsMOne!=NULL);
465  assume(n->cfGetDenom!=NULL);
467  assume(n->cfGcd!=NULL);
469  assume(n->cfDelete!=NULL);
470  assume(n->cfSetMap!=NULL);
471  assume(n->cfInpMult!=NULL);
472 // assume(n->cfInit_bigint!=NULL);
473  assume(n->cfCoeffWrite != NULL);
474 
475  assume(n->cfClearContent != NULL);
477 
478  assume(n->type==t);
479 
480 #ifndef SING_NDEBUG
481  if(n->cfKillChar==NULL) Warn("cfKillChar is NULL for coeff %d",t);
482  if(n->cfWriteLong==NULL) Warn("cfWrite is NULL for coeff %d",t);
483  if(n->cfWriteShort==NULL) Warn("cfWriteShort is NULL for coeff %d",t);
484  if(n->cfCoeffString==ndCoeffString) Warn("cfCoeffString is undefined for coeff %d",t);
485 #endif
486 
487  if( n->nNULL == NULL )
488  n->nNULL = n->cfInit(0, n); // may still remain NULL
489  }
490  else
491  {
492  n->ref++;
493  }
494  return n;
static BOOLEAN ndIsUnit(number a, const coeffs r)
Definition: numbers.cc:109
BOOLEAN(* cfDivBy)(number a, number b, const coeffs r)
Definition: coeffs.h:385
number(* cfCopy)(number a, const coeffs r)
return a copy of a
Definition: coeffs.h:199
number(* cfExtGcd)(number a, number b, number *s, number *t, const coeffs r)
Definition: coeffs.h:248
numberfunc cfIntMod
Definition: coeffs.h:175
int(* cfDivComp)(number a, number b, const coeffs r)
Definition: coeffs.h:381
static void ndPower(number a, int i, number *res, const coeffs r)
Definition: numbers.cc:78
static number ndParameter(const int, const coeffs r)
Definition: numbers.cc:131
number nNULL
the 0 as constant, NULL by default
Definition: coeffs.h:320
static void ndKillChar(coeffs)
Definition: numbers.cc:254
static BOOLEAN ndDBTest(number, const char *, const int, const coeffs)
Definition: numbers.cc:112
BOOLEAN(* cfDBTest)(number a, const char *f, const int l, const coeffs r)
Test: is "a" a correct number?
Definition: coeffs.h:419
void(* cfMPZ)(mpz_t result, number &n, const coeffs r)
Converts a non-negative number n into a GMP number, 0 if impossible.
Definition: coeffs.h:190
void(* cfSetChar)(const coeffs r)
Definition: coeffs.h:161
static BOOLEAN ndDivBy(number, number, const coeffs)
Definition: numbers.cc:260
char const ** pParameterNames
array containing the names of Parameters (default NULL)
Definition: coeffs.h:326
coeffs next
Definition: coeffs.h:125
static number ndCopy(number a, const coeffs)
Definition: numbers.cc:243
static n_coeffType nLastCoeffs
Definition: numbers.cc:298
static number ndChineseRemainder(number *, number *, int, BOOLEAN, CFArray &, const coeffs r)
Definition: numbers.cc:120
void(* cfDelete)(number *a, const coeffs r)
Definition: coeffs.h:272
static void ndNormalize(number &, const coeffs)
Definition: numbers.cc:152
BOOLEAN(*)(*)(*)(*) cfIsOne(number a, const coeffs r)
Definition: coeffs.h:229
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
number(* cfSubringGcd)(number a, number b, const coeffs r)
Definition: coeffs.h:247
static number ndConvFactoryNSingN(const CanonicalForm, const coeffs)
[in, out] a bigint number >= 0
Definition: numbers.cc:272
numberfunc cfAdd
Definition: coeffs.h:175
BOOLEAN(* cfGreater)(number a, number b, const coeffs r)
Definition: coeffs.h:225
void(* cfNormalize)(number &a, const coeffs r)
Definition: coeffs.h:223
static char * ndCoeffString(const coeffs r)
Definition: numbers.cc:54
number(* cfRePart)(number a, const coeffs r)
Definition: coeffs.h:200
#define TRUE
Definition: auxiliary.h:99
static void ndDelete(number *d, const coeffs)
Definition: numbers.cc:52
static int ndDivComp(number, number, const coeffs)
Definition: numbers.cc:261
void(* cfCoeffWrite)(const coeffs r, BOOLEAN details)
output of coeff description via Print
Definition: coeffs.h:148
static char * ndCoeffName(const coeffs r)
Definition: numbers.cc:59
BOOLEAN(* cfIsUnit)(number a, const coeffs r)
Definition: coeffs.h:382
number(* cfGetUnit)(number a, const coeffs r)
Definition: coeffs.h:383
number(* cfFarey)(number p, number n, const coeffs)
rational reconstruction: "best" rational a/b with a/b = p mod n
Definition: coeffs.h:291
number(* cfInitMPZ)(mpz_t i, const coeffs r)
init with a GMP integer
Definition: coeffs.h:181
char *(* cfCoeffString)(const coeffs r)
string output of coeff description
Definition: coeffs.h:151
BOOLEAN(* nCoeffIsEqual)(const coeffs r, n_coeffType n, void *parameter)
Definition: coeffs.h:145
static number ndReturn0(number, const coeffs r)
Definition: numbers.cc:153
static void ndInpMult(number &a, number b, const coeffs r)
Definition: numbers.cc:65
number(* cfInit)(long i, const coeffs r)
init with an integer
Definition: coeffs.h:178
number(* cfNormalizeHelper)(number a, number b, const coeffs r)
Definition: coeffs.h:271
static number ndInitMPZ(mpz_t m, const coeffs r)
Definition: numbers.cc:285
static int ndParDeg(number n, const coeffs r)
Definition: numbers.cc:126
BOOLEAN(*)(*)(*)(*)(*)(*) cfGreaterZero(number a, const coeffs r)
Definition: coeffs.h:237
long(* cfInt)(number &n, const coeffs r)
convertion to long, 0 if impossible
Definition: coeffs.h:187
void(* cfInpMult)(number &a, number b, const coeffs r)
Inplace: a *= b.
Definition: coeffs.h:281
numberfunc cfSub
Definition: coeffs.h:175
static void ndClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs r)
Definition: numbers.cc:160
static number ndGetDenom(number &, const coeffs r)
Definition: numbers.cc:156
number(* cfImPart)(number a, const coeffs r)
Definition: coeffs.h:201
#define assume(x)
Definition: mod2.h:403
number(* cfInpNeg)(number a, const coeffs r)
changes argument inline: a:= -a return -a! (no copy is returned) the result should be assigned to the...
Definition: coeffs.h:195
static int ndSize(number a, const coeffs r)
Definition: numbers.cc:158
int ref
Definition: coeffs.h:126
void(* cfPower)(number a, int i, number *result, const coeffs r)
Definition: coeffs.h:239
nCoeffsEnumeratorFunc cfClearContent
function pointer behind n_ClearContent
Definition: coeffs.h:309
n_Procs_s * cf_root
Definition: numbers.cc:47
numberfunc cfExactDiv
Definition: coeffs.h:175
static BOOLEAN ndCoeffIsEqual(const coeffs r, n_coeffType n, void *)
Definition: numbers.cc:291
n_coeffType type
Definition: coeffs.h:128
static CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition: numbers.cc:265
numberfunc cfDiv
Definition: coeffs.h:175
const char *(* cfRead)(const char *s, number *a, const coeffs r)
Definition: coeffs.h:221
numberfunc cfMult
Definition: coeffs.h:175
static number ndGcd(number, number, const coeffs r)
Definition: numbers.cc:154
static number ndExtGcd(number, number, number *, number *, const coeffs r)
Definition: numbers.cc:262
static cfInitCharProc * nInitCharTable
Definition: numbers.cc:330
#define NULL
Definition: omList.c:10
void(* cfWriteLong)(number a, const coeffs r)
print a given number (long format)
Definition: coeffs.h:204
number(* cfGcd)(number a, number b, const coeffs r)
Definition: coeffs.h:246
static void ndSetChar(const coeffs)
Definition: numbers.cc:255
number(* cfLcm)(number a, number b, const coeffs r)
Definition: coeffs.h:270
static void ndInpAdd(number &a, number b, const coeffs r)
Definition: numbers.cc:71
number(* convFactoryNSingN)(const CanonicalForm n, const coeffs r)
conversion to CanonicalForm(factory) to number
Definition: coeffs.h:315
number(* cfChineseRemainder)(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs)
chinese remainder returns X with X mod q[i]=x[i], i=0..rl-1
Definition: coeffs.h:297
static number ndGetNumerator(number &a, const coeffs r)
Definition: numbers.cc:157
static number ndAnn(number, const coeffs)
Definition: numbers.cc:53
static number ndIntMod(number, number, const coeffs r)
Definition: numbers.cc:155
static number ndFarey(number, number, const coeffs r)
Definition: numbers.cc:115
static void ndClearDenominators(ICoeffsEnumerator &, number &d, const coeffs r)
Definition: numbers.cc:234
nMapFunc(* cfSetMap)(const coeffs src, const coeffs dst)
Definition: coeffs.h:275
char *(* cfCoeffName)(const coeffs r)
default name of cf, should substitue cfCoeffWrite, cfCoeffString
Definition: coeffs.h:154
int(* cfSize)(number n, const coeffs r)
how complicated, (0) => 0, or positive
Definition: coeffs.h:184
number(* cfAnn)(number a, const coeffs r)
Definition: coeffs.h:261
number(* cfParameter)(const int i, const coeffs r)
create i^th parameter or NULL if not possible
Definition: coeffs.h:303
BOOLEAN(*)(*)(*)(*)(*) cfIsMOne(number a, const coeffs r)
Definition: coeffs.h:232
CanonicalForm(* convSingNFactoryN)(number n, BOOLEAN setChar, const coeffs r)
Definition: coeffs.h:316
void(* cfKillChar)(coeffs r)
Definition: coeffs.h:159
int BOOLEAN
Definition: auxiliary.h:86
static void ndMPZ(mpz_t result, number &n, const coeffs r)
Converts a non-negative bigint number into a GMP number.
Definition: numbers.cc:280
void Werror(const char *fmt,...)
Definition: reporter.cc:189
void(* cfInpAdd)(number &a, number b, const coeffs r)
Inplace: a += b.
Definition: coeffs.h:284
number(* cfGetNumerator)(number &n, const coeffs r)
Definition: coeffs.h:241
void(* cfWriteShort)(number a, const coeffs r)
print a given number in a shorter way, if possible e.g. in K(a): a2 instead of a^2 ...
Definition: coeffs.h:208
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int iNumberOfParameters
Number of Parameters in the coeffs (default 0)
Definition: coeffs.h:323
number(* cfGetDenom)(number &n, const coeffs r)
Definition: coeffs.h:240
BOOLEAN(*)(*)(*) cfIsZero(number a, const coeffs r)
Definition: coeffs.h:228
BOOLEAN(*)(*) cfEqual(number a, number b, const coeffs r)
tests
Definition: coeffs.h:227
nCoeffsEnumeratorFunc cfClearDenominators
function pointer behind n_ClearDenominators
Definition: coeffs.h:312
#define Warn
Definition: emacs.cc:80
int(* cfParDeg)(number x, const coeffs r)
degree for coeffcients: -1 for 0, 0 for "constants", ...
Definition: coeffs.h:300

§ nKillChar()

void nKillChar ( coeffs  r)

undo all initialisations

Definition at line 496 of file numbers.cc.

498 {
500  if (r!=NULL)
501  {
502  r->ref--;
503  if (r->ref<=0)
504  {
505  n_Procs_s tmp;
506  n_Procs_s* n=&tmp;
507  tmp.next=cf_root;
508  while((n->next!=NULL) && (n->next!=r)) n=n->next;
509  if (n->next==r)
510  {
511  n->next=n->next->next;
512  if (cf_root==r) cf_root=n->next;
513  n_Delete(&(r->nNULL),r);
514  assume (r->cfKillChar!=NULL); r->cfKillChar(r); // STATISTIC(nKillChar);
515  omFreeSize((void *)r, sizeof(n_Procs_s));
516  r=NULL;
517  }
518  else
519  {
520  WarnS("cf_root list destroyed");
521  }
522  }
523  }
#define STATISTIC(f)
Definition: numstats.h:16
coeffs next
Definition: coeffs.h:125
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define WarnS
Definition: emacs.cc:81
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:496
#define assume(x)
Definition: mod2.h:403
n_Procs_s * cf_root
Definition: numbers.cc:47
#define NULL
Definition: omList.c:10
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

§ nNew()

void nNew ( number *  d)

Definition at line 49 of file numbers.cc.

49 { *d=NULL; }
#define NULL
Definition: omList.c:10

§ nRegister()

n_coeffType nRegister ( n_coeffType  n,
cfInitCharProc  p 
)

Definition at line 525 of file numbers.cc.

527 {
528  if (n==n_unknown)
529  {
532  {
534  ((int)nLastCoeffs+1)*sizeof(cfInitCharProc));
536  ((int)nLastCoeffs)*sizeof(cfInitCharProc));
537  }
538  else
539  {
541  ((int)nLastCoeffs)*sizeof(cfInitCharProc),
542  (((int)nLastCoeffs)+1)*sizeof(cfInitCharProc));
543  }
544 
546  return nLastCoeffs;
547  }
548  else
549  {
550  if (nInitCharTable[n]!=NULL) Print("coeff %d already initialized\n",n);
551  nInitCharTable[n]=p;
552  return n;
553  }
#define Print
Definition: emacs.cc:83
return P p
Definition: myNF.cc:203
static n_coeffType nLastCoeffs
Definition: numbers.cc:298
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
BOOLEAN(* cfInitCharProc)(coeffs, void *)
initialize an object of type coeff, return FALSE in case of success
Definition: numbers.h:89
cfInitCharProc nInitCharTableDefault[]
Definition: numbers.cc:299
n_coeffType
Definition: coeffs.h:27
static cfInitCharProc * nInitCharTable
Definition: numbers.cc:330
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211

Variable Documentation

§ cf_root

n_Procs_s* cf_root =NULL

Definition at line 47 of file numbers.cc.

§ nInitCharTable

cfInitCharProc* nInitCharTable =nInitCharTableDefault
static

Definition at line 330 of file numbers.cc.

§ nInitCharTableDefault

cfInitCharProc nInitCharTableDefault[]
Initial value:
=
{ NULL,
}
BOOLEAN nrInitChar(coeffs n, void *p)
Initialize r.
Definition: shortfl.cc:730
BOOLEAN naInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition: algext.cc:1406
BOOLEAN nr2mInitChar(coeffs r, void *p)
Definition: rmodulo2m.cc:162
BOOLEAN npInitChar(coeffs r, void *p)
Definition: modulop.cc:504
BOOLEAN nlInitChar(coeffs r, void *p)
Definition: longrat.cc:3310
BOOLEAN n2pInitChar(coeffs cf, void *infoStruct)
Definition: algext.cc:1696
BOOLEAN ngcInitChar(coeffs n, void *parameter)
Initialize r (n_long_C)
Definition: gnumpc.cc:460
BOOLEAN nrnInitChar(coeffs r, void *p)
Definition: rmodulon.cc:167
BOOLEAN nrzInitChar(coeffs r, void *)
Definition: rintegers.cc:497
BOOLEAN nfInitChar(coeffs r, void *parameter)
Definition: ffields.cc:834
#define NULL
Definition: omList.c:10
BOOLEAN ngfInitChar(coeffs n, void *parameter)
Initialize r.
Definition: gnumpfl.cc:451
BOOLEAN ntInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition: transext.cc:2536

Definition at line 299 of file numbers.cc.

§ nLastCoeffs

n_coeffType nLastCoeffs =n_CF
static

Definition at line 298 of file numbers.cc.