#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 54 of file GMPrat.cc.
58 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 78 of file GMPrat.cc.
83 mpq_set_si(
p->
rat,(
long) a,(
unsigned long)
abs(
b));
84 mpq_canonicalize(
p->
rat);
◆ ~Rational()
◆ complexity()
double Rational::complexity |
( |
| ) |
const |
Definition at line 529 of file GMPrat.cc.
531 double num = mpz_get_d( mpq_numref(
p->
rat ) );
532 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 155 of file GMPrat.cc.
157 return mpz_get_si( mpq_denref(
p->
rat ) );
◆ get_num()
◆ get_num_si()
int Rational::get_num_si |
( |
| ) |
|
Definition at line 141 of file GMPrat.cc.
143 return mpz_get_si( mpq_numref(
p->
rat ) );
◆ length()
unsigned int Rational::length |
( |
| ) |
const |
Definition at line 365 of file GMPrat.cc.
367 char *snum = (
char*)
omAlloc(mpz_sizeinbase(mpq_numref(
p->
rat),10)+2);
368 char *sden = (
char*)
omAlloc(mpz_sizeinbase(mpq_denref(
p->
rat),10)+2);
370 snum = mpz_get_str( snum,10,mpq_numref(
p->
rat ) );
371 sden = mpz_get_str( sden,10,mpq_denref(
p->
rat ) );
373 int length = strlen( snum );
375 if( sden[0] !=
'1' || sden[1] !=
'\0' )
length += strlen( sden ) + 1;
◆ operator int()
Rational::operator int |
( |
| ) |
|
Definition at line 164 of file GMPrat.cc.
170 mpz_tdiv_q(
h,mpq_numref(
p->
rat),mpq_denref(
p->
rat));
171 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 451 of file GMPrat.cc.
471 mpz_gcd( mpq_numref( erg.
p->
rat ),
472 mpq_numref( a.
p->
rat ),mpq_numref(
b.p->rat ) );
473 mpz_gcd( mpq_denref( erg.
p->
rat ),
474 mpq_denref( a.
p->
rat ),mpq_denref(
b.p->rat ) );
◆ gcd [2/2]
◆ lcm [1/2]
◆ lcm [2/2]
◆ operator!=
Definition at line 321 of file GMPrat.cc.
323 if (mpq_equal(a.
p->
rat,
b.p->rat))
return false;
◆ operator-
◆ operator<
Definition at line 291 of file GMPrat.cc.
293 if (mpq_cmp(a.
p->
rat,
b.p->rat)<0)
return true;
◆ operator<=
Definition at line 297 of file GMPrat.cc.
299 if (mpq_cmp(a.
p->
rat,
b.p->rat)>0)
return false;
◆ operator==
Definition at line 315 of file GMPrat.cc.
317 if (mpq_equal(a.
p->
rat,
b.p->rat))
return true;
◆ operator>
Definition at line 303 of file GMPrat.cc.
305 if (mpq_cmp(a.
p->
rat,
b.p->rat)>0)
return true;
◆ operator>=
Definition at line 309 of file GMPrat.cc.
311 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: