51 #define __ADS_Rational
69#ifndef ADS_RATIONAL_GMP
70 #define ADS_RATIONAL_GMP ADS_BIGINT_GMP
103#if defined( ADS_WITH_GMP )
107 static Rational fromGmp( mpq_srcptr q );
112 requires requires(
const Q & q ) {
113 { q.get_mpq_t() } -> std::convertible_to< mpq_srcptr >;
119 void toGmp( mpq_ptr q )
const;
124 requires requires( Q & q ) {
125 { q.get_mpq_t() } -> std::convertible_to< mpq_ptr >;
127 [[nodiscard]] Q toGmp(
void )
const {
129 toGmp( q.get_mpq_t() );
194 [[nodiscard]]
bool lowest(
void )
const;
198 static mpq_srcptr gmpView( mpq_t q ,
const Rational & a );
203 void ( *op )( mpq_ptr , mpq_srcptr , mpq_srcptr ) );
222#include "ADS/numeric/impl/Rational.tpp"
The integers of any length of Knuth (4.3.1): a sign and the magnitude as a vector of digits (limbs) i...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
an integer of any length, sign and magnitude in base
Definition BigInteger.h:348
a fraction in lowest terms, the denominator positive
Definition Rational.h:86
friend std::strong_ordering operator<=>(const Rational &a, const Rational &b)
the order of and , by the signs and then by against
friend Rational operator+(const Rational &a, const Rational &b)
the sum , by the gcds of the smaller numbers
friend Rational operator*(const Rational &a, const Rational &b)
the product , by the gcds that cancel crosswise
friend Rational operator/(const Rational &a, const Rational &b)
the quotient , as times the inverse of
const BigInteger & den(void) const
the denominator
Definition Rational.h:98
const BigInteger & num(void) const
the numerator
Definition Rational.h:96
friend bool operator==(const Rational &a, const Rational &b)=default
true if the two fractions are equal, i.e., their terms are
Rational operator-(void) const
the opposite
Rational(BigInteger num=0, BigInteger den=1)
the fraction , brought to lowest terms with a positive denominator by one gcd
friend Rational operator-(const Rational &a, const Rational &b)
the difference , as
std::string toString(void) const
the text u/u', or u when