#include <GMPrat.h>
|
Rational | operator- (const Rational &) |
|
bool | operator< (const Rational &, const Rational &) |
|
bool | operator<= (const Rational &, const Rational &) |
|
bool | operator> (const Rational &, const Rational &) |
|
bool | operator>= (const Rational &, const Rational &) |
|
bool | operator== (const Rational &, const Rational &) |
|
bool | operator!= (const Rational &, const Rational &) |
|
int | sgn (const Rational &) |
|
Rational | abs (const Rational &) |
|
Rational | pow (const Rational &, int) |
|
Rational | gcd (const Rational &, const Rational &) |
|
Rational | lcm (const Rational &, const Rational &) |
|
Rational | gcd (Rational *, int) |
|
Rational | lcm (Rational *, int) |
|
Definition at line 14 of file GMPrat.h.
◆ Rational() [1/5]
◆ Rational() [2/5]
Rational::Rational |
( |
int |
a | ) |
|
Definition at line 51 of file GMPrat.cc.
55 mpq_set_si(
p->
rat,(
long)a,1 );
◆ Rational() [3/5]
◆ Rational() [4/5]
◆ Rational() [5/5]
Rational::Rational |
( |
int |
a, |
|
|
int |
b |
|
) |
| |
Definition at line 75 of file GMPrat.cc.
80 mpq_set_si(
p->
rat,(
long) a,(
unsigned long)
abs(
b));
81 mpq_canonicalize(
p->
rat);
◆ ~Rational()
◆ complexity()
double Rational::complexity |
( |
| ) |
const |
Definition at line 526 of file GMPrat.cc.
528 double num = mpz_get_d( mpq_numref(
p->
rat ) );
529 double den = mpz_get_d( mpq_denref(
p->
rat ) );
◆ disconnect()
void Rational::disconnect |
( |
| ) |
|
|
private |
◆ get_den()
◆ get_den_si()
int Rational::get_den_si |
( |
| ) |
|
Definition at line 152 of file GMPrat.cc.
154 return mpz_get_si( mpq_denref(
p->
rat ) );
◆ get_num()
◆ get_num_si()
int Rational::get_num_si |
( |
| ) |
|
Definition at line 138 of file GMPrat.cc.
140 return mpz_get_si( mpq_numref(
p->
rat ) );
◆ length()
unsigned int Rational::length |
( |
| ) |
const |
Definition at line 362 of file GMPrat.cc.
364 char *snum = (
char*)
omAlloc(mpz_sizeinbase(mpq_numref(
p->
rat),10)+2);
365 char *sden = (
char*)
omAlloc(mpz_sizeinbase(mpq_denref(
p->
rat),10)+2);
367 snum = mpz_get_str( snum,10,mpq_numref(
p->
rat ) );
368 sden = mpz_get_str( sden,10,mpq_denref(
p->
rat ) );
370 int length = strlen( snum );
372 if( sden[0] !=
'1' || sden[1] !=
'\0' )
length += strlen( sden ) + 1;
◆ operator int()
Rational::operator int |
( |
| ) |
|
Definition at line 161 of file GMPrat.cc.
167 mpz_tdiv_q(
h,mpq_numref(
p->
rat),mpq_denref(
p->
rat));
168 ret_val=mpz_get_si(
h);
◆ operator*=()
◆ operator++() [1/2]
◆ operator++() [2/2]
◆ operator+=()
◆ operator-()
◆ operator--() [1/2]
◆ operator--() [2/2]
◆ operator-=()
◆ operator/=()
◆ operator=() [1/3]
Rational& Rational::operator= |
( |
char * |
s | ) |
|
◆ operator=() [2/3]
◆ operator=() [3/3]
◆ operator~()
◆ abs
◆ gcd [1/2]
Definition at line 448 of file GMPrat.cc.
468 mpz_gcd( mpq_numref( erg.
p->
rat ),
469 mpq_numref( a.
p->
rat ),mpq_numref(
b.p->rat ) );
470 mpz_gcd( mpq_denref( erg.
p->
rat ),
471 mpq_denref( a.
p->
rat ),mpq_denref(
b.p->rat ) );
◆ gcd [2/2]
◆ lcm [1/2]
◆ lcm [2/2]
◆ operator!=
Definition at line 318 of file GMPrat.cc.
320 if (mpq_equal(a.
p->
rat,
b.p->rat))
return false;
◆ operator-
◆ operator<
Definition at line 288 of file GMPrat.cc.
290 if (mpq_cmp(a.
p->
rat,
b.p->rat)<0)
return true;
◆ operator<=
Definition at line 294 of file GMPrat.cc.
296 if (mpq_cmp(a.
p->
rat,
b.p->rat)>0)
return false;
◆ operator==
Definition at line 312 of file GMPrat.cc.
314 if (mpq_equal(a.
p->
rat,
b.p->rat))
return true;
◆ operator>
Definition at line 300 of file GMPrat.cc.
302 if (mpq_cmp(a.
p->
rat,
b.p->rat)>0)
return true;
◆ operator>=
Definition at line 306 of file GMPrat.cc.
308 if (mpq_cmp(a.
p->
rat,
b.p->rat)<0)
return false;
◆ pow
◆ sgn
The documentation for this class was generated from the following files: