ARTS
2.4.0(git:4fb77825)
|
Contains the rational class definition. More...
#include <cassert>
#include <ostream>
#include "array.h"
#include "bifstream.h"
#include "bofstream.h"
#include "math_funcs.h"
#include "matpack.h"
Go to the source code of this file.
Classes | |
class | Rational |
Implements rational numbers to work with other ARTS types. More... | |
Macros | |
#define | RATIONAL_UNDEFINED Rational(0, 0) |
Typedefs | |
typedef Array< Rational > | ArrayOfRational |
Functions | |
constexpr Index | gcd (Index a, Index b) |
Returns the greatest common denominator of two numbers. More... | |
constexpr Rational | reduce_by_gcd (const Rational a) |
Returns the rational reduced by the greates. More... | |
constexpr Rational | numeric2rational (Numeric x, size_t maxdec=4) |
Rational from Numeric. More... | |
constexpr Rational | operator- (const Rational a) |
Negative. More... | |
constexpr Rational | operator+ (const Rational a) |
Positive. More... | |
constexpr Rational | operator+ (const Rational a, const Rational b) |
Addition. More... | |
constexpr Rational | operator+ (const Rational a, Index b) |
Addition. More... | |
constexpr Rational | operator+ (Index b, const Rational a) |
Addition. More... | |
constexpr Rational | operator- (const Rational a, const Rational b) |
Subtraction. More... | |
constexpr Rational | operator- (const Rational a, Index b) |
Subtraction. More... | |
constexpr Rational | operator- (Index b, const Rational a) |
Subtraction. More... | |
constexpr Rational | operator/ (const Rational a, const Rational b) |
Division. More... | |
constexpr Rational | operator/ (const Rational a, Index b) |
Division. More... | |
constexpr Rational | operator/ (Index b, const Rational a) |
Division. More... | |
constexpr Rational | operator* (const Rational a, const Rational b) |
Multiplication. More... | |
constexpr Rational | operator* (const Rational a, Index b) |
Multiplication. More... | |
constexpr Rational | operator* (Index b, const Rational a) |
Multiplication. More... | |
constexpr Rational | operator% (const Rational a, const Rational b) |
Remainder. More... | |
constexpr Rational | operator% (const Rational a, Index b) |
Remainder. More... | |
constexpr Rational | operator% (Index b, const Rational a) |
Remainder. More... | |
constexpr bool | operator== (const Rational a, const Rational b) |
Equality. More... | |
constexpr bool | operator!= (Rational a, Rational b) |
Inequality. More... | |
constexpr bool | operator< (Rational a, Rational b) |
Less than. More... | |
constexpr bool | operator> (Rational a, Rational b) |
More than. More... | |
constexpr bool | operator<= (Rational a, Rational b) |
Less than or equal to. More... | |
constexpr bool | operator>= (const Rational a, const Rational b) |
More than or equal to. More... | |
constexpr bool | operator! (const Rational a) |
Not. More... | |
Numeric | fac (const Rational r) |
Factorial. More... | |
Numeric | sqrt (const Rational r) |
Square root. More... | |
Numeric | pow (const Rational base, Numeric exp) |
Power of. More... | |
Numeric | pow (Numeric base, const Rational exp) |
Power of. More... | |
Numeric | pow (const Rational base, const Rational exp) |
Power of. More... | |
std::ostream & | operator<< (std::ostream &os, const Rational &a) |
Output operator. More... | |
std::istream & | operator>> (std::istream &is, Rational &a) |
Input operator. More... | |
constexpr bool | operator< (const Index a, const Rational b) |
less More... | |
constexpr bool | operator< (const Rational a, const Index b) |
less More... | |
constexpr bool | operator> (const Index a, const Rational b) |
more More... | |
constexpr bool | operator> (const Rational a, const Index b) |
more More... | |
constexpr bool | operator== (const Rational a, const Index b) |
equal More... | |
constexpr bool | operator!= (const Rational a, const Index b) |
not equal More... | |
constexpr Rational | abs (const Rational a) |
Absolute. More... | |
constexpr Rational | max (const Rational a, const Rational b) |
Maximum. More... | |
constexpr Rational | operator""_2 (unsigned long long int n) |
Returns common operator n/2. More... | |
constexpr Rational | operator""_rat (unsigned long long int n) |
Returns common operator n/1. More... | |
constexpr bool | even (const Rational r) |
Returns true if even integer. More... | |
#define RATIONAL_UNDEFINED Rational(0, 0) |
Definition at line 361 of file rational.h.
typedef Array<Rational> ArrayOfRational |
Definition at line 737 of file rational.h.
|
constexpr |
Returns true if even integer.
[in] | r | Any rational |
Definition at line 762 of file rational.h.
Referenced by o2_ecs_wigner_symbol_tran(), o2_makarov2013_reduced_dipole(), and Absorption::reduced_magnetic_quadrapole().
Factorial.
Definition at line 613 of file rational.h.
References Rational::toIndex().
Returns the greatest common denominator of two numbers.
[in] | a | number a |
[in] | b | number b |
Definition at line 45 of file rational.h.
Referenced by Rational::Rational(), and reduce_by_gcd().
Rational from Numeric.
Performs basic rounding
[in] | x | Numeric value |
[in] | maxdec | Maximum number of decimals |
Definition at line 330 of file rational.h.
References ARTS::Var::x().
Referenced by Rational::Rational(), and test_numeric2rational().
|
constexpr |
Not.
Definition at line 606 of file rational.h.
References Rational::isDefined(), and Rational::Nom().
Inequality.
Definition at line 553 of file rational.h.
References operator==().
|
constexpr |
Returns common operator n/2.
[in] | n | Any positive integer |
Definition at line 744 of file rational.h.
|
constexpr |
Returns common operator n/1.
[in] | n | Any positive integer |
Definition at line 753 of file rational.h.
Remainder.
Definition at line 507 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Remainder.
Definition at line 520 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Remainder.
Definition at line 530 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Multiplication.
Definition at line 479 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Referenced by operator*().
Multiplication.
Definition at line 489 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Multiplication.
Definition at line 499 of file rational.h.
References operator*().
Positive.
Definition at line 377 of file rational.h.
Referenced by operator+().
Addition.
Definition at line 385 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Addition.
Definition at line 398 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Addition.
Definition at line 408 of file rational.h.
References operator+().
Negative.
Definition at line 368 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Subtraction.
Definition at line 416 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Subtraction.
Definition at line 429 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Subtraction.
Definition at line 439 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Division.
Definition at line 449 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Division.
Definition at line 459 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Division.
Definition at line 469 of file rational.h.
References Rational::Denom(), and Rational::Nom().
Less than.
Definition at line 564 of file rational.h.
References Rational::Denom(), Rational::isDefined(), and Rational::Nom().
Referenced by operator>(), and operator>=().
std::ostream& operator<< | ( | std::ostream & | os, |
const Rational & | a | ||
) |
Output operator.
Definition at line 33 of file rational.cc.
References Rational::Denom(), Rational::fixSign(), Rational::Nom(), and reduce_by_gcd().
Less than or equal to.
Definition at line 585 of file rational.h.
References operator>().
Equality.
Definition at line 541 of file rational.h.
References Rational::Denom(), Rational::isDefined(), and Rational::Nom().
Referenced by operator!=().
More than.
Definition at line 576 of file rational.h.
References operator<().
Referenced by operator<=().
More than or equal to.
Definition at line 596 of file rational.h.
References operator<().
std::istream& operator>> | ( | std::istream & | is, |
Rational & | a | ||
) |
Input operator.
Definition at line 44 of file rational.cc.
References Array< base >::nelem(), and Absorption::nelem().
Power of.
Definition at line 648 of file rational.h.
References pow(), and Rational::toNumeric().
Power of.
Definition at line 628 of file rational.h.
References Rational::toNumeric().
Referenced by abs_lookupSetup(), abs_lookupSetupBatch(), abs_lookupSetupWide(), antenna_responseGaussian(), antenna_responseVaryingGaussian(), BF86_CIA_N2(), cart2poslos(), CKD_mt_250_o2_vis(), CKD_mt_v1v0_o2(), conti_n2__(), CP98H2OAbsModel(), diameter_maxFromDiameter_volume_equ(), diameter_volume_equFromDiameter_max(), doit_conv_flagLsq(), ELL07WaterDropletAbs(), TelsemAtlas::emis_interp(), fctl_(), g0Earth(), gaussian_response(), get_ppath_cloudvars(), Ho66_CO2_foreign_continuum(), Ho66_CO2_self_continuum(), binistream::ieee_double2float(), binistream::ieee_single2float(), iyIndependentBeamApproximation(), MaTipping_H2O_foreign_continuum(), mgd(), mgd_with_derivatives(), mod_gamma_dist(), MPM02H2OAbsModel(), MPM85O2AbsModel(), MPM87H2OAbsModel(), MPM87O2AbsModel(), MPM89H2OAbsModel(), MPM89O2AbsModel(), MPM92O2AbsModel(), MPM93_H2O_continuum(), MPM93_N2_continuum(), MPM93_O2_continuum(), MPM93H2OAbsModel(), MPM93IceCrystalAbs(), MPM93O2AbsModel(), MPM93RainExt(), MPM93WaterDropletAbs(), o2_ecs_ql_makarov(), p_gridRefine(), Pardo_ATM_H2O_ForeignContinuum(), Pardo_ATM_N2_dry_continuum(), PFromZSimple(), polynomial_basis_func(), pow(), psd_cloudice_MH97(), psd_mgd_mass_and_something(), psd_rain_W16(), psdModifiedGammaMass(), PWR93O2AbsModel(), PWR98H2OAbsModel(), refellipsoidForAzimuth(), refellipsoidOrbitPlane(), Rosenkranz_CO2_foreign_continuum(), Rosenkranz_CO2_self_continuum(), Rosenkranz_N2_self_continuum(), Rosenkranz_O2_continuum(), rtmethods_jacobian_finalisation(), Standard_H2O_foreign_continuum(), Standard_H2O_self_continuum(), Standard_N2_self_continuum(), Standard_O2_continuum(), surface_specular_R_and_b(), swv_mpmf87s93__(), test07(), transform_x_back(), TRE05O2AbsModel(), yActive(), and yCalc().
Power of.
Definition at line 638 of file rational.h.
References pow(), and Rational::toNumeric().
Returns the rational reduced by the greates.
Definition at line 315 of file rational.h.
References Rational::Denom(), gcd(), and Rational::Nom().
Referenced by operator<<(), and Rational::simplify_in_place().
Square root.
Definition at line 620 of file rational.h.
References Rational::toNumeric().
Referenced by abs_lookupTestAccMC(), antenna_responseGaussian(), antenna_responseVaryingGaussian(), cart2pol(), cart2poslos(), cart2sph(), cart2zaaa(), case_b_g_coefficient_o2(), cayley_hamilton_fitted_method_4x4_propmat_to_transmat__eigen(), cayley_hamilton_fitted_method_4x4_propmat_to_transmat__explicit(), chk_atm_vecfield_lat90(), complex_n_ice_matzler06(), complex_n_water_liebe93(), compute_transmission_matrix_from_averaged_matrix_at_frequency(), covmat_sxExtractSqrtDiagonal(), distance2D(), distance3D(), doit_conv_flagLsq(), Linefunctions::DopplerConstant(), dotprod_with_los(), MCAntenna::draw_los(), Zeeman::FromGrids(), g_legendre_poly(), g_legendre_poly_deriv(), g_legendre_poly_norm_schmidt(), g_legendre_poly_norm_schmidt_deriv(), g_legendre_poly_norm_schmidt_deriv1(), g_legendre_poly_norm_schmidt_deriv2(), g_legendre_poly_norm_schmidt_deriv3(), g_legendre_poly_norm_schmidt_deriv4(), gaussian_response(), gaussian_response_autogrid(), geompath_l_at_r(), geompath_r_at_l(), geompath_tanpos_3d(), legendre_poly(), legendre_poly_deriv(), legendre_poly_norm_schmidt(), legendre_poly_norm_schmidt_deriv(), los2xyz(), MCGeneral(), o2_ecs_wigner_symbol_tran(), o2_makarov2013_reduced_dipole(), psd_cloudice_MH97(), r_crossing_3d(), ran_gaussian(), TelsemAtlas::read(), Absorption::reduced_magnetic_quadrapole(), refellipsoidForAzimuth(), refellipsoidOrbitPlane(), refr_index_airInfraredEarth(), retrievalErrorsExtract(), Linefunctions::set_htp(), sphdist(), test2(), unitl(), vector_angle(), and yCalc().