Go to the documentation of this file.
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) {
std::istream & operator>>(std::istream &is, Rational &a)
Input operator.
constexpr Rational numeric2rational(Numeric x, size_t maxdec=4)
Rational from Numeric.
constexpr Rational operator%(const Rational a, const Rational b)
Remainder.
constexpr Index toIndex(int n=1) const
Converts the value to index by n-scaled division.
constexpr bool operator!=(Rational a, Rational b)
Inequality.
Rational & operator-=(const Rational &a)
Remove from this.
constexpr bool operator!(const Rational a)
Not.
Rational & operator++()
Add one if possible.
constexpr Rational operator++(int) const
Add one if possible.
Rational & operator+=(const Rational &a)
Add to this.
constexpr bool isDefined() const
Is the object defined.
Rational & operator*=(const Index &a)
Multiply by this.
constexpr Rational operator/(const Rational a, const Rational b)
Division.
constexpr Rational & fixSign()
Makes the sign of mdenom positive.
constexpr bool operator==(const Rational a, const Rational b)
Equality.
constexpr Rational reduce_by_gcd(const Rational a)
Returns the rational reduced by the greates.
constexpr Index Nom() const
Nominator.
This file contains the definition of Array.
constexpr bool operator<(Rational a, Rational b)
Less than.
Numeric sqrt(const Rational r)
Square root.
constexpr bool operator>=(const Rational a, const Rational b)
More than or equal to.
bifstream & read(bifstream &bif)
Binary read for Rational.
constexpr bool operator<=(Rational a, Rational b)
Less than or equal to.
This can be used to make arrays out of anything.
Numeric pow(const Rational base, Numeric exp)
Power of.
Index & Denom()
Denominator.
void simplify_in_place()
Simplify by reducing the values locally.
void Nom(Index x)
Nominator.
Rational & operator-=(const Index &a)
Remove from this.
std::ostream & operator<<(std::ostream &os, const Rational &a)
Output operator.
constexpr bool even(const Rational r)
Returns true if even integer.
constexpr Numeric toNumeric() const
Converts this to a Numeric.
constexpr Rational operator--(int) const
Remove one if possible.
constexpr int toInt(int n=1) const
Converts the value to int by n-scaled division in Index form.
constexpr Rational max(const Rational a, const Rational b)
Maximum.
constexpr bool operator>(Rational a, Rational b)
More than.
NUMERIC Numeric
The type to use for all floating point numbers.
Binary output file stream class.
constexpr Rational operator+(const Rational a)
Positive.
Rational & operator/=(const Rational &a)
Divide by this.
constexpr Index Denom() const
Denominator.
constexpr Rational operator-(const Rational a)
Negative.
This file contains the class declaration of bifstream.
This file contains the class declaration of bofstream.
void Denom(Index x)
Denominator.
Rational & operator/=(const Index &a)
Divide by this.
Array< Rational > ArrayOfRational
constexpr Rational abs(const Rational a)
Absolute.
Numeric fac(const Rational r)
Factorial.
constexpr bool isIndex(int n=1) const
Is the object a n-scaled Index.
constexpr bool isUndefined() const
Is the object not defined.
constexpr Rational operator*(const Rational a, const Rational b)
Multiplication.
Vector x(Workspace &ws) noexcept
INDEX Index
The type to use for all integer numbers and indices.
Rational & operator+=(const Index &a)
Add to this.
constexpr Rational(const Index nom=0, const Index denom=1)
Initialization call.
Implements rational numbers to work with other ARTS types.
bofstream & write(bofstream &bof) const
Binary write for Rational.
Rational & operator--()
Remove one if possible.
Binary output file stream class.
constexpr Index gcd(Index a, Index b)
Returns the greatest common denominator of two numbers.
Rational & operator*=(const Rational &a)
Multiply by this.