My Project  debian-1:4.1.1-p2+ds-4build3
Functions | Variables
rintegers.cc File Reference
#include "misc/auxiliary.h"
#include "omalloc/omalloc.h"
#include "factory/factory.h"
#include "misc/mylimits.h"
#include "reporter/reporter.h"
#include "coeffs/coeffs.h"
#include "coeffs/longrat.h"
#include "coeffs/numbers.h"
#include "coeffs/si_gmp.h"
#include "coeffs/mpr_complex.h"
#include "coeffs/rintegers.h"
#include "coeffs/rmodulon.h"
#include <string.h>

Go to the source code of this file.

Functions

static number nrzMult (number a, number b, const coeffs)
 
static number nrzLcm (number a, number b, const coeffs)
 
static number nrzGcd (number a, number b, const coeffs)
 
static number nrzExtGcd (number a, number b, number *s, number *t, const coeffs)
 
static number nrzXExtGcd (number a, number b, number *s, number *t, number *u, number *v, const coeffs)
 
static void nrzPower (number a, int i, number *result, const coeffs)
 
number nrzInit (long i, const coeffs)
 
static void nrzDelete (number *a, const coeffs)
 
static number nrzCopy (number a, const coeffs)
 
static int nrzSize (number a, const coeffs)
 
static long nrzInt (number &n, const coeffs)
 
static number nrzAdd (number a, number b, const coeffs)
 
static number nrzSub (number a, number b, const coeffs)
 
static number nrzGetUnit (number, const coeffs r)
 
static BOOLEAN nrzIsUnit (number a, const coeffs)
 
static BOOLEAN nrzIsZero (number a, const coeffs)
 
static BOOLEAN nrzIsOne (number a, const coeffs)
 
static BOOLEAN nrzIsMOne (number a, const coeffs)
 
static BOOLEAN nrzEqual (number a, number b, const coeffs)
 
static BOOLEAN nrzGreater (number a, number b, const coeffs)
 
static BOOLEAN nrzGreaterZero (number k, const coeffs)
 
static BOOLEAN nrzDivBy (number a, number b, const coeffs)
 
static int nrzDivComp (number a, number b, const coeffs r)
 
static number nrzDiv (number a, number b, const coeffs)
 
static number nrzExactDiv (number a, number b, const coeffs)
 
static number nrzQuotRem (number a, number b, number *r, const coeffs)
 
static number nrzIntMod (number a, number b, const coeffs)
 
static number nrzInvers (number c, const coeffs r)
 
static number nrzNeg (number c, const coeffs)
 
static number nrzMapMachineInt (number from, const coeffs, const coeffs)
 
static number nrzMapZp (number from, const coeffs, const coeffs)
 
static number nrzMapQ (number from, const coeffs src, const coeffs)
 
static nMapFunc nrzSetMap (const coeffs src, const coeffs)
 
void nrzSetExp (int, coeffs)
 
void nrzInitExp (int, coeffs)
 
static BOOLEAN nrzDBTest (number, const char *, const int, const coeffs)
 
void nrzWrite (number a, const coeffs)
 
static const char * nlEatLongC (char *s, mpz_ptr i)
 
static CanonicalForm nrzConvSingNFactoryN (number n, BOOLEAN setChar, const coeffs)
 
static number nrzConvFactoryNSingN (const CanonicalForm n, const coeffs r)
 
static const char * nrzRead (const char *s, number *a, const coeffs)
 
static void nrzCoeffWrite (const coeffs, BOOLEAN)
 
static char * nrzCoeffName (const coeffs)
 
static char * nrzCoeffString (const coeffs cf)
 
static coeffs nrzQuot1 (number c, const coeffs r)
 
static number nrzInitMPZ (mpz_t m, const coeffs)
 
static number nrzFarey (number r, number N, const coeffs R)
 
BOOLEAN nrzInitChar (coeffs r, void *)
 

Variables

omBin gmp_nrz_bin = omGetSpecBin(sizeof(mpz_t))
 

Function Documentation

◆ nlEatLongC()

static const char* nlEatLongC ( char *  s,
mpz_ptr  i 
)
static

Definition at line 406 of file rintegers.cc.

407 {
408  const char * start=s;
409 
410  if (*s<'0' || *s>'9')
411  {
412  mpz_set_ui(i,1);
413  return s;
414  }
415  while (*s >= '0' && *s <= '9') s++;
416  if (*s=='\0')
417  {
418  mpz_set_str(i,start,10);
419  }
420  else
421  {
422  char c=*s;
423  *s='\0';
424  mpz_set_str(i,start,10);
425  *s=c;
426  }
427  return s;
428 }

◆ nrzAdd()

static number nrzAdd ( number  a,
number  b,
const  coeffs 
)
static

Definition at line 172 of file rintegers.cc.

173 {
174  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
175  mpz_init(erg);
176  mpz_add(erg, (mpz_ptr) a, (mpz_ptr) b);
177  return (number) erg;
178 }

◆ nrzCoeffName()

static char* nrzCoeffName ( const  coeffs)
static

Definition at line 470 of file rintegers.cc.

471 {
472  return (char*)"ZZ";
473 }

◆ nrzCoeffString()

static char* nrzCoeffString ( const coeffs  cf)
static

Definition at line 475 of file rintegers.cc.

476 {
477  return omStrDup(nrzCoeffName(cf));
478 }

◆ nrzCoeffWrite()

static void nrzCoeffWrite ( const  coeffs,
BOOLEAN   
)
static

Definition at line 465 of file rintegers.cc.

466 {
467  PrintS("ZZ");
468 }

◆ nrzConvFactoryNSingN()

static number nrzConvFactoryNSingN ( const CanonicalForm  n,
const coeffs  r 
)
static

Definition at line 442 of file rintegers.cc.

443 {
444  if (n.isImm())
445  return nrzInit(n.intval(),r);
446  else
447  {
448  mpz_ptr m = (mpz_ptr) omAllocBin(gmp_nrz_bin);
449  gmp_numerator(n,m);
450  return (number) m;
451  }
452 }

◆ nrzConvSingNFactoryN()

static CanonicalForm nrzConvSingNFactoryN ( number  n,
BOOLEAN  setChar,
const  coeffs 
)
static

Definition at line 431 of file rintegers.cc.

432 {
433  if (setChar) setCharacteristic( 0 );
434 
436  mpz_t num;
437  mpz_init_set(num, *((mpz_t*)n));
438  term = make_cf(num);
439  return term;
440 }

◆ nrzCopy()

static number nrzCopy ( number  a,
const  coeffs 
)
static

Definition at line 143 of file rintegers.cc.

144 {
145  if (a==NULL) return NULL;
146  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
147  mpz_init_set(erg, (mpz_ptr) a);
148  return (number) erg;
149 }

◆ nrzDBTest()

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

Definition at line 380 of file rintegers.cc.

381 {
382  return TRUE;//TODO
383 }

◆ nrzDelete()

static void nrzDelete ( number *  a,
const  coeffs 
)
static

Definition at line 135 of file rintegers.cc.

136 {
137  if (*a == NULL) return;
138  mpz_clear((mpz_ptr) *a);
140  *a = NULL;
141 }

◆ nrzDiv()

static number nrzDiv ( number  a,
number  b,
const  coeffs 
)
static

Definition at line 244 of file rintegers.cc.

245 {
246  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
247  mpz_init(erg);
248  mpz_ptr r = (mpz_ptr) omAllocBin(gmp_nrz_bin);
249  mpz_init(r);
250  mpz_tdiv_qr(erg, r, (mpz_ptr) a, (mpz_ptr) b);
251  //if (!nrzIsZero((number) r, R))
252  //{
253  // WerrorS("Division by non divisible element.");
254  // WerrorS("Result is without remainder.");
255  //}
256  mpz_clear(r);
258  return (number) erg;
259 }

◆ nrzDivBy()

static BOOLEAN nrzDivBy ( number  a,
number  b,
const  coeffs 
)
static

Definition at line 228 of file rintegers.cc.

229 {
230  return mpz_divisible_p((mpz_ptr) a, (mpz_ptr) b) != 0;
231 }

◆ nrzDivComp()

static int nrzDivComp ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 233 of file rintegers.cc.

234 {
235  if (nrzDivBy(a, b, r))
236  {
237  if (nrzDivBy(b, a, r)) return 2;
238  return -1;
239  }
240  if (nrzDivBy(b, a, r)) return 1;
241  return 0;
242 }

◆ nrzEqual()

static BOOLEAN nrzEqual ( number  a,
number  b,
const  coeffs 
)
static

Definition at line 213 of file rintegers.cc.

214 {
215  return 0 == mpz_cmp((mpz_ptr) a, (mpz_ptr) b);
216 }

◆ nrzExactDiv()

static number nrzExactDiv ( number  a,
number  b,
const  coeffs 
)
static

Definition at line 261 of file rintegers.cc.

262 {
263  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
264  mpz_init(erg);
265  mpz_tdiv_q(erg, (mpz_ptr) a, (mpz_ptr) b);
266  return (number) erg;
267 }

◆ nrzExtGcd()

static number nrzExtGcd ( number  a,
number  b,
number *  s,
number *  t,
const  coeffs 
)
static

Definition at line 72 of file rintegers.cc.

73 {
74  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
75  mpz_ptr bs = (mpz_ptr) omAllocBin(gmp_nrz_bin);
76  mpz_ptr bt = (mpz_ptr) omAllocBin(gmp_nrz_bin);
77  mpz_init(erg);
78  mpz_init(bs);
79  mpz_init(bt);
80  mpz_gcdext(erg, bs, bt, (mpz_ptr) a, (mpz_ptr) b);
81  *s = (number) bs;
82  *t = (number) bt;
83  return (number) erg;
84 }

◆ nrzFarey()

static number nrzFarey ( number  r,
number  N,
const coeffs  R 
)
static

Definition at line 500 of file rintegers.cc.

501 {
502  number a0 = nrzCopy(N, R);
503  number b0 = nrzInit(0, R);
504  number a1 = nrzCopy(r, R);
505  number b1 = nrzInit(1, R);
506  number two = nrzInit(2, R);
507 #if 0
508  PrintS("Farey start with ");
509  n_Print(r, R);
510  PrintS(" mod ");
511  n_Print(N, R);
512  PrintLn();
513 #endif
514  while (1)
515  {
516  number as = nrzMult(a1, a1, R);
517  n_InpMult(as, two, R);
518  if (nrzGreater(N, as, R))
519  {
520  nrzDelete(&as, R);
521  break;
522  }
523  nrzDelete(&as, R);
524  number q = nrzDiv(a0, a1, R);
525  number t = nrzMult(a1, q, R),
526  s = nrzSub(a0, t, R);
527  nrzDelete(&a0, R);
528  a0 = a1;
529  a1 = s;
530  nrzDelete(&t, R);
531 
532  t = nrzMult(b1, q, R);
533  s = nrzSub(b0, t, R);
534  nrzDelete(&b0, R);
535  b0 = b1;
536  b1 = s;
537  nrzDelete(&t, R);
538  nrzDelete(&q, R);
539  }
540  number as = nrzMult(b1, b1, R);
541  n_InpMult(as, two, R);
542  nrzDelete(&two, R);
543  if (nrzGreater(as, N, R))
544  {
545  nrzDelete(&a0, R);
546  nrzDelete(&a1, R);
547  nrzDelete(&b0, R);
548  nrzDelete(&b1, R);
549  nrzDelete(&as, R);
550  return NULL;
551  }
552  nrzDelete(&as, R);
553  nrzDelete(&a0, R);
554  nrzDelete(&b0, R);
555 
556  number a, b, ab;
557  coeffs Q = nInitChar(n_Q, 0);
558  nMapFunc f = n_SetMap(R, Q);
559  a = f(a1, R, Q);
560  b = f(b1, R, Q);
561  ab = n_Div(a, b, Q);
562  n_Delete(&a, Q);
563  n_Delete(&b, Q);
564  nKillChar(Q);
565 
566  nrzDelete(&a1, R);
567  nrzDelete(&b1, R);
568  return ab;
569 }

◆ nrzGcd()

static number nrzGcd ( number  a,
number  b,
const  coeffs 
)
static

Definition at line 60 of file rintegers.cc.

61 {
62  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
63  mpz_init(erg);
64  mpz_gcd(erg, (mpz_ptr) a, (mpz_ptr) b);
65  return (number) erg;
66 }

◆ nrzGetUnit()

static number nrzGetUnit ( number  ,
const coeffs  r 
)
static

Definition at line 188 of file rintegers.cc.

189 {
190  return nrzInit(1, r);
191 }

◆ nrzGreater()

static BOOLEAN nrzGreater ( number  a,
number  b,
const  coeffs 
)
static

Definition at line 218 of file rintegers.cc.

219 {
220  return 0 < mpz_cmp((mpz_ptr) a, (mpz_ptr) b);
221 }

◆ nrzGreaterZero()

static BOOLEAN nrzGreaterZero ( number  k,
const  coeffs 
)
static

Definition at line 223 of file rintegers.cc.

224 {
225  return 0 < mpz_sgn1((mpz_ptr) k);
226 }

◆ nrzInit()

number nrzInit ( long  i,
const  coeffs 
)

Definition at line 128 of file rintegers.cc.

129 {
130  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
131  mpz_init_set_si(erg, i);
132  return (number) erg;
133 }

◆ nrzInitChar()

BOOLEAN nrzInitChar ( coeffs  r,
void *   
)

Definition at line 571 of file rintegers.cc.

572 {
573  assume( getCoeffType(r) == n_Z );
574 
575  r->is_field=FALSE;
576  r->is_domain=TRUE;
577  r->rep=n_rep_gmp;
578 
579  //r->nCoeffIsEqual = ndCoeffIsEqual;
580  r->cfCoeffString = nrzCoeffString;
581  r->cfCoeffName = nrzCoeffName;
582  r->cfCoeffWrite = nrzCoeffWrite;
583  //r->cfKillChar = ndKillChar;
584  r->cfMult = nrzMult;
585  r->cfSub = nrzSub;
586  r->cfAdd = nrzAdd;
587  r->cfDiv = nrzDiv;
588  r->cfIntMod= nrzIntMod;
589  r->cfExactDiv= nrzExactDiv;
590  r->cfInit = nrzInit;
591  r->cfInitMPZ = nrzInitMPZ;
592  r->cfSize = nrzSize;
593  r->cfInt = nrzInt;
594  r->cfDivComp = nrzDivComp;
595  r->cfIsUnit = nrzIsUnit;
596  r->cfGetUnit = nrzGetUnit;
597  r->cfExtGcd = nrzExtGcd;
598  r->cfXExtGcd = nrzXExtGcd;
599  r->cfDivBy = nrzDivBy;
600  r->cfQuotRem = nrzQuotRem;
601  r->cfInpNeg = nrzNeg;
602  r->cfInvers= nrzInvers;
603  r->cfCopy = nrzCopy;
604  r->cfWriteLong = nrzWrite;
605  r->cfRead = nrzRead;
606  r->cfGreater = nrzGreater;
607  r->cfEqual = nrzEqual;
608  r->cfIsZero = nrzIsZero;
609  r->cfIsOne = nrzIsOne;
610  r->cfIsMOne = nrzIsMOne;
611  r->cfGreaterZero = nrzGreaterZero;
612  r->cfPower = nrzPower;
613  r->cfGcd = nrzGcd;
614  r->cfLcm = nrzLcm;
615  r->cfDelete= nrzDelete;
616  r->cfSetMap = nrzSetMap;
617  r->cfQuot1 = nrzQuot1;
618  r->convSingNFactoryN=nrzConvSingNFactoryN;
619  r->convFactoryNSingN=nrzConvFactoryNSingN;
620  r->cfChineseRemainder=nlChineseRemainderSym;
621  r->cfFarey=nrzFarey;
622  // debug stuff
623 
624 #ifdef LDEBUG
625  r->cfDBTest=nrzDBTest;
626 #endif
627 
628  r->ch = 0;
629  r->has_simple_Alloc=FALSE;
630  r->has_simple_Inverse=FALSE;
631  return FALSE;
632 }

◆ nrzInitExp()

void nrzInitExp ( int  ,
coeffs   
)

Definition at line 375 of file rintegers.cc.

376 {
377 }

◆ nrzInitMPZ()

static number nrzInitMPZ ( mpz_t  m,
const  coeffs 
)
static

Definition at line 493 of file rintegers.cc.

494 {
495  mpz_ptr z = (mpz_ptr) omAllocBin(gmp_nrz_bin);
496  mpz_init_set(z, m);
497  return (number)z;
498 }

◆ nrzInt()

static long nrzInt ( number &  n,
const  coeffs 
)
static

Definition at line 167 of file rintegers.cc.

168 {
169  return mpz_get_si( (mpz_ptr)n);
170 }

◆ nrzIntMod()

static number nrzIntMod ( number  a,
number  b,
const  coeffs 
)
static

Definition at line 288 of file rintegers.cc.

289 {
290  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
291  mpz_init(erg);
292  mpz_ptr r = (mpz_ptr) omAllocBin(gmp_nrz_bin);
293  mpz_init(r);
294  mpz_tdiv_qr(erg, r, (mpz_ptr) a, (mpz_ptr) b);
295  mpz_clear(erg);
296  omFreeBin(erg, gmp_nrz_bin);
297  return (number) r;
298 }

◆ nrzInvers()

static number nrzInvers ( number  c,
const coeffs  r 
)
static

Definition at line 300 of file rintegers.cc.

301 {
302  if (!nrzIsUnit((number) c, r))
303  {
304  WerrorS("Non invertible element.");
305  return (number)0; //TODO
306  }
307  return nrzCopy(c,r);
308 }

◆ nrzIsMOne()

static BOOLEAN nrzIsMOne ( number  a,
const  coeffs 
)
static

Definition at line 208 of file rintegers.cc.

209 {
210  return (a!=NULL) && (0 == mpz_cmp_si((mpz_ptr) a, -1));
211 }

◆ nrzIsOne()

static BOOLEAN nrzIsOne ( number  a,
const  coeffs 
)
static

Definition at line 203 of file rintegers.cc.

204 {
205  return (a!=NULL) && (0 == mpz_cmp_ui((mpz_ptr) a, 1));
206 }

◆ nrzIsUnit()

static BOOLEAN nrzIsUnit ( number  a,
const  coeffs 
)
static

Definition at line 193 of file rintegers.cc.

194 {
195  return 0 == mpz_cmpabs_ui((mpz_ptr) a, 1);
196 }

◆ nrzIsZero()

static BOOLEAN nrzIsZero ( number  a,
const  coeffs 
)
static

Definition at line 198 of file rintegers.cc.

199 {
200  return 0 == mpz_cmpabs_ui((mpz_ptr) a, 0);
201 }

◆ nrzLcm()

static number nrzLcm ( number  a,
number  b,
const  coeffs 
)
static

Definition at line 48 of file rintegers.cc.

49 {
50  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
51  mpz_init(erg);
52  mpz_lcm(erg, (mpz_ptr) a, (mpz_ptr) b);
53  return (number) erg;
54 }

◆ nrzMapMachineInt()

static number nrzMapMachineInt ( number  from,
const  coeffs,
const  coeffs 
)
static

Definition at line 317 of file rintegers.cc.

318 {
319  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
320  mpz_init_set_ui(erg, (unsigned long) from);
321  return (number) erg;
322 }

◆ nrzMapQ()

static number nrzMapQ ( number  from,
const coeffs  src,
const  coeffs 
)
static

Definition at line 331 of file rintegers.cc.

332 {
333  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
334  mpz_init(erg);
335  nlGMP(from, erg, src); // FIXME? TODO? // extern void nlGMP(number &i, number n, const coeffs r); // to be replaced with n_MPZ(erg, from, src); // ?
336  return (number) erg;
337 }

◆ nrzMapZp()

static number nrzMapZp ( number  from,
const  coeffs,
const  coeffs 
)
static

Definition at line 324 of file rintegers.cc.

325 {
326  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
327  mpz_init_set_si(erg, (long) from);
328  return (number) erg;
329 }

◆ nrzMult()

static number nrzMult ( number  a,
number  b,
const  coeffs 
)
static

Definition at line 37 of file rintegers.cc.

38 {
39  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
40  mpz_init(erg);
41  mpz_mul(erg, (mpz_ptr) a, (mpz_ptr) b);
42  return (number) erg;
43 }

◆ nrzNeg()

static number nrzNeg ( number  c,
const  coeffs 
)
static

Definition at line 310 of file rintegers.cc.

311 {
312 // nNeg inplace !!!
313  mpz_mul_si((mpz_ptr) c, (mpz_ptr) c, -1);
314  return c;
315 }

◆ nrzPower()

static void nrzPower ( number  a,
int  i,
number *  result,
const  coeffs 
)
static

Definition at line 117 of file rintegers.cc.

118 {
119  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
120  mpz_init(erg);
121  mpz_pow_ui(erg, (mpz_ptr) a, i);
122  *result = (number) erg;
123 }

◆ nrzQuot1()

static coeffs nrzQuot1 ( number  c,
const coeffs  r 
)
static

Definition at line 480 of file rintegers.cc.

481 {
482  long ch = r->cfInt(c, r);
483  mpz_t dummy;
484  mpz_init_set_ui(dummy, ch);
485  ZnmInfo info;
486  info.base = dummy;
487  info.exp = (unsigned long) 1;
488  coeffs rr = nInitChar(n_Zn, (void*)&info);
489  mpz_clear(dummy);
490  return(rr);
491 }

◆ nrzQuotRem()

static number nrzQuotRem ( number  a,
number  b,
number *  r,
const  coeffs 
)
static

Definition at line 269 of file rintegers.cc.

270 {
271  mpz_ptr qq = (mpz_ptr) omAllocBin(gmp_nrz_bin);
272  mpz_init(qq);
273  mpz_ptr rr = (mpz_ptr) omAllocBin(gmp_nrz_bin);
274  mpz_init(rr);
275  mpz_tdiv_qr(qq, rr, (mpz_ptr) a, (mpz_ptr) b);
276  if (r==NULL)
277  {
278  mpz_clear(rr);
280  }
281  else
282  {
283  *r=(number)rr;
284  }
285  return (number) qq;
286 }

◆ nrzRead()

static const char* nrzRead ( const char *  s,
number *  a,
const  coeffs 
)
static

Definition at line 454 of file rintegers.cc.

455 {
456  mpz_ptr z = (mpz_ptr) omAllocBin(gmp_nrz_bin);
457  {
458  mpz_init(z);
459  s = nlEatLongC((char *) s, z);
460  }
461  *a = (number) z;
462  return s;
463 }

◆ nrzSetExp()

void nrzSetExp ( int  ,
coeffs   
)

Definition at line 371 of file rintegers.cc.

372 {
373 }

◆ nrzSetMap()

static nMapFunc nrzSetMap ( const coeffs  src,
const  coeffs 
)
static

Definition at line 339 of file rintegers.cc.

340 {
341  /* dst = currRing */
342  /* dst = nrn */
343  if ((src->rep==n_rep_gmp)
344  && (nCoeff_is_Ring_Z(src) || nCoeff_is_Ring_ModN(src) || nCoeff_is_Ring_PtoM(src)))
345  {
346  return ndCopyMap; //nrzCopyMap;
347  }
348  if ((src->rep==n_rep_gap_gmp) /*&& nCoeff_is_Ring_Z(src)*/)
349  {
350  return ndCopyMap; //nrzCopyMap;
351  }
352  if (nCoeff_is_Ring_2toM(src))
353  {
354  return nrzMapMachineInt;
355  }
356  if (nCoeff_is_Zp(src))
357  {
358  return nrzMapZp;
359  }
360  if (getCoeffType(src)==n_Q /*nCoeff_is_Q(src) or coeffs_BIGINT*/)
361  {
362  return nrzMapQ;
363  }
364  return NULL; // default
365 }

◆ nrzSize()

static int nrzSize ( number  a,
const  coeffs 
)
static

Definition at line 158 of file rintegers.cc.

159 {
160  if (a == NULL) return 0;
161  return (((mpz_ptr)a)->_mp_alloc);
162 }

◆ nrzSub()

static number nrzSub ( number  a,
number  b,
const  coeffs 
)
static

Definition at line 180 of file rintegers.cc.

181 {
182  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
183  mpz_init(erg);
184  mpz_sub(erg, (mpz_ptr) a, (mpz_ptr) b);
185  return (number) erg;
186 }

◆ nrzWrite()

void nrzWrite ( number  a,
const  coeffs 
)

Definition at line 386 of file rintegers.cc.

387 {
388  char *s,*z;
389  if (a==NULL)
390  {
391  StringAppendS("o");
392  }
393  else
394  {
395  int l=mpz_sizeinbase((mpz_ptr) a, 10) + 2;
396  s=(char*)omAlloc(l);
397  z=mpz_get_str(s,10,(mpz_ptr) a);
398  StringAppendS(z);
399  omFreeSize((ADDRESS)s,l);
400  }
401 }

◆ nrzXExtGcd()

static number nrzXExtGcd ( number  a,
number  b,
number *  s,
number *  t,
number *  u,
number *  v,
const  coeffs 
)
static

Definition at line 86 of file rintegers.cc.

87 {
88  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
89  mpz_ptr bs = (mpz_ptr) omAllocBin(gmp_nrz_bin);
90  mpz_ptr bt = (mpz_ptr) omAllocBin(gmp_nrz_bin);
91  mpz_init(erg);
92  mpz_init(bs);
93  mpz_init(bt);
94 
95  mpz_gcdext(erg, bs, bt, (mpz_ptr)a, (mpz_ptr)b);
96 
97  mpz_ptr bu = (mpz_ptr) omAllocBin(gmp_nrz_bin);
98  mpz_ptr bv = (mpz_ptr) omAllocBin(gmp_nrz_bin);
99 
100  mpz_init_set(bu, (mpz_ptr) b);
101  mpz_init_set(bv, (mpz_ptr) a);
102 
103  assume(mpz_cmp_si(erg, 0));
104 
105  mpz_div(bu, bu, erg);
106  mpz_div(bv, bv, erg);
107 
108  mpz_mul_si(bu, bu, -1);
109  *u = (number) bu;
110  *v = (number) bv;
111 
112  *s = (number) bs;
113  *t = (number) bt;
114  return (number) erg;
115 }

Variable Documentation

◆ gmp_nrz_bin

omBin gmp_nrz_bin = omGetSpecBin(sizeof(mpz_t))

Definition at line 31 of file rintegers.cc.

getCoeffType
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
FALSE
#define FALSE
Definition: auxiliary.h:94
n_rep_gmp
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:116
n_Zn
@ n_Zn
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
nrzCopy
static number nrzCopy(number a, const coeffs)
Definition: rintegers.cc:143
nCoeff_is_Zp
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:831
StringAppendS
void StringAppendS(const char *st)
Definition: reporter.cc:107
nrzInvers
static number nrzInvers(number c, const coeffs r)
Definition: rintegers.cc:300
f
FILE * f
Definition: checklibs.c:9
nrzDiv
static number nrzDiv(number a, number b, const coeffs)
Definition: rintegers.cc:244
nrzMapQ
static number nrzMapQ(number from, const coeffs src, const coeffs)
Definition: rintegers.cc:331
nrzSetMap
static nMapFunc nrzSetMap(const coeffs src, const coeffs)
Definition: rintegers.cc:339
k
int k
Definition: cfEzgcd.cc:92
nrzFarey
static number nrzFarey(number r, number N, const coeffs R)
Definition: rintegers.cc:500
nrzConvSingNFactoryN
static CanonicalForm nrzConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs)
Definition: rintegers.cc:431
nCoeff_is_Ring_2toM
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:747
result
return result
Definition: facAbsBiFact.cc:76
n_InpMult
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:642
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
nlChineseRemainderSym
number nlChineseRemainderSym(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs CF)
Definition: longrat.cc:2936
mpz_sgn1
#define mpz_sgn1(A)
Definition: si_gmp.h:13
nrzQuot1
static coeffs nrzQuot1(number c, const coeffs r)
Definition: rintegers.cc:480
num
CanonicalForm num(const CanonicalForm &f)
Definition: canonicalform.h:330
nrzSize
static int nrzSize(number a, const coeffs)
Definition: rintegers.cc:158
cf
CanonicalForm cf
Definition: cfModGcd.cc:4024
nrzIntMod
static number nrzIntMod(number a, number b, const coeffs)
Definition: rintegers.cc:288
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:263
nrzGreater
static BOOLEAN nrzGreater(number a, number b, const coeffs)
Definition: rintegers.cc:218
ndCopyMap
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
nrzConvFactoryNSingN
static number nrzConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: rintegers.cc:442
nlEatLongC
static const char * nlEatLongC(char *s, mpz_ptr i)
Definition: rintegers.cc:406
nInitChar
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:349
omAllocBin
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
n_Q
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:31
make_cf
CanonicalForm make_cf(const mpz_ptr n)
Definition: singext.cc:66
gmp_nrz_bin
omBin gmp_nrz_bin
Definition: rintegers.cc:31
N
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
nrzMapZp
static number nrzMapZp(number from, const coeffs, const coeffs)
Definition: rintegers.cc:324
CanonicalForm::isImm
bool isImm() const
Definition: canonicalform.h:107
b
CanonicalForm b
Definition: cfModGcd.cc:4044
nrzDBTest
static BOOLEAN nrzDBTest(number, const char *, const int, const coeffs)
Definition: rintegers.cc:380
CanonicalForm
factory's main class
Definition: canonicalform.h:83
term
Definition: int_poly.h:33
nrzIsOne
static BOOLEAN nrzIsOne(number a, const coeffs)
Definition: rintegers.cc:203
CanonicalForm::intval
long intval() const
conversion functions
Definition: canonicalform.cc:197
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
nCoeff_is_Ring_ModN
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_ModN(const coeffs r)
Definition: coeffs.h:750
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
nrzCoeffString
static char * nrzCoeffString(const coeffs cf)
Definition: rintegers.cc:475
nrzGetUnit
static number nrzGetUnit(number, const coeffs r)
Definition: rintegers.cc:188
PrintS
void PrintS(const char *s)
Definition: reporter.cc:284
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
nrzGreaterZero
static BOOLEAN nrzGreaterZero(number k, const coeffs)
Definition: rintegers.cc:223
nrzEqual
static BOOLEAN nrzEqual(number a, number b, const coeffs)
Definition: rintegers.cc:213
nrzExtGcd
static number nrzExtGcd(number a, number b, number *s, number *t, const coeffs)
Definition: rintegers.cc:72
nrzAdd
static number nrzAdd(number a, number b, const coeffs)
Definition: rintegers.cc:172
setCharacteristic
void setCharacteristic(int c)
Definition: cf_char.cc:23
nrzCoeffWrite
static void nrzCoeffWrite(const coeffs, BOOLEAN)
Definition: rintegers.cc:465
coeffs
n_Z
@ n_Z
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
nrzSub
static number nrzSub(number a, number b, const coeffs)
Definition: rintegers.cc:180
nrzNeg
static number nrzNeg(number c, const coeffs)
Definition: rintegers.cc:310
nCoeff_is_Ring_PtoM
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r)
Definition: coeffs.h:753
nrzMapMachineInt
static number nrzMapMachineInt(number from, const coeffs, const coeffs)
Definition: rintegers.cc:317
nrzDivBy
static BOOLEAN nrzDivBy(number a, number b, const coeffs)
Definition: rintegers.cc:228
n_Print
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:581
nrzIsZero
static BOOLEAN nrzIsZero(number a, const coeffs)
Definition: rintegers.cc:198
nrzInt
static long nrzInt(number &n, const coeffs)
Definition: rintegers.cc:167
nrzQuotRem
static number nrzQuotRem(number a, number b, number *r, const coeffs)
Definition: rintegers.cc:269
mpz_mul_si
void mpz_mul_si(mpz_ptr r, mpz_srcptr s, long int si)
Definition: longrat.cc:172
nrzInitMPZ
static number nrzInitMPZ(mpz_t m, const coeffs)
Definition: rintegers.cc:493
nrzCoeffName
static char * nrzCoeffName(const coeffs)
Definition: rintegers.cc:470
nrzDivComp
static int nrzDivComp(number a, number b, const coeffs r)
Definition: rintegers.cc:233
nrzIsMOne
static BOOLEAN nrzIsMOne(number a, const coeffs)
Definition: rintegers.cc:208
nrzMult
static number nrzMult(number a, number b, const coeffs)
Definition: rintegers.cc:37
nrzInit
number nrzInit(long i, const coeffs)
Definition: rintegers.cc:128
nrzExactDiv
static number nrzExactDiv(number a, number b, const coeffs)
Definition: rintegers.cc:261
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
m
int m
Definition: cfEzgcd.cc:121
nrzRead
static const char * nrzRead(const char *s, number *a, const coeffs)
Definition: rintegers.cc:454
nrzDelete
static void nrzDelete(number *a, const coeffs)
Definition: rintegers.cc:135
nrzXExtGcd
static number nrzXExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs)
Definition: rintegers.cc:86
assume
#define assume(x)
Definition: mod2.h:390
NULL
#define NULL
Definition: omList.c:10
l
int l
Definition: cfEzgcd.cc:93
R
#define R
Definition: sirandom.c:26
nrzPower
static void nrzPower(number a, int i, number *result, const coeffs)
Definition: rintegers.cc:117
gmp_numerator
void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:20
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
nrzWrite
void nrzWrite(number a, const coeffs)
Definition: rintegers.cc:386
ZnmInfo
Definition: rmodulon.h:18
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
n_Div
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:616
n_SetMap
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:722
Q
#define Q
Definition: sirandom.c:25
PrintLn
void PrintLn()
Definition: reporter.cc:310
omFreeBin
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
nCoeff_is_Ring_Z
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_Z(const coeffs r)
Definition: coeffs.h:756
info
const ExtensionInfo & info
< [in] sqrfree poly
Definition: facFqFactorize.h:38
nrzIsUnit
static BOOLEAN nrzIsUnit(number a, const coeffs)
Definition: rintegers.cc:193
nKillChar
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:510
nrzLcm
static number nrzLcm(number a, number b, const coeffs)
Definition: rintegers.cc:48
nrzGcd
static number nrzGcd(number a, number b, const coeffs)
Definition: rintegers.cc:60
nlGMP
void nlGMP(number &i, mpz_t n, const coeffs r)
Definition: longrat.cc:1478
n_rep_gap_gmp
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:113