ARTS
2.3.1285(git:92a29ea9-dirty)
|
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.
Referenced by interpret_stringdata(), parse_a1_br_hitran(), parse_a1_pm_hitran(), parse_a1_s_hitran(), parse_a1_sym_hitran(), parse_a1_x_hitran(), parse_a2_hitran(), parse_a4_hitran(), parse_a5_hitran(), parse_f51_hitran(), parse_space(), postprocess_group1_hitran(), postprocess_group2_hitran(), postprocess_group5_hitran(), postprocess_group6_hitran(), postprocess_group6oh_hitran(), QuantumNumbers::QuantumNumbers(), Rational::Rational(), and update_id().
typedef Array<Rational> ArrayOfRational |
Definition at line 737 of file rational.h.
constexpr bool even | ( | const Rational | r | ) |
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 i, and Rational::Rational().
Referenced by Rational::Rational(), and test_numeric2rational().
constexpr bool operator! | ( | const Rational | a | ) |
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 Rational operator""_2 | ( | unsigned long long int | n | ) |
Returns common operator n/2.
[in] | n | Any positive integer |
Definition at line 744 of file rational.h.
References Rational::Rational().
constexpr Rational operator""_rat | ( | unsigned long long int | n | ) |
Returns common operator n/1.
[in] | n | Any positive integer |
Definition at line 753 of file rational.h.
References Rational::Rational().
Remainder.
Definition at line 507 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Remainder.
Definition at line 520 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Remainder.
Definition at line 530 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Multiplication.
Definition at line 479 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Referenced by operator*().
Multiplication.
Definition at line 489 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
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(), Rational::Nom(), and Rational::Rational().
Addition.
Definition at line 398 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Addition.
Definition at line 408 of file rational.h.
References operator+().
Negative.
Definition at line 368 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Subtraction.
Definition at line 416 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Subtraction.
Definition at line 429 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Subtraction.
Definition at line 439 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Division.
Definition at line 449 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Division.
Definition at line 459 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Division.
Definition at line 469 of file rational.h.
References Rational::Denom(), Rational::Nom(), and Rational::Rational().
Less than.
Definition at line 564 of file rational.h.
References Rational::Denom(), Rational::isDefined(), and Rational::Nom().
Referenced by operator>(), and operator>=().
less
Definition at line 664 of file rational.h.
References Rational::Rational().
less
Definition at line 674 of file rational.h.
References Rational::Rational().
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(), r, and reduce_by_gcd().
Referenced by pow().
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!=().
equal
Definition at line 704 of file rational.h.
References Rational::Rational().
More than.
Definition at line 576 of file rational.h.
References operator<().
Referenced by operator<=().
more
Definition at line 684 of file rational.h.
References Rational::Rational().
more
Definition at line 694 of file rational.h.
References Rational::Rational().
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().
Referenced by pow().
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(), LineShape::SingleSpeciesModel::compute(), LineShape::SingleSpeciesModel::compute_dT(), LineShape::SingleSpeciesModel::compute_dT0(), LineShape::SingleSpeciesModel::compute_dX0(), LineShape::SingleSpeciesModel::compute_dX1(), LineShape::SingleSpeciesModel::compute_dX2(), LineShape::SingleSpeciesModel::compute_dX3(), conti_n2__(), CP98H2OAbsModel(), delanoe_shape_with_derivative(), diameter_maxFromDiameter_volume_equ(), diameter_volume_equFromDiameter_max(), doit_conv_flagLsq(), ELL07WaterDropletAbs(), TelsemAtlas::emis_interp(), fctl_(), g0Earth(), gaussian_response(), get_ppath_cloudvars(), PressureBroadeningData::GetAirAndWaterBroadening(), PressureBroadeningData::GetAirAndWaterBroadening_dForeignExponent(), PressureBroadeningData::GetAirAndWaterBroadening_dForeignGamma(), PressureBroadeningData::GetAirAndWaterBroadening_dForeignPsf(), PressureBroadeningData::GetAirAndWaterBroadening_dSelfExponent(), PressureBroadeningData::GetAirAndWaterBroadening_dSelfGamma(), PressureBroadeningData::GetAirAndWaterBroadening_dSelfPsf(), PressureBroadeningData::GetAirAndWaterBroadening_dWaterExponent(), PressureBroadeningData::GetAirAndWaterBroadening_dWaterGamma(), PressureBroadeningData::GetAirAndWaterBroadening_dWaterPsf(), PressureBroadeningData::GetAirBroadening(), PressureBroadeningData::GetAirBroadening_dForeignExponent(), PressureBroadeningData::GetAirBroadening_dForeignGamma(), PressureBroadeningData::GetAirBroadening_dForeignPsf(), PressureBroadeningData::GetAirBroadening_dSelfExponent(), PressureBroadeningData::GetAirBroadening_dSelfGamma(), PressureBroadeningData::GetHTPAirBroadening(), PressureBroadeningData::GetPressureBroadeningParams_dSelfVMR(), PressureBroadeningData::GetSDAirBroadening(), PressureBroadeningData::GetTestBroadening(), Ho66_CO2_foreign_continuum(), Ho66_CO2_self_continuum(), binistream::ieee_double2float(), binistream::ieee_single2float(), iyIndependentBeamApproximation(), lineshape_doppler(), lon_crossing_3d(), magfield_nk(), 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_MY05(), psd_rain_W16(), psd_snow_F07(), 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().
Power of.
Definition at line 648 of file rational.h.
References operator<<(), operator>>(), pow(), and Rational::toNumeric().
Returns the rational reduced by the greates.
Definition at line 315 of file rational.h.
References Rational::Denom(), gcd(), Rational::Nom(), and Rational::Rational().
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(), faddeeva_algorithm_916(), 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(), hartmann_tran_lineshape(), hui_etal_1978_lineshape(), legendre_poly(), legendre_poly_deriv(), legendre_poly_norm_schmidt(), legendre_poly_norm_schmidt_deriv(), lineshape_doppler(), lineshape_voigt_drayson(), lineshape_voigt_kuntz6(), lon_crossing_3d(), los2xyz(), mc_IWP_cloud_opt_pathCalc(), MCGeneral(), MCIPA(), o2_ecs_wigner_symbol_tran(), o2_makarov2013_reduced_dipole(), psd_cloudice_MH97(), r_crossing_3d(), ran_gaussian(), TelsemAtlas::read(), LineRecord::reduced_magnetic_quadrapole(), Absorption::reduced_magnetic_quadrapole(), refellipsoidForAzimuth(), refellipsoidOrbitPlane(), refr_index_airInfraredEarth(), retrievalErrorsExtract(), LineFunctions::set_faddeeva_algorithm916(), LineFunctions::set_faddeeva_from_full_linemixing(), Linefunctions::set_htp(), LineFunctions::set_htp(), LineFunctions::set_hui_etal_1978(), sphdist(), linalg::std(), test2(), unitl(), vector_angle(), yCalc(), and za_geom2other_point().