ARTS 2.5.10 (git: 2f1c442c)
|
Implements rational numbers to work with other ARTS types. More...
#include <rational.h>
Public Member Functions | |
constexpr | Rational (const Index n=0, const Index d=1) noexcept |
Initialization call. | |
Rational (const String &s) | |
Initialization call. | |
void | simplify_in_place () noexcept |
Simplify by reducing the values locally. | |
constexpr bool | isUndefined () const noexcept |
Is the object not defined. | |
constexpr bool | isDefined () const noexcept |
Is the object defined. | |
constexpr bool | isIndex (int n=1) const noexcept |
Is the object a n-scaled Index. | |
constexpr Index | toIndex (int n=1) const noexcept |
Converts the value to index by n-scaled division. | |
constexpr Numeric | toNumeric () const noexcept |
Converts this to a Numeric. | |
constexpr int | toInt (int n=1) const noexcept |
Converts the value to int by n-scaled division in Index form. | |
constexpr Rational & | operator+= (const Rational &a) noexcept |
Add to this. | |
constexpr Rational & | operator+= (const Index &a) noexcept |
Add to this. | |
constexpr Rational & | operator+= (const int &a) noexcept |
Add to this. | |
constexpr Rational & | operator-= (const Rational &a) noexcept |
Remove from this. | |
constexpr Rational & | operator-= (const Index &a) noexcept |
Remove from this. | |
constexpr Rational & | operator-= (const int &a) noexcept |
Remove from this. | |
constexpr Rational & | operator/= (const Rational &a) noexcept |
Divide by this. | |
constexpr Rational & | operator/= (const Index &a) noexcept |
Divide by this. | |
constexpr Rational & | operator/= (const int &a) noexcept |
Divide by this. | |
constexpr Rational & | operator*= (const Rational &a) noexcept |
Multiply by this. | |
constexpr Rational & | operator*= (const Index &a) noexcept |
Multiply by this. | |
constexpr Rational & | operator*= (const int &a) noexcept |
Multiply by this. | |
constexpr Rational | operator++ (int) const noexcept |
Add one if possible. | |
constexpr Rational | operator-- (int) const noexcept |
Remove one if possible. | |
constexpr Rational & | operator++ () noexcept |
Add one if possible. | |
constexpr Rational & | operator-- () noexcept |
Remove one if possible. | |
constexpr | operator bool () const noexcept |
Cast to bool. | |
constexpr | operator Numeric () const noexcept |
Cast to Numeric. | |
constexpr | operator Index () const noexcept |
Cast to Index. | |
constexpr | operator int () const noexcept |
Cast to int. | |
bifstream & | read (bifstream &bif) |
Binary read for Rational. | |
bofstream & | write (bofstream &bof) const |
Binary write for Rational. | |
constexpr Rational & | fixSign () noexcept |
Makes the sign of denom positive. | |
Public Attributes | |
Index | numer |
Index | denom |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Rational &a) |
std::istream & | operator>> (std::istream &is, Rational &a) |
Implements rational numbers to work with other ARTS types.
Definition at line 43 of file rational.h.
Initialization call.
[in] | nom | Nominator |
[in] | denom | Denominator |
Definition at line 52 of file rational.h.
|
explicit |
Initialization call.
Sets the rational from the string. Formats accepted are
Numeric: 1.234567890 Fraction: 12345/67890 Index: 1234567890
Note that overflow is possible and we do not care to capture it
[in] | s | String of the value |
Definition at line 57 of file rational.cc.
References a, ARTS_USER_ERROR, b, numeric2rational(), and RATIONAL_UNDEFINED.
|
inlineconstexprnoexcept |
Makes the sign of denom positive.
Definition at line 297 of file rational.h.
Referenced by simplify_in_place().
|
inlineconstexprnoexcept |
Is the object defined.
Definition at line 84 of file rational.h.
References isUndefined().
Referenced by isIndex(), and operator bool().
|
inlineconstexprnoexcept |
Is the object a n-scaled Index.
[in] | n | Scale |
Definition at line 92 of file rational.h.
References denom, isDefined(), and numer.
|
inlineconstexprnoexcept |
Is the object not defined.
Definition at line 77 of file rational.h.
References denom.
Referenced by case_b_g_coefficient_o2(), closed_shell_trilinear(), isDefined(), and test43().
|
inlineexplicitconstexprnoexcept |
|
inlineexplicitconstexprnoexcept |
|
inlineexplicitconstexprnoexcept |
|
inlineexplicitconstexprnoexcept |
Multiply by this.
[in] | a | To multiply by |
Definition at line 233 of file rational.h.
|
inlineconstexprnoexcept |
Multiply by this.
[in] | a | To multiply by |
Definition at line 243 of file rational.h.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Divide by this.
[in] | a | To divide by |
Definition at line 202 of file rational.h.
|
inlineconstexprnoexcept |
Divide by this.
[in] | a | To divide by |
Definition at line 212 of file rational.h.
|
noexcept |
Simplify by reducing the values locally.
Definition at line 86 of file rational.cc.
References a, denom, fixSign(), numer, and reduce_by_gcd().
|
inlineconstexprnoexcept |
Converts the value to index by n-scaled division.
Throws a logic error if *this is not an Index
[in] | n | Scale to *this |
Definition at line 103 of file rational.h.
Referenced by lm_hitran_2017::calcw(), operator Index(), Absorption::LineMixing::Makarov2020etal::relaxation_matrix_offdiagonal(), test43(), and toInt().
|
inlineconstexprnoexcept |
Converts the value to int by n-scaled division in Index form.
Throws a logic error if *this is not an Index
[in] | n | Scale to *this |
Definition at line 122 of file rational.h.
References toIndex().
Referenced by is_wigner3_ready(), is_wigner6_ready(), operator int(), and test43().
|
inlineconstexprnoexcept |
Converts this to a Numeric.
Definition at line 111 of file rational.h.
Referenced by operator Numeric(), operator*(), operator+(), operator-(), operator/(), pow(), sqrt(), and test43().
|
friend |
Definition at line 34 of file rational.cc.
|
friend |
Definition at line 45 of file rational.cc.
Index Rational::denom |
Definition at line 45 of file rational.h.
Referenced by fixSign(), isIndex(), isUndefined(), operator*=(), operator++(), operator+=(), operator--(), operator-=(), operator/=(), read(), simplify_in_place(), test43(), toIndex(), toNumeric(), Quantum::Number::Value::Value(), Quantum::Number::value_holder(), and write().
Index Rational::numer |
Definition at line 44 of file rational.h.
Referenced by fixSign(), isIndex(), operator bool(), operator*=(), operator++(), operator+=(), operator--(), operator-=(), operator/=(), read(), simplify_in_place(), test43(), toIndex(), toNumeric(), Quantum::Number::Value::Value(), Quantum::Number::value_holder(), and write().