My Project
Loading...
Searching...
No Matches
InternalInteger Class Reference

factory's class for integers More...

#include <int_int.h>

Public Member Functions

void * operator new (size_t)
 
void operator delete (void *addr, size_t)
 
 InternalInteger ()
 
 InternalInteger (const InternalCF &)
 
 InternalInteger (const int i)
 
 InternalInteger (const long i)
 
 InternalInteger (const char *str, const int base=10)
 
 InternalInteger (const mpz_ptr mpi)
 
 ~InternalInteger ()
 
InternalCFdeepCopyObject () const
 
const char * classname () const
 
void print (OSTREAM &, char *)
 
InternalCFgenZero ()
 
InternalCFgenOne ()
 
bool is_imm () const
 
int levelcoeff () const
 
InternalCFneg ()
 InternalCF * InternalInteger::neg ()
 
int comparesame (InternalCF *)
 
InternalCFaddsame (InternalCF *)
 
InternalCFsubsame (InternalCF *)
 
InternalCFmulsame (InternalCF *)
 
InternalCFdividesame (InternalCF *)
 
InternalCFmodulosame (InternalCF *)
 
InternalCFdivsame (InternalCF *)
 
InternalCFmodsame (InternalCF *)
 
void divremsame (InternalCF *, InternalCF *&, InternalCF *&)
 
bool divremsamet (InternalCF *, InternalCF *&, InternalCF *&)
 
int comparecoeff (InternalCF *)
 
InternalCFaddcoeff (InternalCF *)
 
InternalCFsubcoeff (InternalCF *, bool)
 
InternalCFmulcoeff (InternalCF *)
 
InternalCFdividecoeff (InternalCF *, bool)
 
InternalCFmodulocoeff (InternalCF *, bool)
 
InternalCFdivcoeff (InternalCF *, bool)
 
InternalCFmodcoeff (InternalCF *, bool)
 
void divremcoeff (InternalCF *, InternalCF *&, InternalCF *&, bool)
 
bool divremcoefft (InternalCF *, InternalCF *&, InternalCF *&, bool)
 
InternalCFbgcdsame (const InternalCF *const) const
 
InternalCFbgcdcoeff (const InternalCF *const)
 
InternalCFbextgcdsame (InternalCF *, CanonicalForm &, CanonicalForm &)
 
InternalCFbextgcdcoeff (InternalCF *, CanonicalForm &, CanonicalForm &)
 
long intval () const
 
int intmod (int p) const
 
int sign () const
 int InternalInteger::sign () const
 
InternalCFsqrt ()
 InternalCF * InternalInteger::sqrt ()
 
int ilog2 ()
 int InternalInteger::ilog2 ()
 
- Public Member Functions inherited from InternalCF
 InternalCF ()
 
 InternalCF (const InternalCF &)
 
virtual ~InternalCF ()
 
int deleteObject ()
 
InternalCFcopyObject ()
 
virtual int level () const
 
virtual int type () const
 
virtual Variable variable () const
 
virtual bool inBaseDomain () const
 
virtual bool inExtension () const
 
virtual bool inCoeffDomain () const
 
virtual bool inPolyDomain () const
 
virtual bool inQuotDomain () const
 
virtual bool isZero () const
 
virtual bool isOne () const
 bool InternalCF::isOne, isZero () const
 
virtual bool isUnivariate () const
 
virtual InternalCFnum ()
 InternalCF * InternalCF::num (), den ()
 
virtual InternalCFden ()
 
virtual InternalCFinvert ()
 
virtual InternalCFtryInvert (const CanonicalForm &, bool &)
 
virtual InternalCFtryMulsame (InternalCF *, const CanonicalForm &)
 
virtual InternalCFtryDivsame (InternalCF *, const CanonicalForm &, bool &)
 
virtual bool tryDivremsamet (InternalCF *, InternalCF *&, InternalCF *&, const CanonicalForm &, bool &)
 
virtual InternalCFtryDividecoeff (InternalCF *, bool, const CanonicalForm &, bool &)
 
virtual InternalCFtryDivcoeff (InternalCF *, bool, const CanonicalForm &, bool &)
 
virtual bool tryDivremcoefft (InternalCF *, InternalCF *&, InternalCF *&, bool, const CanonicalForm &, bool &)
 
virtual CanonicalForm lc ()
 CanonicalForm InternalCF::lc (), Lc (), LC ()
 
virtual CanonicalForm Lc ()
 
virtual CanonicalForm LC ()
 
virtual CanonicalForm coeff (int i)
 CanonicalForm InternalCF::coeff ( int i )
 
virtual int degree ()
 int InternalCF::degree ()
 
virtual int taildegree ()
 
virtual CanonicalForm tailcoeff ()
 CanonicalForm InternalCF::tailcoeff (), int InternalCF::taildegree ()
 
- Public Member Functions inherited from omallocClass
void * operator new (size_t size) throw (std::bad_alloc)
 
void operator delete (void *block) throw ()
 
void * operator new[] (size_t size) throw (std::bad_alloc)
 
void operator delete[] (void *block) throw ()
 
void * operator new (size_t size, const std::nothrow_t &) throw ()
 
void * operator new[] (size_t size, const std::nothrow_t &) throw ()
 

Private Member Functions

InternalCFnormalizeMyself ()
 normalizeMyself(), uiNormalizeMyself() - normalize CO.
 
InternalCFuiNormalizeMyself ()
 uiNormalizeMyself()’ is the same as ‘normalizeMyself()’ except that CO is expected to be non-negative.
 

Static Private Member Functions

static InternalCFnormalizeMPI (mpz_ptr)
 normalizeMPI(), uiNormalizeMPI() - normalize a mpi.
 
static InternalCFuiNormalizeMPI (mpz_ptr)
 uiNormalizeMPI()’ is the same as ‘normalizeMPI()’ except that ‘aMpi’ is expected to be non-begative.
 
static mpz_ptr MPI (const InternalCF *const c)
 MPI() - return underlying mpz_t of ‘c’.
 

Private Attributes

mpz_t thempi
 

Static Private Attributes

static const omBin InternalInteger_bin = omGetSpecBin(sizeof(InternalInteger))
 

Friends

class InternalRational
 
void gmp_numerator (const CanonicalForm &f, mpz_ptr result)
 
void gmp_denominator (const CanonicalForm &f, mpz_ptr result)
 
void getmpi (InternalCF *value, mpz_t mpi)
 
void convertCF2Fmpz (fmpz *, const CanonicalForm &)
 
void convertCF2initFmpz (fmpz_t result, const CanonicalForm &f)
 conversion of a factory integer to fmpz_t(init.)
 
void convertCF2Fmpq (fmpq_t result, const CanonicalForm &f)
 conversion of a factory rationals to fmpq_t
 

Additional Inherited Members

- Protected Member Functions inherited from InternalCF
int getRefCount ()
 
void incRefCount ()
 
int decRefCount ()
 

Detailed Description

factory's class for integers

an integer is represented as an mpz_t thempi

See also
InternalRational

Definition at line 55 of file int_int.h.

Constructor & Destructor Documentation

◆ InternalInteger() [1/6]

InternalInteger::InternalInteger ( )
inline

Definition at line 85 of file int_int.h.

85{ mpz_init( thempi ); }

◆ InternalInteger() [2/6]

InternalInteger::InternalInteger ( const InternalCF & )
inline

Definition at line 86 of file int_int.h.

87 {
88 ASSERT( 0, "ups there is something wrong in your code" );
89 }
#define ASSERT(expression, message)
Definition cf_assert.h:99

◆ InternalInteger() [3/6]

InternalInteger::InternalInteger ( const int i)
inline

Definition at line 90 of file int_int.h.

90{ mpz_init_set_si( thempi, (long)i );}
int i
Definition cfEzgcd.cc:132

◆ InternalInteger() [4/6]

InternalInteger::InternalInteger ( const long i)
inline

Definition at line 91 of file int_int.h.

91{ mpz_init_set_si( thempi, i );}

◆ InternalInteger() [5/6]

InternalInteger::InternalInteger ( const char * str,
const int base = 10 )
inline

Definition at line 92 of file int_int.h.

93 { mpz_init_set_str( thempi, str, base ); }

◆ InternalInteger() [6/6]

InternalInteger::InternalInteger ( const mpz_ptr mpi)
inline

Definition at line 94 of file int_int.h.

94{thempi[0]=*mpi;}

◆ ~InternalInteger()

InternalInteger::~InternalInteger ( )
inline

Definition at line 95 of file int_int.h.

95{ mpz_clear( thempi ); }

Member Function Documentation

◆ addcoeff()

InternalCF * InternalInteger::addcoeff ( InternalCF * c)
virtual

Reimplemented from InternalCF.

Definition at line 205 of file int_int.cc.

206{
207 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );
208 long cc = imm2int( c );
209 if ( getRefCount() > 1 )
210 {
211 decRefCount();
212 mpz_t dummy;
213 mpz_init( dummy );
214 if ( cc < 0 )
215 mpz_sub_ui( dummy, thempi, -cc );
216 else
217 mpz_add_ui( dummy, thempi, cc );
218 if ( mpz_is_imm( dummy ) )
219 {
220 InternalCF * res = int2imm( mpz_get_si( dummy ) );
221 mpz_clear( dummy );
222 return res;
223 }
224 else
225 return new InternalInteger( dummy );
226 }
227 else
228 {
229 if ( cc < 0 )
230 mpz_sub_ui( thempi, thempi, -cc );
231 else
232 mpz_add_ui( thempi, thempi, cc );
233 if ( mpz_is_imm( thempi ) )
234 {
235 InternalCF * res = int2imm( mpz_get_si( thempi ) );
236 delete this;
237 return res;
238 }
239 else
240 return this;
241 }
242}
InternalCF()
Definition int_cf.h:55
int getRefCount()
Definition int_cf.h:51
int decRefCount()
Definition int_cf.h:53
bool is_imm() const
Definition int_int.cc:41
CanonicalForm res
Definition facAbsFact.cc:60
bool mpz_is_imm(const mpz_t mpi)
Definition gmpext.h:19
static long imm2int(const InternalCF *const imm)
Definition imm.h:70
const long INTMARK
Definition imm.h:37
static InternalCF * int2imm(long i)
Definition imm.h:75

◆ addsame()

InternalCF * InternalInteger::addsame ( InternalCF * c)
virtual

Reimplemented from InternalCF.

Definition at line 85 of file int_int.cc.

86{
87 if ( getRefCount() > 1 )
88 {
90 mpz_t dummy;
91 mpz_init( dummy );
92 mpz_add( dummy, thempi, MPI( c ) );
93 if ( mpz_is_imm( dummy ) )
94 {
95 InternalCF * res = int2imm( mpz_get_si( dummy ) );
96 mpz_clear( dummy );
97 return res;
98 }
99 else
100 return new InternalInteger( dummy );
101 }
102 else
103 {
104 mpz_add( thempi, thempi, MPI( c ) );
105 if ( mpz_is_imm( thempi ) )
106 {
107 InternalCF * res = int2imm( mpz_get_si( thempi ) );
108 delete this;
109 return res;
110 }
111 else
112 return this;
113 }
114}
static mpz_ptr MPI(const InternalCF *const c)
MPI() - return underlying mpz_t of ‘c’.
Definition int_int.h:252

◆ bextgcdcoeff()

InternalCF * InternalInteger::bextgcdcoeff ( InternalCF * c,
CanonicalForm & a,
CanonicalForm & b )
virtual
See also
CanonicalForm::bextgcd(), InternalInteger::bextgcdsame()

Reimplemented from InternalCF.

Definition at line 464 of file int_int.cc.

465{
466 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );
467
468 // simply return 1 if we are calculating over the rationals
470 {
471 a = 1/CanonicalForm( copyObject() ); b = 0;
472 return int2imm( 1 );
473 }
474
475 long cInt = imm2int( c );
476
477 // trivial cases
478 if ( cInt == 1 || cInt == -1 )
479 {
480 a = 0; b = cInt;
481 return int2imm( 1 );
482 }
483 else if ( cInt == 0 )
484 {
485 a = 1; b = 0;
486 return copyObject();
487 }
488
489 // calculate q and r such that CO = q*cInt + r
490 InternalCF * q = 0, * r = 0;
491 divremcoeff( c, q, r, false );
492
493 // we do not repeat all the code to calculate the gcd of two
494 // immediates. Note that r is an immediate since c != 0, so
495 // we do not have to destroy it. q is destroyed by the
496 // CanonicalForm destructor, hence we do not need to worry
497 // about it, either.
498 CanonicalForm aPrime, bPrime;
499 CanonicalForm result = bextgcd( c, r, aPrime, bPrime );
500 a = bPrime;
501 b = aPrime - CanonicalForm( q ) * bPrime;
502
503 return result.getval();
504}
CanonicalForm bextgcd(const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &a, CanonicalForm &b)
CanonicalForm bextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a,...
CanonicalForm b
Definition cfModGcd.cc:4111
static const int SW_RATIONAL
set to 1 for computations over Q
Definition cf_defs.h:31
INST_VAR CFSwitches cf_glob_switches
bool isOn(int s) const
check if 's' is on
Definition cf_switches.h:55
InternalCF * getval() const
InternalCF * copyObject()
Definition int_cf.h:62
void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool)
return result

◆ bextgcdsame()

InternalCF * InternalInteger::bextgcdsame ( InternalCF * c,
CanonicalForm & a,
CanonicalForm & b )
virtual
See also
CanonicalForm::bextgcd(), InternalInteger::bextgcdcoeff()

Reimplemented from InternalCF.

Definition at line 409 of file int_int.cc.

410{
411 ASSERT( ! ::is_imm( c ) && c->levelcoeff() == IntegerDomain, "incompatible base coefficients" );
412
413 // simply return 1 if we are calculating over the rationals
415 {
416 a = 1/CanonicalForm( copyObject() ); b = 0;
417 return int2imm( 1 );
418 }
419
420 // calculate extended gcd
421 mpz_t result, aMPI, bMPI;
422 mpz_init( result );
423 mpz_init( aMPI );
424 mpz_init( bMPI );
425 mpz_gcdext( result, aMPI, bMPI, thempi, MPI( c ) );
426
427 // check and modify signs
428 if ( mpz_sgn( result ) < 0 )
429 {
430 mpz_neg( result, result );
431 mpz_neg( aMPI, aMPI );
432 mpz_neg( bMPI, bMPI );
433 }
434
435 // postconditioning of result
436 if ( mpz_is_imm( aMPI ) )
437 {
438 a = CanonicalForm( int2imm( mpz_get_si( aMPI ) ) );
439 mpz_clear( aMPI );
440 }
441 else
442 a = CanonicalForm( new InternalInteger( aMPI ) );
443 if ( mpz_is_imm( bMPI ) )
444 {
445 b = CanonicalForm( int2imm( mpz_get_si( bMPI ) ) );
446 mpz_clear( bMPI );
447 }
448 else
449 b = CanonicalForm( new InternalInteger( bMPI ) );
450 if ( mpz_is_imm( result ) )
451 {
452 InternalCF * res = int2imm( mpz_get_si( result ) );
453 mpz_clear( result );
454 return res;
455 }
456 else
457 return new InternalInteger( result );
458}
#define IntegerDomain
Definition cf_defs.h:21
virtual int levelcoeff() const
Definition int_cf.h:68

◆ bgcdcoeff()

InternalCF * InternalInteger::bgcdcoeff ( const InternalCF * const c)
virtual
See also
CanonicalForm::bgcd(), InternalInteger::bgcdsame()

Reimplemented from InternalCF.

Definition at line 377 of file int_int.cc.

378{
379 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );
380
381 // simply return 1 if we are calculating over the rationals
383 return int2imm( 1 );
384
385 long cInt = imm2int( c );
386
387 // trivial cases
388 if ( cInt == 1 || cInt == -1 )
389 return int2imm( 1 );
390 else if ( cInt == 0 )
391 return copyObject();
392
393 // calculate gcd. We need a positive operand since
394 // `mpz_gcd_ui()' operates an unsigned int's only.
395 if ( cInt < 0 ) cInt = -cInt;
396 mpz_t dummy;
397 mpz_init( dummy );
398 // we do not need dummy since we know that cInt != 0
399 cInt = mpz_gcd_ui( dummy, thempi, cInt );
400 mpz_clear( dummy );
401 if ( cInt < 0 ) cInt = -cInt;
402 return int2imm( cInt );
403}

◆ bgcdsame()

InternalCF * InternalInteger::bgcdsame ( const InternalCF * const c) const
virtual
See also
CanonicalForm::bgcd(), InternalInteger::bgcdcoeff()

Reimplemented from InternalCF.

Definition at line 348 of file int_int.cc.

349{
350 ASSERT( ! ::is_imm( c ) && c->levelcoeff() == IntegerDomain, "incompatible base coefficients" );
351
352 // simply return 1 if we are calculating over the rationals
354 return int2imm( 1 );
355
356 // calculate gcd
357 mpz_t result;
358 mpz_init( result );
359 mpz_gcd( result, thempi, MPI( c ) );
360 mpz_abs( result, result );
361
362 // check for immediate result
363 if ( mpz_is_imm( result ) )
364 {
365 InternalCF * res = int2imm( mpz_get_si( result ) );
366 mpz_clear( result );
367 return res;
368 }
369 else
370 return new InternalInteger( result );
371}

◆ classname()

const char * InternalInteger::classname ( ) const
inlinevirtual

Reimplemented from InternalCF.

Definition at line 97 of file int_int.h.

97{ return "InternalInteger"; }

◆ comparecoeff()

int InternalInteger::comparecoeff ( InternalCF * c)
virtual
See also
CanonicalForm::operator <(), CanonicalForm::operator ==(), InternalInteger::comparesame()

Reimplemented from InternalCF.

Definition at line 198 of file int_int.cc.

199{
200 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );
201 return mpz_cmp_si( thempi, imm2int( c ) );
202}

◆ comparesame()

int InternalInteger::comparesame ( InternalCF * c)
virtual
See also
CanonicalForm::operator <(), CanonicalForm::operator ==(), InternalInteger::comparecoeff()

Reimplemented from InternalCF.

Definition at line 188 of file int_int.cc.

189{
190 ASSERT( ! ::is_imm( c ) && c->levelcoeff() == IntegerDomain, "incompatible base coefficients" );
191 return mpz_cmp( thempi, MPI( c ) );
192}

◆ deepCopyObject()

InternalCF * InternalInteger::deepCopyObject ( ) const
virtual

Reimplemented from InternalCF.

Definition at line 18 of file int_int.cc.

19{
20 mpz_t dummy;
21 mpz_init_set( dummy, thempi );
22 return new InternalInteger( dummy );
23}

◆ divcoeff()

InternalCF * InternalInteger::divcoeff ( InternalCF * c,
bool invert )
virtual
See also
CanonicalForm::div(), InternalInteger::divsame()

Reimplemented from InternalCF.

Definition at line 151 of file int_intdiv.cc.

152{
153 ASSERT( ::is_imm( c ) == INTMARK,
154 "type error: immediate integer expected" );
155 ASSERT( invert || imm2int( c ) != 0,
156 "math error: divide by zero" );
157 ASSERT( ! invert || imm2int( c ) == 0,
158 "math error: c does not divide CO" );
159
160 if ( invert ) {
161 if ( deleteObject() ) delete this;
162 // this may happen iff `c' == 0
163 return int2imm( 0 );
164 } else if ( getRefCount() > 1 ) {
165 deleteObject();
166 mpz_t mpiC;
167 mpz_t mpiResult;
168 mpz_init_set_si( mpiC, imm2int( c ) );
169 mpz_init( mpiResult );
170 mpz_divexact( mpiResult, thempi, mpiC );
171 mpz_clear( mpiC );
172 return normalizeMPI( mpiResult );
173 } else {
174 mpz_t mpiC;
175 mpz_init_set_si( mpiC, imm2int( c ) );
176 mpz_divexact( thempi, thempi, mpiC );
177 mpz_clear( mpiC );
178 return normalizeMyself();
179 }
180}
virtual InternalCF * invert()
Definition int_cf.cc:172
int deleteObject()
Definition int_cf.h:61
InternalCF * normalizeMyself()
normalizeMyself(), uiNormalizeMyself() - normalize CO.
Definition int_int.h:172
static InternalCF * normalizeMPI(mpz_ptr)
normalizeMPI(), uiNormalizeMPI() - normalize a mpi.
Definition int_int.h:216

◆ dividecoeff()

InternalCF * InternalInteger::dividecoeff ( InternalCF * c,
bool invert )
virtual
See also
CanonicalForm::operator /(), InternalInteger::dividesame()

Reimplemented from InternalCF.

Definition at line 69 of file int_intdiv.cc.

70{
71 ASSERT( ::is_imm( c ) == INTMARK,
72 "type error: immediate integer expected" );
73 ASSERT( invert || imm2int( c ) != 0,
74 "math error: divide by zero" );
75
76 long intC = imm2int( c );
77
79 mpz_t n, d;
80 if ( invert ) {
81 mpz_init_set_si( n, intC );
82 mpz_init_set( d, thempi );
83 } else {
84 mpz_init_set( n, thempi );
85 mpz_init_set_si( d, intC );
86 }
87 if ( deleteObject() ) delete this;
89 return result->normalize_myself();
90 }
91
92 if ( invert ) {
93 int mpiSign = mpz_sgn( thempi );
94 if ( deleteObject() ) delete this;
95 if ( intC >= 0 )
96 return int2imm( 0 );
97 else
98 return int2imm( -mpiSign );
99 } else if ( getRefCount() > 1 ) {
100 decRefCount();
101 mpz_t mpiResult;
102 mpz_init( mpiResult );
103 if ( intC > 0 )
104 mpz_fdiv_q_ui( mpiResult, thempi, intC );
105 else {
106 mpz_fdiv_q_ui( mpiResult, thempi, -intC );
107 mpz_neg( mpiResult, mpiResult );
108 }
109 return normalizeMPI( mpiResult );
110 } else {
111 if ( intC > 0 )
112 mpz_fdiv_q_ui( thempi, thempi, intC );
113 else {
114 mpz_fdiv_q_ui( thempi, thempi, -intC );
115 mpz_neg( thempi, thempi );
116 }
117 return normalizeMyself();
118 }
119}
friend class InternalRational
Definition int_int.h:149

◆ dividesame()

InternalCF * InternalInteger::dividesame ( InternalCF * c)
virtual
See also
CanonicalForm::operator /(), InternalInteger::dividecoeff()

Reimplemented from InternalCF.

Definition at line 28 of file int_intdiv.cc.

29{
30 ASSERT( ! ::is_imm( c ) && c->levelcoeff() == IntegerDomain,
31 "type error: InternalInteger expected" );
32
33 if ( c == this ) {
34 if ( deleteObject() ) delete this;
35 return int2imm( 1 );
36 }
37
39 mpz_t n, d;
40 mpz_init_set( n, thempi );
41 mpz_init_set( d, MPI( c ) );
42 if ( deleteObject() ) delete this;
44 return result->normalize_myself();
45 }
46
47 if ( getRefCount() > 1 ) {
49 mpz_t mpiResult;
50 mpz_init( mpiResult );
51 if ( mpz_sgn( MPI( c ) ) > 0 )
52 mpz_fdiv_q( mpiResult, thempi, MPI( c ) );
53 else
54 mpz_cdiv_q( mpiResult, thempi, MPI( c ) );
55 return normalizeMPI( mpiResult );
56 } else {
57 if ( mpz_sgn( MPI( c ) ) > 0 )
58 mpz_fdiv_q( thempi, thempi, MPI( c ) );
59 else
60 mpz_cdiv_q( thempi, thempi, MPI( c ) );
61 return normalizeMyself();
62 }
63}

◆ divremcoeff()

void InternalInteger::divremcoeff ( InternalCF * c,
InternalCF *& quot,
InternalCF *& rem,
bool invert )
virtual
See also
CanonicalForm::divrem(), InternalInteger::divremsame()

Reimplemented from InternalCF.

Definition at line 308 of file int_intdiv.cc.

309{
310 ASSERT( ::is_imm( c ) == INTMARK,
311 "type error: immediate integer expected" );
312 ASSERT( invert || imm2int( c ) != 0,
313 "math error: divide by zero" );
314
315 long intC = imm2int( c );
316
318 mpz_t n, d;
319 if ( invert ) {
320 mpz_init_set_si( n, intC );
321 mpz_init_set( d, thempi );
322 } else {
323 mpz_init_set( n, thempi );
324 mpz_init_set_si( d, intC );
325 }
327 quot = result->normalize_myself();
328 rem = int2imm( 0 );
329 return;
330 }
331
332 if ( invert ) {
333 if ( intC >= 0 ) {
334 rem = c;
335 quot = int2imm( 0 );
336 } else {
337 mpz_t mpiResult;
338 mpz_init_set( mpiResult, thempi );
339 mpz_abs( mpiResult, mpiResult );
340 mpz_sub_ui( mpiResult, mpiResult, -intC );
341 rem = uiNormalizeMPI( mpiResult );
342 quot = int2imm( -mpz_sgn( thempi ) );
343 }
344 } else {
345 mpz_t q;
346 mpz_t dummy;
347 mpz_init( q ); mpz_init( dummy );
348 if ( intC > 0 ) {
349 rem = int2imm( mpz_fdiv_qr_ui( q, dummy, thempi, intC ) );
350 quot = normalizeMPI( q );
351 } else {
352 rem = int2imm( mpz_fdiv_qr_ui( q, dummy, thempi, -intC ) );
353 mpz_neg( q, q );
354 quot = normalizeMPI( q );
355 }
356 mpz_clear( dummy );
357 }
358}
static InternalCF * uiNormalizeMPI(mpz_ptr)
‘uiNormalizeMPI()’ is the same as ‘normalizeMPI()’ except that ‘aMpi’ is expected to be non-begative.
Definition int_int.h:233
void rem(unsigned long *a, unsigned long *q, unsigned long p, int &dega, int degq)
Definition minpoly.cc:572

◆ divremcoefft()

bool InternalInteger::divremcoefft ( InternalCF * c,
InternalCF *& quot,
InternalCF *& rem,
bool invert )
virtual
See also
CanonicalForm::divremt(), InternalInteger::divremsamet()

Reimplemented from InternalCF.

Definition at line 374 of file int_intdiv.cc.

375{
376 divremcoeff( c, quot, rem, invert );
377 return true;
378}

◆ divremsame()

void InternalInteger::divremsame ( InternalCF * c,
InternalCF *& quot,
InternalCF *& rem )
virtual
See also
CanonicalForm::divrem(), InternalInteger::divremcoeff()

Reimplemented from InternalCF.

Definition at line 271 of file int_intdiv.cc.

272{
273 ASSERT( ! ::is_imm( c ) && c->levelcoeff() == IntegerDomain,
274 "type error: InternalInteger expected" );
275
276 if ( c == this ) {
277 quot = int2imm( 1 );
278 rem = int2imm( 0 );
279 return;
280 }
281
283 mpz_t n, d;
284 mpz_init_set( n, thempi );
285 mpz_init_set( d, MPI( c ) );
287 quot = result->normalize_myself();
288 rem = int2imm( 0 );
289 return;
290 }
291
292 mpz_t q;
293 mpz_t r;
294 mpz_init( q ); mpz_init( r );
295 if ( mpz_sgn( MPI( c ) ) > 0 )
296 mpz_fdiv_qr( q, r, thempi, MPI( c ) );
297 else
298 mpz_cdiv_qr( q, r, thempi, MPI( c ) );
299
300 quot = normalizeMPI( q );
301 rem = uiNormalizeMPI( r );
302}

◆ divremsamet()

bool InternalInteger::divremsamet ( InternalCF * c,
InternalCF *& quot,
InternalCF *& rem )
virtual
See also
CanonicalForm::divremt(), InternalInteger::divremcoefft()

Reimplemented from InternalCF.

Definition at line 364 of file int_intdiv.cc.

365{
366 divremsame( c, quot, rem );
367 return true;
368}
void divremsame(InternalCF *, InternalCF *&, InternalCF *&)

◆ divsame()

InternalCF * InternalInteger::divsame ( InternalCF * c)
virtual
See also
CanonicalForm::div(), InternalInteger::divcoeff()

Reimplemented from InternalCF.

Definition at line 125 of file int_intdiv.cc.

126{
127 ASSERT( ! ::is_imm( c ) && c->levelcoeff() == IntegerDomain,
128 "type error: InternalInteger expected" );
129
130 if ( c == this ) {
131 if ( deleteObject() ) delete this;
132 return int2imm( 1 );
133 }
134
135 if ( getRefCount() > 1 ) {
136 deleteObject();
137 mpz_t mpiResult;
138 mpz_init( mpiResult );
139 mpz_divexact( mpiResult, thempi, MPI( c ) );
140 return normalizeMPI( mpiResult );
141 } else {
142 mpz_divexact( thempi, thempi, MPI( c ) );
143 return normalizeMyself();
144 }
145}

◆ genOne()

InternalCF * InternalInteger::genOne ( )
virtual

Reimplemented from InternalCF.

Definition at line 54 of file int_int.cc.

55{
56 if ( isOne() )
57 return copyObject();
58 else
59 return new InternalInteger( 1 );
60}
virtual bool isOne() const
bool InternalCF::isOne, isZero () const
Definition int_cf.cc:18

◆ genZero()

InternalCF * InternalInteger::genZero ( )
virtual

Reimplemented from InternalCF.

Definition at line 46 of file int_int.cc.

47{
48 if ( isZero() )
49 return copyObject();
50 else
51 return new InternalInteger();
52}
virtual bool isZero() const
Definition int_cf.cc:24

◆ ilog2()

int InternalInteger::ilog2 ( )
virtual

int InternalInteger::ilog2 ()

See also
CanonicalForm::ilog2()

Reimplemented from InternalCF.

Definition at line 549 of file int_int.cc.

550{
551 ASSERT( mpz_cmp_si( thempi, 0 ) > 0, "log() argument <= 0" );
552 return mpz_sizeinbase( thempi, 2 ) - 1;
553}

◆ intmod()

int InternalInteger::intmod ( int p) const
virtual

Reimplemented from InternalCF.

Definition at line 511 of file int_int.cc.

512{
513 return (int)mpz_fdiv_ui( thempi, (unsigned long)p );
514}
int p
Definition cfModGcd.cc:4086

◆ intval()

long InternalInteger::intval ( ) const
virtual

Reimplemented from InternalCF.

Definition at line 506 of file int_int.cc.

507{
508 return mpz_get_si( thempi );
509}

◆ is_imm()

bool InternalInteger::is_imm ( ) const

Definition at line 41 of file int_int.cc.

42{
43 return mpz_is_imm( thempi );
44}

◆ levelcoeff()

int InternalInteger::levelcoeff ( ) const
inlinevirtual

Reimplemented from InternalCF.

Definition at line 106 of file int_int.h.

106{ return IntegerDomain; }

◆ modcoeff()

InternalCF * InternalInteger::modcoeff ( InternalCF * c,
bool invert )
virtual
See also
see CanonicalForm::mod(), InternalInteger::modsame()

Reimplemented from InternalCF.

Definition at line 262 of file int_intdiv.cc.

263{
264 return modulocoeff( c, invert );
265}
InternalCF * modulocoeff(InternalCF *, bool)

◆ modsame()

InternalCF * InternalInteger::modsame ( InternalCF * c)
virtual
See also
see CanonicalForm::mod(), InternalInteger::modcoeff()

Reimplemented from InternalCF.

Definition at line 253 of file int_intdiv.cc.

254{
255 return modulosame( c );
256}
InternalCF * modulosame(InternalCF *)

◆ modulocoeff()

InternalCF * InternalInteger::modulocoeff ( InternalCF * c,
bool invert )
virtual
See also
CanonicalForm::operator %(), InternalInteger::modulosame()

Reimplemented from InternalCF.

Definition at line 212 of file int_intdiv.cc.

213{
214 ASSERT( ::is_imm( c ) == INTMARK,
215 "type error: immediate integer expected" );
216 ASSERT( invert || imm2int( c ) != 0,
217 "math error: divide by zero" );
218
220 if ( deleteObject() ) delete this;
221 return int2imm( 0 );
222 }
223
224 long intC = imm2int( c );
225
226 if ( invert ) {
227 if ( intC >= 0 ) {
228 if ( deleteObject() ) delete this;
229 return c;
230 } else {
231 // no checks for refCount == 1 are done. It is not worth ...
232 mpz_t mpiResult;
233 mpz_init_set( mpiResult, thempi );
234 mpz_abs( mpiResult, mpiResult );
235 mpz_sub_ui( mpiResult, mpiResult, -intC );
236 if ( deleteObject() ) delete this;
237 return uiNormalizeMPI( mpiResult );
238 }
239 } else {
240 mpz_t dummy;
241 mpz_init( dummy );
242 InternalCF * result = int2imm( mpz_mod_ui( dummy, thempi, tabs( intC ) ) );
243 mpz_clear( dummy );
244 if ( deleteObject() ) delete this;
245 return result;
246 }
247}
int tabs
Definition checklibs.c:11

◆ modulosame()

InternalCF * InternalInteger::modulosame ( InternalCF * c)
virtual
See also
CanonicalForm::operator %(), InternalInteger::modulocoeff()

Reimplemented from InternalCF.

Definition at line 186 of file int_intdiv.cc.

187{
188 ASSERT( ! ::is_imm( c ) && c->levelcoeff() == IntegerDomain,
189 "type error: InternalInteger expected" );
190
191 if ( (c == this) || cf_glob_switches.isOn( SW_RATIONAL ) ) {
192 if ( deleteObject() ) delete this;
193 return int2imm( 0 );
194 }
195
196 if ( getRefCount() > 1 ) {
197 decRefCount();
198 mpz_t mpiResult;
199 mpz_init( mpiResult );
200 mpz_mod( mpiResult, thempi, MPI( c ) );
201 return uiNormalizeMPI( mpiResult );
202 } else {
203 mpz_mod( thempi, thempi, MPI( c ) );
204 return uiNormalizeMyself();
205 }
206}
InternalCF * uiNormalizeMyself()
‘uiNormalizeMyself()’ is the same as ‘normalizeMyself()’ except that CO is expected to be non-negativ...
Definition int_int.h:194

◆ MPI()

mpz_ptr InternalInteger::MPI ( const InternalCF *const c)
inlinestaticprivate

MPI() - return underlying mpz_t of ‘c’.

‘c’ is expected to be an ‘InternalInteger *’. `c's underlying mpz_t is returned.

Definition at line 252 of file int_int.h.

253{
254 return (((InternalInteger*)c)->thempi);
255}

◆ mulcoeff()

InternalCF * InternalInteger::mulcoeff ( InternalCF * c)
virtual

Reimplemented from InternalCF.

Definition at line 299 of file int_int.cc.

300{
301 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );
302 long cc = imm2int( c );
303 if ( getRefCount() > 1 )
304 {
305 decRefCount();
306 mpz_t dummy;
307 mpz_init( dummy );
308 if ( cc < 0 )
309 {
310 mpz_mul_ui( dummy, thempi, -cc );
311 mpz_neg( dummy, dummy );
312 }
313 else
314 mpz_mul_ui( dummy, thempi, cc );
315 if ( mpz_is_imm( dummy ) )
316 {
317 InternalCF * res = int2imm( mpz_get_si( dummy ) );
318 mpz_clear( dummy );
319 return res;
320 }
321 else
322 return new InternalInteger( dummy );
323 }
324 else
325 {
326 if ( cc < 0 )
327 {
328 mpz_mul_ui( thempi, thempi, -cc );
329 mpz_neg( thempi, thempi );
330 }
331 else
332 mpz_mul_ui( thempi, thempi, cc );
333 if ( mpz_is_imm( thempi ) )
334 {
335 InternalCF * res = int2imm( mpz_get_si( thempi ) );
336 delete this;
337 return res;
338 }
339 else
340 return this;
341 }
342}

◆ mulsame()

InternalCF * InternalInteger::mulsame ( InternalCF * c)
virtual

Reimplemented from InternalCF.

Definition at line 147 of file int_int.cc.

148{
149 if ( getRefCount() > 1 )
150 {
151 decRefCount();
152 mpz_t dummy;
153 mpz_init( dummy );
154 mpz_mul( dummy, thempi, MPI( c ) );
155 #if 0
156 if ( mpz_is_imm( dummy ) )
157 {
158 // can this happen ???
159 InternalCF * res = int2imm( mpz_get_si( dummy ) );
160 mpz_clear( dummy );
161 return res;
162 }
163 else
164 #endif
165 return new InternalInteger( dummy );
166 }
167 else
168 {
169 mpz_mul( thempi, thempi, MPI( c ) );
170 #if 0
171 if ( mpz_is_imm( &thempi ) )
172 {
173 // can this happen ???
174 InternalCF * res = int2imm( mpz_get_si( &thempi ) );
175 delete this;
176 return res;
177 }
178 else
179 #endif
180 return this;
181 }
182}

◆ neg()

InternalCF * InternalInteger::neg ( )
virtual

InternalCF * InternalInteger::neg ()

See also
CanonicalForm::operator -()

Reimplemented from InternalCF.

Definition at line 66 of file int_int.cc.

67{
68 if ( getRefCount() > 1 )
69 {
71 mpz_t dummy;
72 mpz_init_set( dummy, thempi );
73 mpz_neg( dummy, dummy );
74 return new InternalInteger( dummy );
75 }
76 else
77 {
78 mpz_neg( thempi, thempi );
79 return this;
80 }
81}

◆ normalizeMPI()

InternalCF * InternalInteger::normalizeMPI ( mpz_ptr aMpi)
inlinestaticprivate

normalizeMPI(), uiNormalizeMPI() - normalize a mpi.

If ‘aMpi’ fits into an immediate integer, clear ‘aMpi’ and return the immediate. Otherwise, return a new ‘InternalInteger’ with ‘aMpi’ as underlying mpi.

Definition at line 216 of file int_int.h.

217{
218 if ( mpz_is_imm( aMpi ) ) {
219 InternalCF * result = int2imm( mpz_get_si( aMpi ) );
220 mpz_clear( aMpi );
221 return result;
222 } else
223 return new InternalInteger( aMpi );
224}

◆ normalizeMyself()

InternalCF * InternalInteger::normalizeMyself ( )
inlineprivate

normalizeMyself(), uiNormalizeMyself() - normalize CO.

If CO fits into an immediate integer, delete CO and return the immediate. Otherwise, return a pointer to CO.

Note: We do not mind reference counting at this point! CO is deleted unconditionally!

Definition at line 172 of file int_int.h.

173{
174 ASSERT( getRefCount() == 1, "internal error: must not delete CO" );
175
176 if ( mpz_is_imm( thempi ) ) {
177 InternalCF * result = int2imm( mpz_get_si( thempi ) );
178 delete this;
179 return result;
180 } else
181 return this;
182}

◆ operator delete()

void InternalInteger::operator delete ( void * addr,
size_t  )
inline

Definition at line 79 of file int_int.h.

80 {
82 }
static const omBin InternalInteger_bin
Definition int_int.h:69
#define omFreeBin(addr, bin)

◆ operator new()

void * InternalInteger::operator new ( size_t )
inline

Definition at line 73 of file int_int.h.

74 {
75 void* addr;
77 return addr;
78 }
#define omTypeAllocBin(type, addr, bin)

◆ print()

void InternalInteger::print ( OSTREAM & os,
char * c )
virtual

Reimplemented from InternalCF.

Definition at line 26 of file int_int.cc.

27{
28 if ( *c == '*' && mpz_cmp_si( thempi, 1 ) == 0 )
29 os << c+1;
30 else if ( *c == '*' && mpz_cmp_si( thempi, -1 ) == 0 )
31 os << '-' << c+1;
32 else {
33 char * str = new char[mpz_sizeinbase( thempi, 10 ) + 2];
34 str = mpz_get_str( str, 10, thempi );
35 os << str << c;
36 delete [] str;
37 }
38}
char * str(leftv arg)
Definition shared.cc:699

◆ sign()

int InternalInteger::sign ( ) const
virtual

int InternalInteger::sign () const

See also
CanonicalForm::sign()

Reimplemented from InternalCF.

Definition at line 520 of file int_int.cc.

521{
522 return mpz_sgn( thempi );
523}

◆ sqrt()

InternalCF * InternalInteger::sqrt ( )
virtual

InternalCF * InternalInteger::sqrt ()

See also
CanonicalForm::sqrt()

Reimplemented from InternalCF.

Definition at line 529 of file int_int.cc.

530{
531 ASSERT( mpz_cmp_si( thempi, 0 ) >= 0, "sqrt() argument < 0" );
532 mpz_t result;
533 mpz_init( result );
534 mpz_sqrt( result, thempi );
535 if ( mpz_is_imm( result ) )
536 {
537 InternalCF * res = int2imm( mpz_get_si( result ) );
538 mpz_clear( result );
539 return res;
540 }
541 else
542 return new InternalInteger( result );
543}

◆ subcoeff()

InternalCF * InternalInteger::subcoeff ( InternalCF * c,
bool negate )
virtual

Reimplemented from InternalCF.

Definition at line 244 of file int_int.cc.

245{
246 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );
247 long cc = imm2int( c );
248 if ( getRefCount() > 1 )
249 {
250 decRefCount();
251 mpz_t dummy;
252 if ( negate )
253 {
254 mpz_init_set_si( dummy, cc );
255 mpz_sub( dummy, dummy, thempi );
256 }
257 else
258 {
259 mpz_init( dummy );
260 if ( cc < 0 )
261 mpz_add_ui( dummy, thempi, -cc );
262 else
263 mpz_sub_ui( dummy, thempi, cc );
264 }
265 if ( mpz_is_imm( dummy ) )
266 {
267 InternalCF * res = int2imm( mpz_get_si( dummy ) );
268 mpz_clear( dummy );
269 return res;
270 }
271 else
272 return new InternalInteger( dummy );
273 }
274 else
275 {
276 if ( negate )
277 {
278 mpz_t dummy;
279 mpz_init_set_si( dummy, cc );
280 mpz_sub( thempi, dummy, thempi );
281 mpz_clear( dummy );
282 }
283 else
284 if ( cc < 0 )
285 mpz_add_ui( thempi, thempi, -cc );
286 else
287 mpz_sub_ui( thempi, thempi, cc );
288 if ( mpz_is_imm( thempi ) )
289 {
290 InternalCF * res = int2imm( mpz_get_si( thempi ) );
291 delete this;
292 return res;
293 }
294 else
295 return this;
296 }
297}

◆ subsame()

InternalCF * InternalInteger::subsame ( InternalCF * c)
virtual

Reimplemented from InternalCF.

Definition at line 116 of file int_int.cc.

117{
118 if ( getRefCount() > 1 )
119 {
120 decRefCount();
121 mpz_t dummy;
122 mpz_init( dummy );
123 mpz_sub( dummy, thempi, MPI( c ) );
124 if ( mpz_is_imm( dummy ) )
125 {
126 InternalCF * res = int2imm( mpz_get_si( dummy ) );
127 mpz_clear( dummy );
128 return res;
129 }
130 else
131 return new InternalInteger( dummy );
132 }
133 else
134 {
135 mpz_sub( thempi, thempi, MPI( c ) );
136 if ( mpz_is_imm( thempi ) )
137 {
138 InternalCF * res = int2imm( mpz_get_si( thempi ) );
139 delete this;
140 return res;
141 }
142 else
143 return this;
144 }
145}

◆ uiNormalizeMPI()

InternalCF * InternalInteger::uiNormalizeMPI ( mpz_ptr aMpi)
inlinestaticprivate

uiNormalizeMPI()’ is the same as ‘normalizeMPI()’ except that ‘aMpi’ is expected to be non-begative.

In this case, we may use ‘mpz_get_ui()’ to convert ‘aMpi’ into an immediate which is slightly faster than the signed variant.

Definition at line 233 of file int_int.h.

234{
235 if ( mpz_is_imm( aMpi ) ) {
236 InternalCF * result = int2imm( mpz_get_ui( aMpi ) );
237 mpz_clear( aMpi );
238 return result;
239 } else
240 return new InternalInteger( aMpi );
241}

◆ uiNormalizeMyself()

InternalCF * InternalInteger::uiNormalizeMyself ( )
inlineprivate

uiNormalizeMyself()’ is the same as ‘normalizeMyself()’ except that CO is expected to be non-negative.

In this case, we may use ‘mpz_get_ui()’ to convert the underlying mpi into an immediate which is slightly faster than the signed variant.

Note: We do not mind reference counting at this point! CO is deleted unconditionally!

Definition at line 194 of file int_int.h.

195{
196 ASSERT( getRefCount() == 1, "internal error: must not delete CO" );
197
198 if ( mpz_is_imm( thempi ) ) {
199 InternalCF * result = int2imm( mpz_get_ui( thempi ) );
200 delete this;
201 return result;
202 } else
203 return this;
204}

Friends And Related Symbol Documentation

◆ convertCF2Fmpq

void convertCF2Fmpq ( fmpq_t result,
const CanonicalForm & f )
friend

conversion of a factory rationals to fmpq_t

Parameters
result[in,out] an fmpq_t
[in]fa CanonicalForm wrapping a rational

Definition at line 220 of file FLINTconvert.cc.

221{
222 //ASSERT (isOn (SW_RATIONAL), "expected rational");
223 if (f.isImm ())
224 {
225 fmpq_set_si(result, f.intval(), 1);
226 }
227 else if(f.inQ())
228 {
229 InternalCF *fi=f.getval();
230 if (fi->levelcoeff() == RationalDomain)
231 {
232 fmpz_set_mpz(fmpq_numref(result), InternalRational::MPQNUM( fi ));
233 fmpz_set_mpz(fmpq_denref(result), InternalRational::MPQDEN( fi ));
234 }
235 else
236 {
237 mpz_t gmp_val;
238 gmp_numerator (f, gmp_val);
239 fmpz_set_mpz (fmpq_numref (result), gmp_val);
240 mpz_clear (gmp_val);
241 gmp_denominator (f, gmp_val);
242 fmpz_set_mpz (fmpq_denref (result), gmp_val);
243 mpz_clear (gmp_val);
244 }
245 fi->deleteObject();
246 }
247 else if(f.inZ()) /* and not isImm() */
248 {
249 InternalInteger *fi=(InternalInteger*)f.getval();
250 fmpz_set_mpz (fmpq_numref (result), fi->thempi);
251 fmpz_one(fmpq_denref(result));
252 fi->deleteObject();
253 }
254 else
255 {
256 printf("wrong type\n");
257 }
258}
#define RationalDomain
Definition cf_defs.h:20
FILE * f
Definition checklibs.c:9
friend void gmp_denominator(const CanonicalForm &f, mpz_ptr result)
Definition singext.cc:40
friend void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition singext.cc:20
static mpz_ptr MPQDEN(const InternalCF *const c)
Definition int_rat.h:143
static mpz_ptr MPQNUM(const InternalCF *const c)
Definition int_rat.h:138

◆ convertCF2Fmpz

void convertCF2Fmpz ( fmpz * ,
const CanonicalForm &  )
friend

◆ convertCF2initFmpz

void convertCF2initFmpz ( fmpz_t result,
const CanonicalForm & f )
friend

conversion of a factory integer to fmpz_t(init.)

Parameters
result[in,out] an fmpz_t
[in]fa CanonicalForm wrapping an integer

Definition at line 133 of file FLINTconvert.cc.

134{
135 if (f.isImm())
136 fmpz_set_si (result, f.intval());
137 else
138 {
139 InternalInteger *fi=(InternalInteger*)f.getval();
140 mpz_set(_fmpz_promote(result),fi->thempi);
141 _fmpz_demote_val(result);
142 fi->deleteObject();
143 }
144}

◆ getmpi

void getmpi ( InternalCF * value,
mpz_t mpi )
friend

Definition at line 303 of file cf_factory.cc.

304{
305 ASSERT( ! is_imm( value ) && (value->levelcoeff() == IntegerDomain || value->levelcoeff() == PrimePowerDomain), "illegal operation" );
306 mpz_init_set (mpi, ((InternalInteger*)value)->thempi);
307}
#define PrimePowerDomain
Definition cf_defs.h:17

◆ gmp_denominator

void gmp_denominator ( const CanonicalForm & f,
mpz_ptr result )
friend

Definition at line 40 of file singext.cc.

41{
42 InternalCF * ff = f.getval();
43 ASSERT( ! is_imm( ff ), "illegal type" );
44 if ( ff->levelcoeff() == IntegerDomain )
45 {
46 mpz_init_set_si( result, 1 );
47 ff->deleteObject();
48 }
49 else if ( ff->levelcoeff() == RationalDomain )
50 {
51 mpz_init_set( result, (InternalRational::MPQDEN( ff )) );
52 ff->deleteObject();
53 }
54 else
55 {
56 ASSERT( 0, "illegal type" );
57 }
58}

◆ gmp_numerator

void gmp_numerator ( const CanonicalForm & f,
mpz_ptr result )
friend

Definition at line 20 of file singext.cc.

21{
22 InternalCF * ff = f.getval();
23 ASSERT( ! is_imm( ff ), "illegal type" );
24 if ( ff->levelcoeff() == IntegerDomain )
25 {
26 mpz_init_set( result, (InternalInteger::MPI( ff )) );
27 ff->deleteObject();
28 }
29 else if ( ff->levelcoeff() == RationalDomain )
30 {
31 mpz_init_set( result, (InternalRational::MPQNUM( ff )) );
32 ff->deleteObject();
33 }
34 else
35 {
36 ASSERT( 0, "illegal type" );
37 }
38}

◆ InternalRational

friend class InternalRational
friend

Definition at line 149 of file int_int.h.

Field Documentation

◆ InternalInteger_bin

const omBin InternalInteger::InternalInteger_bin = omGetSpecBin(sizeof(InternalInteger))
staticprivate

Definition at line 69 of file int_int.h.

◆ thempi

mpz_t InternalInteger::thempi
private

Definition at line 58 of file int_int.h.


The documentation for this class was generated from the following files: