My Project  UNKNOWN_GIT_VERSION
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)
 
void nrzDelete (number *a, const coeffs)
 
static number nrzCopy (number a, const coeffs)
 
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)
 
void nrzWriteFd (number n, const ssiInfo *d, const coeffs)
 
number nrzReadFd (const ssiInfo *d, const coeffs)
 
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 411 of file rintegers.cc.

412 {
413  const char * start=s;
414 
415  if (*s<'0' || *s>'9')
416  {
417  mpz_set_ui(i,1);
418  return s;
419  }
420  while (*s >= '0' && *s <= '9') s++;
421  if (*s=='\0')
422  {
423  mpz_set_str(i,start,10);
424  }
425  else
426  {
427  char c=*s;
428  *s='\0';
429  mpz_set_str(i,start,10);
430  *s=c;
431  }
432  return s;
433 }
int i
Definition: cfEzgcd.cc:125
const CanonicalForm int s
Definition: facAbsFact.cc:55

◆ nrzAdd()

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

Definition at line 177 of file rintegers.cc.

178 {
179  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
180  mpz_init(erg);
181  mpz_add(erg, (mpz_ptr) a, (mpz_ptr) b);
182  return (number) erg;
183 }
CanonicalForm b
Definition: cfModGcd.cc:4044
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
omBin gmp_nrz_bin
Definition: rintegers.cc:31

◆ nrzCoeffName()

static char* nrzCoeffName ( const  coeffs)
static

Definition at line 479 of file rintegers.cc.

480 {
481  return (char*)"ZZ";
482 }

◆ nrzCoeffString()

static char* nrzCoeffString ( const coeffs  cf)
static

Definition at line 484 of file rintegers.cc.

485 {
486  return omStrDup(nrzCoeffName(cf));
487 }
CanonicalForm cf
Definition: cfModGcd.cc:4024
#define omStrDup(s)
Definition: omAllocDecl.h:263
static char * nrzCoeffName(const coeffs)
Definition: rintegers.cc:479

◆ nrzCoeffWrite()

static void nrzCoeffWrite ( const  coeffs,
BOOLEAN   
)
static

Definition at line 474 of file rintegers.cc.

475 {
476  PrintS("ZZ");
477 }
void PrintS(const char *s)
Definition: reporter.cc:284

◆ nrzConvFactoryNSingN()

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

Definition at line 447 of file rintegers.cc.

448 {
449  if (n.isImm())
450  return nrzInit(n.intval(),r);
451  else
452  {
453  mpz_ptr m = (mpz_ptr) omAllocBin(gmp_nrz_bin);
454  gmp_numerator(n,m);
455  if (!n.den().isOne())
456  {
457  WarnS("denominator is not 1 in factory");
458  }
459  return (number) m;
460  }
461 }
int m
Definition: cfEzgcd.cc:121
CanonicalForm den() const
den() returns the denominator of CO if CO is a rational number, 1 (from the current domain!...
long intval() const
conversion functions
bool isImm() const
CF_NO_INLINE bool isOne() const
CF_INLINE bool CanonicalForm::isOne, isZero () const.
Definition: cf_inline.cc:354
#define WarnS
Definition: emacs.cc:78
void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:20
number nrzInit(long i, const coeffs)
Definition: rintegers.cc:128

◆ nrzConvSingNFactoryN()

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

Definition at line 436 of file rintegers.cc.

437 {
438  if (setChar) setCharacteristic( 0 );
439 
441  mpz_t num;
442  mpz_init_set(num, *((mpz_t*)n));
443  term = make_cf(num);
444  return term;
445 }
CanonicalForm num(const CanonicalForm &f)
void setCharacteristic(int c)
Definition: cf_char.cc:23
factory's main class
Definition: canonicalform.h:83
Definition: int_poly.h:33
CanonicalForm make_cf(const mpz_ptr n)
Definition: singext.cc:66

◆ nrzCopy()

static number nrzCopy ( number  a,
const  coeffs 
)
static

Definition at line 145 of file rintegers.cc.

146 {
147  if (a==NULL) return NULL;
148  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
149  mpz_init_set(erg, (mpz_ptr) a);
150  return (number) erg;
151 }
#define NULL
Definition: omList.c:10

◆ nrzDBTest()

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

Definition at line 385 of file rintegers.cc.

386 {
387  return TRUE;//TODO
388 }
#define TRUE
Definition: auxiliary.h:98

◆ nrzDelete()

void nrzDelete ( number *  a,
const  coeffs 
)

Definition at line 135 of file rintegers.cc.

136 {
137  if (*a != NULL)
138  {
139  mpz_clear((mpz_ptr) *a);
141  *a = NULL;
142  }
143 }
void * ADDRESS
Definition: auxiliary.h:133
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259

◆ nrzDiv()

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

Definition at line 249 of file rintegers.cc.

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

◆ nrzDivBy()

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

Definition at line 233 of file rintegers.cc.

234 {
235  return mpz_divisible_p((mpz_ptr) a, (mpz_ptr) b) != 0;
236 }

◆ nrzDivComp()

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

Definition at line 238 of file rintegers.cc.

239 {
240  if (nrzDivBy(a, b, r))
241  {
242  if (nrzDivBy(b, a, r)) return 2;
243  return -1;
244  }
245  if (nrzDivBy(b, a, r)) return 1;
246  return 0;
247 }
static BOOLEAN nrzDivBy(number a, number b, const coeffs)
Definition: rintegers.cc:233

◆ nrzEqual()

static BOOLEAN nrzEqual ( 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 }

◆ nrzExactDiv()

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

Definition at line 266 of file rintegers.cc.

267 {
268  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
269  mpz_init(erg);
270  mpz_tdiv_q(erg, (mpz_ptr) a, (mpz_ptr) b);
271  return (number) erg;
272 }

◆ 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 509 of file rintegers.cc.

510 {
511  number a0 = nrzCopy(N, R);
512  number b0 = nrzInit(0, R);
513  number a1 = nrzCopy(r, R);
514  number b1 = nrzInit(1, R);
515  number two = nrzInit(2, R);
516 #if 0
517  PrintS("Farey start with ");
518  n_Print(r, R);
519  PrintS(" mod ");
520  n_Print(N, R);
521  PrintLn();
522 #endif
523  while (1)
524  {
525  number as = nrzMult(a1, a1, R);
526  n_InpMult(as, two, R);
527  if (nrzGreater(N, as, R))
528  {
529  nrzDelete(&as, R);
530  break;
531  }
532  nrzDelete(&as, R);
533  number q = nrzDiv(a0, a1, R);
534  number t = nrzMult(a1, q, R),
535  s = nrzSub(a0, t, R);
536  nrzDelete(&a0, R);
537  a0 = a1;
538  a1 = s;
539  nrzDelete(&t, R);
540 
541  t = nrzMult(b1, q, R);
542  s = nrzSub(b0, t, R);
543  nrzDelete(&b0, R);
544  b0 = b1;
545  b1 = s;
546  nrzDelete(&t, R);
547  nrzDelete(&q, R);
548  }
549  number as = nrzMult(b1, b1, R);
550  n_InpMult(as, two, R);
551  nrzDelete(&two, R);
552  if (nrzGreater(as, N, R))
553  {
554  nrzDelete(&a0, R);
555  nrzDelete(&a1, R);
556  nrzDelete(&b0, R);
557  nrzDelete(&b1, R);
558  nrzDelete(&as, R);
559  return NULL;
560  }
561  nrzDelete(&as, R);
562  nrzDelete(&a0, R);
563  nrzDelete(&b0, R);
564 
565  number a, b, ab;
566  coeffs Q = nInitChar(n_Q, 0);
567  nMapFunc f = n_SetMap(R, Q);
568  a = f(a1, R, Q);
569  b = f(b1, R, Q);
570  ab = n_Div(a, b, Q);
571  n_Delete(&a, Q);
572  n_Delete(&b, Q);
573  nKillChar(Q);
574 
575  nrzDelete(&a1, R);
576  nrzDelete(&b1, R);
577  return ab;
578 }
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
FILE * f
Definition: checklibs.c:9
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:31
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:611
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:721
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:615
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:350
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
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:641
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:511
The main handler for Singular numbers which are suitable for Singular polynomials.
void PrintLn()
Definition: reporter.cc:310
static number nrzSub(number a, number b, const coeffs)
Definition: rintegers.cc:185
static BOOLEAN nrzGreater(number a, number b, const coeffs)
Definition: rintegers.cc:223
static number nrzDiv(number a, number b, const coeffs)
Definition: rintegers.cc:249
static number nrzMult(number a, number b, const coeffs)
Definition: rintegers.cc:37
void nrzDelete(number *a, const coeffs)
Definition: rintegers.cc:135
static number nrzCopy(number a, const coeffs)
Definition: rintegers.cc:145
#define R
Definition: sirandom.c:26
#define Q
Definition: sirandom.c:25

◆ 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 193 of file rintegers.cc.

194 {
195  return nrzInit(1, r);
196 }

◆ nrzGreater()

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

Definition at line 223 of file rintegers.cc.

224 {
225  return 0 < mpz_cmp((mpz_ptr) a, (mpz_ptr) b);
226 }

◆ nrzGreaterZero()

static BOOLEAN nrzGreaterZero ( number  k,
const  coeffs 
)
static

Definition at line 228 of file rintegers.cc.

229 {
230  return 0 < mpz_sgn1((mpz_ptr) k);
231 }
int k
Definition: cfEzgcd.cc:92
#define mpz_sgn1(A)
Definition: si_gmp.h:13

◆ 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 *  parameter 
)

Definition at line 594 of file rintegers.cc.

595 {
596  assume( getCoeffType(r) == n_Z );
597 
598  r->is_field=FALSE;
599  r->is_domain=TRUE;
600  r->rep=n_rep_gmp;
601 
602  //r->nCoeffIsEqual = ndCoeffIsEqual;
603  r->cfCoeffString = nrzCoeffString;
604  r->cfCoeffName = nrzCoeffName;
605  r->cfCoeffWrite = nrzCoeffWrite;
606  //r->cfKillChar = ndKillChar;
607  r->cfMult = nrzMult;
608  r->cfSub = nrzSub;
609  r->cfAdd = nrzAdd;
610  r->cfDiv = nrzDiv;
611  r->cfIntMod= nrzIntMod;
612  r->cfExactDiv= nrzExactDiv;
613  r->cfInit = nrzInit;
614  r->cfInitMPZ = nrzInitMPZ;
615  r->cfSize = nrzSize;
616  r->cfInt = nrzInt;
617  r->cfDivComp = nrzDivComp;
618  r->cfIsUnit = nrzIsUnit;
619  r->cfGetUnit = nrzGetUnit;
620  r->cfExtGcd = nrzExtGcd;
621  r->cfXExtGcd = nrzXExtGcd;
622  r->cfDivBy = nrzDivBy;
623  r->cfQuotRem = nrzQuotRem;
624  r->cfInpNeg = nrzNeg;
625  r->cfInvers= nrzInvers;
626  r->cfCopy = nrzCopy;
627  r->cfWriteLong = nrzWrite;
628  r->cfRead = nrzRead;
629  r->cfGreater = nrzGreater;
630  r->cfEqual = nrzEqual;
631  r->cfIsZero = nrzIsZero;
632  r->cfIsOne = nrzIsOne;
633  r->cfIsMOne = nrzIsMOne;
634  r->cfGreaterZero = nrzGreaterZero;
635  r->cfPower = nrzPower;
636  r->cfGcd = nrzGcd;
637  r->cfLcm = nrzLcm;
638  r->cfDelete= nrzDelete;
639  r->cfSetMap = nrzSetMap;
640  r->cfQuot1 = nrzQuot1;
641  r->convSingNFactoryN=nrzConvSingNFactoryN;
642  r->convFactoryNSingN=nrzConvFactoryNSingN;
643  r->cfChineseRemainder=nlChineseRemainderSym;
644  r->cfFarey=nrzFarey;
645  r->cfWriteFd=nrzWriteFd;
646  r->cfReadFd=nrzReadFd;
647  // debug stuff
648 
649 #ifdef LDEBUG
650  r->cfDBTest=nrzDBTest;
651 #endif
652 
653  r->ch = 0;
654  r->has_simple_Alloc=FALSE;
655  r->has_simple_Inverse=FALSE;
656  return FALSE;
657 }
#define FALSE
Definition: auxiliary.h:94
@ n_Z
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:115
number nlChineseRemainderSym(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs CF)
Definition: longrat.cc:2939
#define assume(x)
Definition: mod2.h:390
number nrzReadFd(const ssiInfo *d, const coeffs)
Definition: rintegers.cc:586
static number nrzNeg(number c, const coeffs)
Definition: rintegers.cc:315
static BOOLEAN nrzEqual(number a, number b, const coeffs)
Definition: rintegers.cc:218
void nrzWrite(number a, const coeffs)
Definition: rintegers.cc:391
static number nrzGcd(number a, number b, const coeffs)
Definition: rintegers.cc:60
static BOOLEAN nrzIsMOne(number a, const coeffs)
Definition: rintegers.cc:213
static number nrzLcm(number a, number b, const coeffs)
Definition: rintegers.cc:48
static BOOLEAN nrzIsZero(number a, const coeffs)
Definition: rintegers.cc:203
static number nrzConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: rintegers.cc:447
static void nrzPower(number a, int i, number *result, const coeffs)
Definition: rintegers.cc:117
static number nrzInvers(number c, const coeffs r)
Definition: rintegers.cc:305
static number nrzXExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs)
Definition: rintegers.cc:86
static number nrzExactDiv(number a, number b, const coeffs)
Definition: rintegers.cc:266
static long nrzInt(number &n, const coeffs)
Definition: rintegers.cc:172
int nrzSize(number a, const coeffs)
Definition: rintegers.cc:160
static number nrzIntMod(number a, number b, const coeffs)
Definition: rintegers.cc:293
static BOOLEAN nrzIsUnit(number a, const coeffs)
Definition: rintegers.cc:198
static int nrzDivComp(number a, number b, const coeffs r)
Definition: rintegers.cc:238
static void nrzCoeffWrite(const coeffs, BOOLEAN)
Definition: rintegers.cc:474
static number nrzAdd(number a, number b, const coeffs)
Definition: rintegers.cc:177
static number nrzExtGcd(number a, number b, number *s, number *t, const coeffs)
Definition: rintegers.cc:72
static coeffs nrzQuot1(number c, const coeffs r)
Definition: rintegers.cc:489
static BOOLEAN nrzGreaterZero(number k, const coeffs)
Definition: rintegers.cc:228
static nMapFunc nrzSetMap(const coeffs src, const coeffs)
Definition: rintegers.cc:344
static BOOLEAN nrzIsOne(number a, const coeffs)
Definition: rintegers.cc:208
static number nrzQuotRem(number a, number b, number *r, const coeffs)
Definition: rintegers.cc:274
static number nrzGetUnit(number, const coeffs r)
Definition: rintegers.cc:193
static number nrzInitMPZ(mpz_t m, const coeffs)
Definition: rintegers.cc:502
static BOOLEAN nrzDBTest(number, const char *, const int, const coeffs)
Definition: rintegers.cc:385
static const char * nrzRead(const char *s, number *a, const coeffs)
Definition: rintegers.cc:463
void nrzWriteFd(number n, const ssiInfo *d, const coeffs)
Definition: rintegers.cc:580
static CanonicalForm nrzConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs)
Definition: rintegers.cc:436
static number nrzFarey(number r, number N, const coeffs R)
Definition: rintegers.cc:509
static char * nrzCoeffString(const coeffs cf)
Definition: rintegers.cc:484

◆ nrzInitExp()

void nrzInitExp ( int  ,
coeffs   
)

Definition at line 380 of file rintegers.cc.

381 {
382 }

◆ nrzInitMPZ()

static number nrzInitMPZ ( mpz_t  m,
const  coeffs 
)
static

Definition at line 502 of file rintegers.cc.

503 {
504  mpz_ptr z = (mpz_ptr) omAllocBin(gmp_nrz_bin);
505  mpz_init_set(z, m);
506  return (number)z;
507 }

◆ nrzInt()

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

Definition at line 172 of file rintegers.cc.

173 {
174  return mpz_get_si( (mpz_ptr)n);
175 }

◆ nrzIntMod()

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

Definition at line 293 of file rintegers.cc.

294 {
295  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
296  mpz_init(erg);
297  mpz_ptr r = (mpz_ptr) omAllocBin(gmp_nrz_bin);
298  mpz_init(r);
299  mpz_tdiv_qr(erg, r, (mpz_ptr) a, (mpz_ptr) b);
300  mpz_clear(erg);
301  omFreeBin(erg, gmp_nrz_bin);
302  return (number) r;
303 }

◆ nrzInvers()

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

Definition at line 305 of file rintegers.cc.

306 {
307  if (!nrzIsUnit((number) c, r))
308  {
309  WerrorS("Non invertible element.");
310  return (number)NULL;
311  }
312  return nrzCopy(c,r);
313 }
void WerrorS(const char *s)
Definition: feFopen.cc:24

◆ nrzIsMOne()

static BOOLEAN nrzIsMOne ( number  a,
const  coeffs 
)
static

Definition at line 213 of file rintegers.cc.

214 {
215  return (0 == mpz_cmp_si((mpz_ptr) a, -1));
216 }

◆ nrzIsOne()

static BOOLEAN nrzIsOne ( number  a,
const  coeffs 
)
static

Definition at line 208 of file rintegers.cc.

209 {
210  return (0 == mpz_cmp_ui((mpz_ptr) a, 1));
211 }

◆ nrzIsUnit()

static BOOLEAN nrzIsUnit ( number  a,
const  coeffs 
)
static

Definition at line 198 of file rintegers.cc.

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

◆ nrzIsZero()

static BOOLEAN nrzIsZero ( number  a,
const  coeffs 
)
static

Definition at line 203 of file rintegers.cc.

204 {
205  return 0 == mpz_cmpabs_ui((mpz_ptr) a, 0);
206 }

◆ 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 322 of file rintegers.cc.

323 {
324  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
325  mpz_init_set_ui(erg, (unsigned long) from);
326  return (number) erg;
327 }

◆ nrzMapQ()

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

Definition at line 336 of file rintegers.cc.

337 {
338  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
339  mpz_init(erg);
340  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); // ?
341  return (number) erg;
342 }
void nlGMP(number &i, mpz_t n, const coeffs r)
Definition: longrat.cc:1478

◆ nrzMapZp()

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

Definition at line 329 of file rintegers.cc.

330 {
331  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
332  mpz_init_set_si(erg, (long) from);
333  return (number) erg;
334 }

◆ 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 315 of file rintegers.cc.

316 {
317 // nNeg inplace !!!
318  mpz_mul_si((mpz_ptr) c, (mpz_ptr) c, -1);
319  return c;
320 }
void mpz_mul_si(mpz_ptr r, mpz_srcptr s, long int si)
Definition: longrat.cc:172

◆ 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 }
return result
Definition: facAbsBiFact.cc:76

◆ nrzQuot1()

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

Definition at line 489 of file rintegers.cc.

490 {
491  long ch = r->cfInt(c, r);
492  mpz_t dummy;
493  mpz_init_set_ui(dummy, ch);
494  ZnmInfo info;
495  info.base = dummy;
496  info.exp = (unsigned long) 1;
497  coeffs rr = nInitChar(n_Zn, (void*)&info);
498  mpz_clear(dummy);
499  return(rr);
500 }
@ n_Zn
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
const ExtensionInfo & info
< [in] sqrfree poly

◆ nrzQuotRem()

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

Definition at line 274 of file rintegers.cc.

275 {
276  mpz_ptr qq = (mpz_ptr) omAllocBin(gmp_nrz_bin);
277  mpz_init(qq);
278  mpz_ptr rr = (mpz_ptr) omAllocBin(gmp_nrz_bin);
279  mpz_init(rr);
280  mpz_tdiv_qr(qq, rr, (mpz_ptr) a, (mpz_ptr) b);
281  if (r==NULL)
282  {
283  mpz_clear(rr);
285  }
286  else
287  {
288  *r=(number)rr;
289  }
290  return (number) qq;
291 }

◆ nrzRead()

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

Definition at line 463 of file rintegers.cc.

464 {
465  mpz_ptr z = (mpz_ptr) omAllocBin(gmp_nrz_bin);
466  {
467  mpz_init(z);
468  s = nlEatLongC((char *) s, z);
469  }
470  *a = (number) z;
471  return s;
472 }
static const char * nlEatLongC(char *s, mpz_ptr i)
Definition: rintegers.cc:411

◆ nrzReadFd()

number nrzReadFd ( const ssiInfo d,
const  coeffs 
)

Definition at line 586 of file rintegers.cc.

587 {
588  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
589  mpz_init(erg);
591  return (number)erg;
592 }
#define SSI_BASE
Definition: auxiliary.h:149
void s_readmpz_base(s_buff F, mpz_ptr a, int base)
Definition: s_buff.cc:207
s_buff f_read
Definition: s_buff.h:22

◆ nrzSetExp()

void nrzSetExp ( int  ,
coeffs   
)

Definition at line 376 of file rintegers.cc.

377 {
378 }

◆ nrzSetMap()

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

Definition at line 344 of file rintegers.cc.

345 {
346  /* dst = currRing */
347  /* dst = nrn */
348  if ((src->rep==n_rep_gmp)
349  && (nCoeff_is_Z(src) || nCoeff_is_Zn(src) || nCoeff_is_Ring_PtoM(src)))
350  {
351  return ndCopyMap; //nrzCopyMap;
352  }
353  if ((src->rep==n_rep_gap_gmp) /*&& nCoeff_is_Z(src)*/)
354  {
355  return ndCopyMap; //nrzCopyMap;
356  }
357  if (nCoeff_is_Ring_2toM(src))
358  {
359  return nrzMapMachineInt;
360  }
361  if (nCoeff_is_Zp(src))
362  {
363  return nrzMapZp;
364  }
365  if (getCoeffType(src)==n_Q /*nCoeff_is_Q(src) or coeffs_BIGINT*/)
366  {
367  return nrzMapQ;
368  }
369  return NULL; // default
370 }
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition: coeffs.h:838
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r)
Definition: coeffs.h:749
static FORCE_INLINE BOOLEAN nCoeff_is_Zn(const coeffs r)
Definition: coeffs.h:848
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:822
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:746
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:112
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:252
static number nrzMapQ(number from, const coeffs src, const coeffs)
Definition: rintegers.cc:336
static number nrzMapZp(number from, const coeffs, const coeffs)
Definition: rintegers.cc:329
static number nrzMapMachineInt(number from, const coeffs, const coeffs)
Definition: rintegers.cc:322

◆ nrzSize()

int nrzSize ( number  a,
const  coeffs 
)

Definition at line 160 of file rintegers.cc.

161 {
162  mpz_ptr p=(mpz_ptr)a;
163  int s=p->_mp_alloc;
164  if (s==1) s=(mpz_cmp_ui(p,0)!=0);
165  return s;
166 
167 }
int p
Definition: cfModGcd.cc:4019

◆ nrzSub()

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

Definition at line 185 of file rintegers.cc.

186 {
187  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
188  mpz_init(erg);
189  mpz_sub(erg, (mpz_ptr) a, (mpz_ptr) b);
190  return (number) erg;
191 }

◆ nrzWrite()

void nrzWrite ( number  a,
const  coeffs 
)

Definition at line 391 of file rintegers.cc.

392 {
393  char *s,*z;
394  if (a==NULL)
395  {
396  StringAppendS("o");
397  }
398  else
399  {
400  int l=mpz_sizeinbase((mpz_ptr) a, 10) + 2;
401  s=(char*)omAlloc(l);
402  z=mpz_get_str(s,10,(mpz_ptr) a);
403  StringAppendS(z);
404  omFreeSize((ADDRESS)s,l);
405  }
406 }
int l
Definition: cfEzgcd.cc:93
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
void StringAppendS(const char *st)
Definition: reporter.cc:107

◆ nrzWriteFd()

void nrzWriteFd ( number  n,
const ssiInfo d,
const  coeffs 
)

Definition at line 580 of file rintegers.cc.

581 {
582  mpz_out_str (d->f_write,SSI_BASE, (mpz_ptr)n);
583  fputc(' ',d->f_write);
584 }
FILE * f_write
Definition: s_buff.h:23

◆ 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 }
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37

Variable Documentation

◆ gmp_nrz_bin

omBin gmp_nrz_bin = omGetSpecBin(sizeof(mpz_t))

Definition at line 31 of file rintegers.cc.