63 const auto div =
gcd(nom, denom);
138 :
throw std::logic_error(
139 "Rational is not representative of an integer");
247 :
throw std::logic_error(
"Undefined Rational in operator++");
254 :
throw std::logic_error(
"Undefined Rational in operator--");
270 explicit constexpr
operator bool()
const {
281 explicit constexpr
operator int()
const {
return toInt(); }
331 Index nom=0, denom=1;
334 const bool signchange = x < 0;
361 #define RATIONAL_UNDEFINED Rational(0, 0) 724 return a < 0 ? -a : a;
734 return a < b ? b : a;
744 constexpr
Rational operator ""_2(
unsigned long long int n) {
753 constexpr
Rational operator ""_rat(
unsigned long long int n) {
INDEX Index
The type to use for all integer numbers and indices.
constexpr bool operator<=(Rational a, Rational b)
Less than or equal to.
constexpr bool operator==(const Rational a, const Rational b)
Equality.
Rational & operator/=(const Index &a)
Divide by this.
constexpr bool operator>=(const Rational a, const Rational b)
More than or equal to.
constexpr bool operator<(Rational a, Rational b)
Less than.
std::ostream & operator<<(std::ostream &os, const Rational &a)
Output operator.
constexpr Rational operator%(const Rational a, const Rational b)
Remainder.
constexpr bool operator>(Rational a, Rational b)
More than.
Rational & operator+=(const Index &a)
Add to this.
void Denom(Index x)
Denominator.
Rational & operator*=(const Rational &a)
Multiply by this.
constexpr Rational abs(const Rational a)
Absolute.
Index & Denom()
Denominator.
constexpr Index Nom() const
Nominator.
constexpr Rational operator--(int) const
Remove one if possible.
constexpr Rational(const Index nom=0, const Index denom=1)
Initialization call.
bifstream & read(bifstream &bif)
Binary read for Rational.
constexpr Index gcd(Index a, Index b)
Returns the greatest common denominator of two numbers.
constexpr Rational max(const Rational a, const Rational b)
Maximum.
Rational & operator/=(const Rational &a)
Divide by this.
Rational & operator++()
Add one if possible.
Rational & operator+=(const Rational &a)
Add to this.
bofstream & write(bofstream &bof) const
Binary write for Rational.
constexpr Rational reduce_by_gcd(const Rational a)
Returns the rational reduced by the greates.
constexpr Rational & fixSign()
Makes the sign of mdenom positive.
Rational & operator--()
Remove one if possible.
This file contains the definition of Array.
constexpr bool operator!=(Rational a, Rational b)
Inequality.
Array< Rational > ArrayOfRational
constexpr Rational operator*(const Rational a, const Rational b)
Multiplication.
constexpr bool isDefined() const
Is the object defined.
Binary output file stream class.
Implements rational numbers to work with other ARTS types.
This file contains the class declaration of bifstream.
This file contains the class declaration of bofstream.
constexpr Index toIndex(int n=1) const
Converts the value to index by n-scaled division.
constexpr Index Denom() const
Denominator.
Rational & operator-=(const Rational &a)
Remove from this.
NUMERIC Numeric
The type to use for all floating point numbers.
constexpr Rational operator+(const Rational a)
Positive.
std::istream & operator>>(std::istream &is, Rational &a)
Input operator.
constexpr Numeric toNumeric() const
Converts this to a Numeric.
Numeric pow(const Rational base, Numeric exp)
Power of.
This can be used to make arrays out of anything.
Rational & operator-=(const Index &a)
Remove from this.
Numeric fac(const Rational r)
Factorial.
constexpr Rational numeric2rational(Numeric x, size_t maxdec=4)
Rational from Numeric.
constexpr bool isUndefined() const
Is the object not defined.
Binary output file stream class.
constexpr bool operator!(const Rational a)
Not.
Rational & operator*=(const Index &a)
Multiply by this.
constexpr Rational operator/(const Rational a, const Rational b)
Division.
constexpr bool even(const Rational r)
Returns true if even integer.
void Nom(Index x)
Nominator.
constexpr int toInt(int n=1) const
Converts the value to int by n-scaled division in Index form.
constexpr Rational operator-(const Rational a)
Negative.
constexpr bool isIndex(int n=1) const
Is the object a n-scaled Index.
void simplify_in_place()
Simplify by reducing the values locally.
constexpr Rational operator++(int) const
Add one if possible.
Numeric sqrt(const Rational r)
Square root.