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 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 char * ndCoeffName (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)
 
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

number n_convFactoryNSingN ( const CanonicalForm  n,
const coeffs  r 
)

Definition at line 560 of file numbers.cc.

562 { 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:560
#define assume(x)
Definition: mod2.h:405
#define NULL
Definition: omList.c:10
CanonicalForm n_convSingNFactoryN ( number  n,
BOOLEAN  setChar,
const coeffs  r 
)

Definition at line 565 of file numbers.cc.

567 { STATISTIC(n_convSingNFactoryN); assume(r != NULL); assume(r->convSingNFactoryN != NULL); return r->convSingNFactoryN(n, setChar, r); }
#define STATISTIC(f)
Definition: numstats.h:16
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#define assume(x)
Definition: mod2.h:405
#define NULL
Definition: omList.c:10
CanonicalForm n_convSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: numbers.cc:565
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 131 of file numbers.cc.

132 {
133  int c = n_GetChar(r);
134  BOOLEAN ret = n_IsZero(a, r);
135  if( (c != 0) && !ret )
136  {
137  number ch = n_Init( c, r );
138  number g = n_Gcd( ch, a, r );
139  ret = !n_IsOne (g, r);
140  n_Delete(&ch, r);
141  n_Delete(&g, r);
142  }
143  return ret;
144 }
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:685
const poly a
Definition: syzextra.cc:212
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:469
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:539
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:445
g
Definition: cfModGcd.cc:4031
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:465
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
int BOOLEAN
Definition: auxiliary.h:131
void n_Print ( number &  a,
const coeffs  r 
)

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

Definition at line 549 of file numbers.cc.

551 {
552  assume(r != NULL);
553  n_Test(a,r);
554 
555  StringSetS("");
556  n_Write(a, r);
557  { 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:405
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:592
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:923
#define NULL
Definition: omList.c:10
number nd_Copy ( number  a,
const coeffs  r 
)

Definition at line 252 of file numbers.cc.

252 { return r->cfCopy(a, r); }
const poly a
Definition: syzextra.cc:212
static number ndAnn ( number  ,
const coeffs   
)
static

Definition at line 53 of file numbers.cc.

53 { return NULL;}
#define NULL
Definition: omList.c:10
static number ndChineseRemainder ( number *  ,
number *  ,
int  ,
BOOLEAN  ,
CFArray ,
const coeffs  r 
)
static

Definition at line 114 of file numbers.cc.

115 {
116  Werror("ChineseRemainder not implemented for %s (c=%d)",r->cfCoeffString(r),getCoeffType(r));
117  return r->cfInit(0,r);
118 }
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
void Werror(const char *fmt,...)
Definition: reporter.cc:199
static void ndClearContent ( ICoeffsEnumerator numberCollectionEnumerator,
number &  c,
const coeffs  r 
)
static

TODO: move to a separate implementation

Definition at line 155 of file numbers.cc.

156 {
157  assume(r != NULL);
158 
159  // no fractions
160  assume(!( nCoeff_is_Q(r) ));
161  // all coeffs are given by integers!!!
162 
163  numberCollectionEnumerator.Reset();
164 
165  if( !numberCollectionEnumerator.MoveNext() ) // empty zero polynomial?
166  {
167  c = n_Init(1, r);
168  return;
169  }
170 
171  number &curr = numberCollectionEnumerator.Current();
172 
173 #ifdef HAVE_RINGS
174  /// TODO: move to a separate implementation
175  if (nCoeff_is_Ring(r))
176  {
177  if (nCoeff_has_Units(r))
178  {
179  c = n_GetUnit(curr, r);
180 
181  if (!n_IsOne(c, r))
182  {
183  number inv = n_Invers(c, r);
184 
185  n_InpMult(curr, inv, r);
186 
187  while( numberCollectionEnumerator.MoveNext() )
188  {
189  number &n = numberCollectionEnumerator.Current();
190  n_Normalize(n, r); // ?
191  n_InpMult(n, inv, r); // TODO: either this or directly divide!!!?
192  }
193 
194  n_Delete(&inv, r);
195  }
196  } else c = n_Init(1, r);
197 
198  return;
199  }
200 #endif
201 
202  assume(!nCoeff_is_Ring(r));
204 
205  n_Normalize(curr, r); // Q: good/bad/ugly??
206 
207  if (!n_IsOne(curr, r))
208  {
209  number t = curr; // takes over the curr! note: not a reference!!!
210 
211  curr = n_Init(1, r); // ???
212 
213  number inv = n_Invers(t, r);
214 
215  while( numberCollectionEnumerator.MoveNext() )
216  {
217  number &n = numberCollectionEnumerator.Current();
218  n_InpMult(n, inv, r); // TODO: either this or directly divide!!!?
219 // n_Normalize(n, r); // ?
220  }
221 
222  n_Delete(&inv, r);
223 
224  c = t;
225  } else
226  c = n_Copy(curr, r); // c == 1 and nothing else to do...
227 }
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:533
static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r)
Definition: coeffs.h:830
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:818
static FORCE_INLINE BOOLEAN nCoeff_is_Zp_a(const coeffs r)
Definition: coeffs.h:857
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of 'a' and 'b'; replacement of 'a' by the product a*b
Definition: coeffs.h:640
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:469
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:539
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:579
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:824
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:753
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:405
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:815
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 'a'; raise an error if 'a' is not invertible ...
Definition: coeffs.h:565
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:837
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:452
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:915
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
static void ndClearDenominators ( ICoeffsEnumerator ,
number &  d,
const coeffs  r 
)
static

Definition at line 229 of file numbers.cc.

230 {
231  assume( r != NULL );
234 
235  d = n_Init(1, r);
236 }
static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r)
Definition: coeffs.h:830
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:818
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:539
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:824
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:753
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:911
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:919
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:837
#define NULL
Definition: omList.c:10
static BOOLEAN ndCoeffIsEqual ( const coeffs  r,
n_coeffType  n,
void *   
)
static

Definition at line 286 of file numbers.cc.

288 {
289  /* test, if r is an instance of nInitCoeffs(n,parameter) */
290  /* if parameter is not needed */
291  return (n==r->type);
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
static char* ndCoeffName ( const coeffs  r)
static

Definition at line 153 of file numbers.cc.

153 { return r->cfCoeffString(r); }
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
static number ndConvFactoryNSingN ( const CanonicalForm  ,
const coeffs   
)
static

[in, out] a bigint number >= 0

[out] the GMP equivalent

Definition at line 267 of file numbers.cc.

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

Definition at line 260 of file numbers.cc.

261 {
262  CanonicalForm term(0);
263  Werror("no conversion to factory");
264  return term;
265 }
Definition: int_poly.h:36
factory's main class
Definition: canonicalform.h:75
void Werror(const char *fmt,...)
Definition: reporter.cc:199
static number ndCopy ( number  a,
const coeffs   
)
static

Definition at line 238 of file numbers.cc.

238 { return a; }
const poly a
Definition: syzextra.cc:212
number ndCopyMap ( number  a,
const coeffs  aRing,
const coeffs  r 
)

Definition at line 239 of file numbers.cc.

240 {
241  // aRing and r need not be the same, but must be the same representation
242  assume(aRing->rep==r->rep);
244  return a;
245  else
246  return r->cfCopy(a, r);
247 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE BOOLEAN nCoeff_has_simple_Alloc(const coeffs r)
TRUE if n_Delete/n_New are empty operations.
Definition: coeffs.h:907
static BOOLEAN ndDBTest ( number  ,
const char *  ,
const int  ,
const coeffs   
)
static

Definition at line 106 of file numbers.cc.

106 { return TRUE; }
#define TRUE
Definition: auxiliary.h:144
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
static BOOLEAN ndDivBy ( number  ,
number  ,
const coeffs   
)
static

Definition at line 255 of file numbers.cc.

255 { return TRUE; } // assume a,b !=0
#define TRUE
Definition: auxiliary.h:144
static int ndDivComp ( number  ,
number  ,
const coeffs   
)
static

Definition at line 256 of file numbers.cc.

256 { return 2; }
static number ndExtGcd ( number  ,
number  ,
number *  ,
number *  ,
const coeffs  r 
)
static

Definition at line 257 of file numbers.cc.

257 { return r->cfInit(1,r); }
static number ndFarey ( number  ,
number  ,
const coeffs  r 
)
static

Definition at line 109 of file numbers.cc.

110 {
111  Werror("farey not implemented for %s (c=%d)",r->cfCoeffString(r),getCoeffType(r));
112  return NULL;
113 }
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define NULL
Definition: omList.c:10
void Werror(const char *fmt,...)
Definition: reporter.cc:199
static number ndGcd ( number  ,
number  ,
const coeffs  r 
)
static

Definition at line 148 of file numbers.cc.

148 { return r->cfInit(1,r); }
static number ndGetDenom ( number &  ,
const coeffs  r 
)
static

Definition at line 150 of file numbers.cc.

150 { return r->cfInit(1,r); }
static number ndGetNumerator ( number &  a,
const coeffs  r 
)
static

Definition at line 151 of file numbers.cc.

151 { return r->cfCopy(a,r); }
const poly a
Definition: syzextra.cc:212
static number ndInitMPZ ( mpz_t  m,
const coeffs  r 
)
static

Definition at line 280 of file numbers.cc.

282 {
283  return r->cfInit( mpz_get_si(m), r);
int m
Definition: cfEzgcd.cc:119
static void ndInpAdd ( number &  a,
number  b,
const coeffs  r 
)
static

Definition at line 65 of file numbers.cc.

66 {
67  number n=r->cfAdd(a,b,r);
68  r->cfDelete(&a,r);
69  a=n;
70 }
const poly a
Definition: syzextra.cc:212
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
const poly b
Definition: syzextra.cc:213
static void ndInpMult ( number &  a,
number  b,
const coeffs  r 
)
static

Definition at line 59 of file numbers.cc.

60 {
61  number n=r->cfMult(a,b,r);
62  r->cfDelete(&a,r);
63  a=n;
64 }
const poly a
Definition: syzextra.cc:212
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
const poly b
Definition: syzextra.cc:213
static number ndIntMod ( number  ,
number  ,
const coeffs  r 
)
static

Definition at line 149 of file numbers.cc.

149 { return r->cfInit(0,r); }
static BOOLEAN ndIsUnit ( number  a,
const coeffs  r 
)
static

Definition at line 103 of file numbers.cc.

103 { return !r->cfIsZero(a,r); }
const poly a
Definition: syzextra.cc:212
static void ndKillChar ( coeffs  )
static

Definition at line 249 of file numbers.cc.

249 {}
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 275 of file numbers.cc.

277 {
278  mpz_init_set_si( result, r->cfInt(n, r) );
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
return result
Definition: facAbsBiFact.cc:76
static void ndNormalize ( number &  ,
const coeffs   
)
static

Definition at line 146 of file numbers.cc.

146 { }
static number ndParameter ( const int  ,
const coeffs  r 
)
static

Definition at line 125 of file numbers.cc.

126 {
127  Werror("ndParameter: n_Parameter is not implemented/relevant for (coeff_type = %d)",getCoeffType(r));
128  return NULL;
129 }
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define NULL
Definition: omList.c:10
void Werror(const char *fmt,...)
Definition: reporter.cc:199
static int ndParDeg ( number  n,
const coeffs  r 
)
static

Definition at line 120 of file numbers.cc.

121 {
122  return (-r->cfIsZero(n,r));
123 }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
static void ndPower ( number  a,
int  i,
number *  res,
const coeffs  r 
)
static

Definition at line 72 of file numbers.cc.

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

Definition at line 147 of file numbers.cc.

147 { return r->cfInit(0,r); }
static void ndSetChar ( const coeffs  )
static

Definition at line 250 of file numbers.cc.

250 {}
static int ndSize ( number  a,
const coeffs  r 
)
static

Definition at line 152 of file numbers.cc.

152 { return (int)r->cfIsZero(a,r)==FALSE; }
const poly a
Definition: syzextra.cc:212
#define FALSE
Definition: auxiliary.h:140
coeffs nInitChar ( n_coeffType  t,
void *  parameter 
)

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

Definition at line 327 of file numbers.cc.

329 {
331 
332  while((n!=NULL) && (n->nCoeffIsEqual!=NULL) && (!n->nCoeffIsEqual(n,t,parameter)))
333  n=n->next;
334 
335  if (n==NULL)
336  {
337  n=(n_Procs_s*)omAlloc0(sizeof(n_Procs_s));
338  n->next=cf_root;
339  n->ref=1;
340  n->type=t;
341 
342  // default entries (different from NULL) for some routines:
344  n->cfSize = ndSize;
347  n->cfImPart=ndReturn0;
348  n->cfDelete= ndDelete;
349  n->cfAnn = ndAnn;
350  n->cfCoeffString = ndCoeffString; // should alway be changed!
351  n->cfInpMult=ndInpMult;
352  n->cfInpAdd=ndInpAdd;
353  n->cfCopy = ndCopy;
354  n->cfIntMod=ndIntMod; /* dummy !! */
356  n->cfGcd = ndGcd;
357  n->cfNormalizeHelper = ndGcd; /* tricky, isn't it ?*/
358  n->cfLcm = ndGcd; /* tricky, isn't it ?*/
359  n->cfInitMPZ = ndInitMPZ;
360  n->cfMPZ = ndMPZ;
361  n->cfPower = ndPower;
363 
364  n->cfKillChar = ndKillChar; /* dummy */
365  n->cfSetChar = ndSetChar; /* dummy */
366  // temp. removed to catch all the coeffs which miss to implement this!
367 
369  n->cfFarey = ndFarey;
370  n->cfParDeg = ndParDeg;
371 
373 
376 
377  n->cfIsUnit = ndIsUnit;
378 #ifdef HAVE_RINGS
379  n->cfDivComp = ndDivComp;
380  n->cfDivBy = ndDivBy;
381  n->cfExtGcd = ndExtGcd;
382  //n->cfGetUnit = (nMapFunc)NULL;
383 #endif
384 
385 #ifdef LDEBUG
386  n->cfDBTest=ndDBTest;
387 #endif
388 
391 
392  BOOLEAN nOK=TRUE;
393  // init
394  if ((t<=nLastCoeffs) && (nInitCharTable[t]!=NULL))
395  nOK = (nInitCharTable[t])(n,parameter);
396  else
397  Werror("Sorry: the coeff type [%d] was not registered: it is missing in nInitCharTable", (int)t);
398  if (nOK)
399  {
400  omFreeSize(n,sizeof(*n));
401  return NULL;
402  }
403  cf_root=n;
404  // post init settings:
405  if (n->cfRePart==NULL) n->cfRePart=n->cfCopy;
406  if (n->cfExactDiv==NULL) n->cfExactDiv=n->cfDiv;
407  if (n->cfSubringGcd==NULL) n->cfSubringGcd=n->cfGcd;
408 
409 #ifdef HAVE_RINGS
410  if (n->cfGetUnit==NULL) n->cfGetUnit=n->cfCopy;
411 #endif
412 
413  if(n->cfWriteShort==NULL)
414  n->cfWriteShort = n->cfWriteLong;
415 
417  assume(n->cfSetChar!=NULL);
419  assume(n->cfMult!=NULL);
420  assume(n->cfSub!=NULL);
421  assume(n->cfAdd!=NULL);
422  assume(n->cfDiv!=NULL);
423  assume(n->cfIntMod!=NULL);
424  assume(n->cfExactDiv!=NULL);
425  assume(n->cfInit!=NULL);
426  assume(n->cfInitMPZ!=NULL);
427  assume(n->cfSize!=NULL);
428  assume(n->cfInt!=NULL);
429  assume(n->cfMPZ!=NULL);
430  //assume(n->n->cfDivComp!=NULL);
431  //assume(n->cfIsUnit!=NULL);
432  //assume(n->cfGetUnit!=NULL);
433  //assume(n->cfExtGcd!=NULL);
434  assume(n->cfInpNeg!=NULL);
435  assume(n->cfCopy!=NULL);
436 
437  assume(n->cfWriteLong!=NULL);
438  assume(n->cfWriteShort!=NULL);
439 
440  assume(n->iNumberOfParameters>= 0);
441 
442  assume( (n->iNumberOfParameters == 0 && n->pParameterNames == NULL) ||
443  (n->iNumberOfParameters > 0 && n->pParameterNames != NULL) );
444 
445  assume(n->cfParameter!=NULL);
446  assume(n->cfParDeg!=NULL);
447 
448  assume(n->cfRead!=NULL);
449  assume(n->cfNormalize!=NULL);
450  assume(n->cfGreater!=NULL);
451  //assume(n->cfDivBy!=NULL);
452  assume(n->cfEqual!=NULL);
453  assume(n->cfIsZero!=NULL);
454  assume(n->cfIsOne!=NULL);
455  assume(n->cfIsMOne!=NULL);
457  assume(n->cfGetDenom!=NULL);
459  assume(n->cfGcd!=NULL);
461  assume(n->cfDelete!=NULL);
462  assume(n->cfSetMap!=NULL);
463  assume(n->cfInpMult!=NULL);
464 // assume(n->cfInit_bigint!=NULL);
465  assume(n->cfCoeffWrite != NULL);
466 
467  assume(n->cfClearContent != NULL);
469 
470  assume(n->type==t);
471 
472 #ifndef SING_NDEBUG
473  if(n->cfKillChar==NULL) Warn("cfKillChar is NULL for coeff %d",t);
474  if(n->cfWriteLong==NULL) Warn("cfWrite is NULL for coeff %d",t);
475  if(n->cfWriteShort==NULL) Warn("cfWriteShort is NULL for coeff %d",t);
476  if(n->cfCoeffString==ndCoeffString) Warn("cfCoeffString is undefined for coeff %d",t);
477 #endif
478 
479  if( n->nNULL == NULL )
480  n->nNULL = n->cfInit(0, n); // may still remain NULL
481  }
482  else
483  {
484  n->ref++;
485  }
486  return n;
static BOOLEAN ndIsUnit(number a, const coeffs r)
Definition: numbers.cc:103
BOOLEAN(* cfDivBy)(number a, number b, const coeffs r)
Definition: coeffs.h:382
number(* cfCopy)(number a, const coeffs r)
return a copy of a
Definition: coeffs.h:198
number(* cfExtGcd)(number a, number b, number *s, number *t, const coeffs r)
Definition: coeffs.h:245
numberfunc cfIntMod
Definition: coeffs.h:174
int(* cfDivComp)(number a, number b, const coeffs r)
Definition: coeffs.h:378
static void ndPower(number a, int i, number *res, const coeffs r)
Definition: numbers.cc:72
static number ndParameter(const int, const coeffs r)
Definition: numbers.cc:125
number nNULL
the 0 as constant, NULL by default
Definition: coeffs.h:317
static void ndKillChar(coeffs)
Definition: numbers.cc:249
static BOOLEAN ndDBTest(number, const char *, const int, const coeffs)
Definition: numbers.cc:106
BOOLEAN(* cfDBTest)(number a, const char *f, const int l, const coeffs r)
Test: is "a" a correct number?
Definition: coeffs.h:416
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:189
void(* cfSetChar)(const coeffs r)
Definition: coeffs.h:160
static BOOLEAN ndDivBy(number, number, const coeffs)
Definition: numbers.cc:255
char const ** pParameterNames
array containing the names of Parameters (default NULL)
Definition: coeffs.h:323
coeffs next
Definition: coeffs.h:124
static number ndCopy(number a, const coeffs)
Definition: numbers.cc:238
static n_coeffType nLastCoeffs
Definition: numbers.cc:293
static number ndChineseRemainder(number *, number *, int, BOOLEAN, CFArray &, const coeffs r)
Definition: numbers.cc:114
void(* cfDelete)(number *a, const coeffs r)
Definition: coeffs.h:269
static void ndNormalize(number &, const coeffs)
Definition: numbers.cc:146
BOOLEAN(*)(*)(*)(*) cfIsOne(number a, const coeffs r)
Definition: coeffs.h:228
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
number(* cfSubringGcd)(number a, number b, const coeffs r)
Definition: coeffs.h:244
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
static number ndConvFactoryNSingN(const CanonicalForm, const coeffs)
[in, out] a bigint number >= 0
Definition: numbers.cc:267
numberfunc cfAdd
Definition: coeffs.h:174
BOOLEAN(* cfGreater)(number a, number b, const coeffs r)
Definition: coeffs.h:224
void(* cfNormalize)(number &a, const coeffs r)
Definition: coeffs.h:222
static char * ndCoeffString(const coeffs r)
Definition: numbers.cc:54
number(* cfRePart)(number a, const coeffs r)
Definition: coeffs.h:199
#define TRUE
Definition: auxiliary.h:144
static void ndDelete(number *d, const coeffs)
Definition: numbers.cc:52
static int ndDivComp(number, number, const coeffs)
Definition: numbers.cc:256
void(* cfCoeffWrite)(const coeffs r, BOOLEAN details)
output of coeff description via Print
Definition: coeffs.h:147
static char * ndCoeffName(const coeffs r)
Definition: numbers.cc:153
BOOLEAN(* cfIsUnit)(number a, const coeffs r)
Definition: coeffs.h:379
number(* cfGetUnit)(number a, const coeffs r)
Definition: coeffs.h:380
number(* cfFarey)(number p, number n, const coeffs)
rational reconstruction: "best" rational a/b with a/b = p mod n
Definition: coeffs.h:288
number(* cfInitMPZ)(mpz_t i, const coeffs r)
init with a GMP integer
Definition: coeffs.h:180
char *(* cfCoeffString)(const coeffs r)
string output of coeff description
Definition: coeffs.h:150
BOOLEAN(* nCoeffIsEqual)(const coeffs r, n_coeffType n, void *parameter)
Definition: coeffs.h:144
static number ndReturn0(number, const coeffs r)
Definition: numbers.cc:147
static void ndInpMult(number &a, number b, const coeffs r)
Definition: numbers.cc:59
number(* cfInit)(long i, const coeffs r)
init with an integer
Definition: coeffs.h:177
number(* cfNormalizeHelper)(number a, number b, const coeffs r)
Definition: coeffs.h:268
static number ndInitMPZ(mpz_t m, const coeffs r)
Definition: numbers.cc:280
static int ndParDeg(number n, const coeffs r)
Definition: numbers.cc:120
BOOLEAN(*)(*)(*)(*)(*)(*) cfGreaterZero(number a, const coeffs r)
Definition: coeffs.h:234
long(* cfInt)(number &n, const coeffs r)
convertion to long, 0 if impossible
Definition: coeffs.h:186
void(* cfInpMult)(number &a, number b, const coeffs r)
Inplace: a *= b.
Definition: coeffs.h:278
numberfunc cfSub
Definition: coeffs.h:174
static void ndClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs r)
Definition: numbers.cc:155
static number ndGetDenom(number &, const coeffs r)
Definition: numbers.cc:150
number(* cfImPart)(number a, const coeffs r)
Definition: coeffs.h:200
#define assume(x)
Definition: mod2.h:405
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:194
static int ndSize(number a, const coeffs r)
Definition: numbers.cc:152
int ref
Definition: coeffs.h:125
void(* cfPower)(number a, int i, number *result, const coeffs r)
Definition: coeffs.h:236
nCoeffsEnumeratorFunc cfClearContent
function pointer behind n_ClearContent
Definition: coeffs.h:306
n_Procs_s * cf_root
Definition: numbers.cc:47
numberfunc cfExactDiv
Definition: coeffs.h:174
static BOOLEAN ndCoeffIsEqual(const coeffs r, n_coeffType n, void *)
Definition: numbers.cc:286
n_coeffType type
Definition: coeffs.h:127
static CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition: numbers.cc:260
numberfunc cfDiv
Definition: coeffs.h:174
const char *(* cfRead)(const char *s, number *a, const coeffs r)
Definition: coeffs.h:220
numberfunc cfMult
Definition: coeffs.h:174
static number ndGcd(number, number, const coeffs r)
Definition: numbers.cc:148
static number ndExtGcd(number, number, number *, number *, const coeffs r)
Definition: numbers.cc:257
static cfInitCharProc * nInitCharTable
Definition: numbers.cc:323
#define NULL
Definition: omList.c:10
void(* cfWriteLong)(number a, const coeffs r)
print a given number (long format)
Definition: coeffs.h:203
number(* cfGcd)(number a, number b, const coeffs r)
Definition: coeffs.h:243
static void ndSetChar(const coeffs)
Definition: numbers.cc:250
number(* cfLcm)(number a, number b, const coeffs r)
Definition: coeffs.h:267
static void ndInpAdd(number &a, number b, const coeffs r)
Definition: numbers.cc:65
number(* convFactoryNSingN)(const CanonicalForm n, const coeffs r)
conversion to CanonicalForm(factory) to number
Definition: coeffs.h:312
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:294
static number ndGetNumerator(number &a, const coeffs r)
Definition: numbers.cc:151
static number ndAnn(number, const coeffs)
Definition: numbers.cc:53
static number ndIntMod(number, number, const coeffs r)
Definition: numbers.cc:149
static number ndFarey(number, number, const coeffs r)
Definition: numbers.cc:109
static void ndClearDenominators(ICoeffsEnumerator &, number &d, const coeffs r)
Definition: numbers.cc:229
nMapFunc(* cfSetMap)(const coeffs src, const coeffs dst)
Definition: coeffs.h:272
char *(* cfCoeffName)(const coeffs r)
default name of cf, should substitue cfCoeffWrite, cfCoeffString
Definition: coeffs.h:153
int(* cfSize)(number n, const coeffs r)
how complicated, (0) => 0, or positive
Definition: coeffs.h:183
number(* cfAnn)(number a, const coeffs r)
Definition: coeffs.h:258
number(* cfParameter)(const int i, const coeffs r)
create i^th parameter or NULL if not possible
Definition: coeffs.h:300
BOOLEAN(*)(*)(*)(*)(*) cfIsMOne(number a, const coeffs r)
Definition: coeffs.h:229
CanonicalForm(* convSingNFactoryN)(number n, BOOLEAN setChar, const coeffs r)
Definition: coeffs.h:313
void(* cfKillChar)(coeffs r)
Definition: coeffs.h:158
int BOOLEAN
Definition: auxiliary.h:131
static void ndMPZ(mpz_t result, number &n, const coeffs r)
Converts a non-negative bigint number into a GMP number.
Definition: numbers.cc:275
void Werror(const char *fmt,...)
Definition: reporter.cc:199
void(* cfInpAdd)(number &a, number b, const coeffs r)
Inplace: a += b.
Definition: coeffs.h:281
number(* cfGetNumerator)(number &n, const coeffs r)
Definition: coeffs.h:238
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:207
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int iNumberOfParameters
Number of Parameters in the coeffs (default 0)
Definition: coeffs.h:320
number(* cfGetDenom)(number &n, const coeffs r)
Definition: coeffs.h:237
BOOLEAN(*)(*)(*) cfIsZero(number a, const coeffs r)
Definition: coeffs.h:227
BOOLEAN(*)(*) cfEqual(number a, number b, const coeffs r)
tests
Definition: coeffs.h:226
nCoeffsEnumeratorFunc cfClearDenominators
function pointer behind n_ClearDenominators
Definition: coeffs.h:309
#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:297
void nKillChar ( coeffs  r)

undo all initialisations

Definition at line 488 of file numbers.cc.

490 {
492  if (r!=NULL)
493  {
494  r->ref--;
495  if (r->ref<=0)
496  {
497  n_Procs_s tmp;
498  n_Procs_s* n=&tmp;
499  tmp.next=cf_root;
500  while((n->next!=NULL) && (n->next!=r)) n=n->next;
501  if (n->next==r)
502  {
503  n->next=n->next->next;
504  if (cf_root==r) cf_root=n->next;
505  n_Delete(&(r->nNULL),r);
506  assume (r->cfKillChar!=NULL); r->cfKillChar(r); // STATISTIC(nKillChar);
507  omFreeSize((void *)r, sizeof(n_Procs_s));
508  r=NULL;
509  }
510  else
511  {
512  WarnS("cf_root list destroyed");
513  }
514  }
515  }
#define STATISTIC(f)
Definition: numstats.h:16
coeffs next
Definition: coeffs.h:124
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#define WarnS
Definition: emacs.cc:81
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:488
#define assume(x)
Definition: mod2.h:405
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 'p'
Definition: coeffs.h:456
void nNew ( number *  d)

Definition at line 49 of file numbers.cc.

49 { *d=NULL; }
#define NULL
Definition: omList.c:10
n_coeffType nRegister ( n_coeffType  n,
cfInitCharProc  p 
)

Definition at line 518 of file numbers.cc.

520 {
521  if (n==n_unknown)
522  {
525  {
527  ((int)nLastCoeffs+1)*sizeof(cfInitCharProc));
529  ((int)nLastCoeffs)*sizeof(cfInitCharProc));
530  }
531  else
532  {
534  ((int)nLastCoeffs)*sizeof(cfInitCharProc),
535  (((int)nLastCoeffs)+1)*sizeof(cfInitCharProc));
536  }
537 
539  return nLastCoeffs;
540  }
541  else
542  {
543  if (nInitCharTable[n]!=NULL) Print("coeff %d already initialized\n",n);
544  nInitCharTable[n]=p;
545  return n;
546  }
#define Print
Definition: emacs.cc:83
return P p
Definition: myNF.cc:203
static n_coeffType nLastCoeffs
Definition: numbers.cc:293
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#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:294
n_coeffType
Definition: coeffs.h:27
static cfInitCharProc * nInitCharTable
Definition: numbers.cc:323
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211

Variable Documentation

n_Procs_s* cf_root =NULL

Definition at line 47 of file numbers.cc.

cfInitCharProc* nInitCharTable =nInitCharTableDefault
static

Definition at line 323 of file numbers.cc.

cfInitCharProc nInitCharTableDefault[]
Initial value:
=
{ NULL,
}
BOOLEAN nrInitChar(coeffs n, void *p)
Initialize r.
Definition: shortfl.cc:733
BOOLEAN naInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition: algext.cc:1389
BOOLEAN nr2mInitChar(coeffs r, void *p)
Definition: rmodulo2m.cc:160
BOOLEAN npInitChar(coeffs r, void *p)
Definition: modulop.cc:498
BOOLEAN nlInitChar(coeffs r, void *p)
Definition: longrat.cc:3138
BOOLEAN ngcInitChar(coeffs n, void *parameter)
Initialize r (n_long_C)
Definition: gnumpc.cc:464
BOOLEAN nrnInitChar(coeffs r, void *p)
Definition: rmodulon.cc:163
BOOLEAN nrzInitChar(coeffs r, void *)
Definition: rintegers.cc:488
BOOLEAN nfInitChar(coeffs r, void *parameter)
Definition: ffields.cc:836
#define NULL
Definition: omList.c:10
BOOLEAN ngfInitChar(coeffs n, void *parameter)
Initialize r.
Definition: gnumpfl.cc:443
BOOLEAN ntInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition: transext.cc:2503

Definition at line 294 of file numbers.cc.

n_coeffType nLastCoeffs =n_CF
static

Definition at line 293 of file numbers.cc.