Go to the source code of this file.
|
Rational | operator- (const Rational &r) |
|
bool | operator< (const Rational &a, const Rational &b) |
|
bool | operator<= (const Rational &a, const Rational &b) |
|
bool | operator> (const Rational &a, const Rational &b) |
|
bool | operator>= (const Rational &a, const Rational &b) |
|
bool | operator== (const Rational &a, const Rational &b) |
|
bool | operator!= (const Rational &a, const Rational &b) |
|
Rational | operator+ (const Rational &a, const Rational &b) |
|
Rational | operator- (const Rational &a, const Rational &b) |
|
Rational | operator* (const Rational &a, const Rational &b) |
|
Rational | pow (const Rational &a, int e) |
|
Rational | operator/ (const Rational &a, const Rational &b) |
|
int | sgn (const Rational &a) |
|
Rational | abs (const Rational &a) |
|
Rational | gcd (const Rational &a, const Rational &b) |
|
Rational | gcd (Rational *a, int n) |
|
Rational | lcm (const Rational &a, const Rational &b) |
|
Rational | lcm (Rational *a, int n) |
|
◆ GMPRAT_CC
◆ abs()
Definition at line 436 of file GMPrat.cc.
437{
439 erg;
440
441 if (mpq_sgn(a.
p->
rat)<0)
443 else
445 return erg;
446}
◆ gcd() [1/2]
Definition at line 448 of file GMPrat.cc.
449{
450 if( a == 0 )
451 {
453 {
455 }
456 else
457 {
459 }
460 }
462 {
464 }
465
467
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 ) );
472
473
474
476}
Rational abs(const Rational &a)
◆ gcd() [2/2]
Definition at line 478 of file GMPrat.cc.
479{
480 if( n == 1 )
481 {
482 return a[0];
483 }
484
486
487 for(
int i=2;
i<n;
i++ )
488 {
490 }
491
493}
Rational gcd(const Rational &a, const Rational &b)
◆ lcm() [1/2]
Definition at line 495 of file GMPrat.cc.
496{
497 if( a == 0 )
498 {
500 }
502 {
503 return a;
504 }
505
507}
◆ lcm() [2/2]
Definition at line 509 of file GMPrat.cc.
510{
511 if( n == 1 )
512 {
513 return a[0];
514 }
515
517
518 for(
int i=2;
i<n;
i++ )
519 {
521 }
522
524}
Rational lcm(const Rational &a, const Rational &b)
◆ operator!=()
Definition at line 318 of file GMPrat.cc.
319{
320 if (mpq_equal(a.
p->
rat,
b.p->rat))
return false;
321 return true;
322}
◆ operator*()
Definition at line 403 of file GMPrat.cc.
404{
406 erg(a);
407
409}
◆ operator+()
Definition at line 385 of file GMPrat.cc.
386{
388 erg(a);
389
391}
◆ operator-() [1/2]
Definition at line 394 of file GMPrat.cc.
395{
397 erg(a);
398
400}
◆ operator-() [2/2]
Definition at line 187 of file GMPrat.cc.
188{
190
192 return erg;
193}
◆ operator/()
Definition at line 422 of file GMPrat.cc.
423{
425 erg(a);
426
428}
◆ operator<()
Definition at line 288 of file GMPrat.cc.
289{
290 if (mpq_cmp(a.
p->
rat,
b.p->rat)<0)
return true;
291 return false;
292}
◆ operator<=()
Definition at line 294 of file GMPrat.cc.
295{
296 if (mpq_cmp(a.
p->
rat,
b.p->rat)>0)
return false;
297 return true;
298}
◆ operator==()
Definition at line 312 of file GMPrat.cc.
313{
314 if (mpq_equal(a.
p->
rat,
b.p->rat))
return true;
315 return false;
316}
◆ operator>()
Definition at line 300 of file GMPrat.cc.
301{
302 if (mpq_cmp(a.
p->
rat,
b.p->rat)>0)
return true;
303 return false;
304}
◆ operator>=()
Definition at line 306 of file GMPrat.cc.
307{
308 if (mpq_cmp(a.
p->
rat,
b.p->rat)<0)
return false;
309 return true;
310}
◆ pow()
Definition at line 411 of file GMPrat.cc.
412{
414
415 for(
int i=0;
i<e;
i++ )
416 {
417 erg *= a;
418 }
419 return erg;
420}
◆ sgn()
Definition at line 430 of file GMPrat.cc.
431{
432 return mpq_sgn(a.
p->
rat);
433}