pub struct CosmoValue {
pub value: f64,
pub h_dependency: i32,
}Expand description
Cosmological value that contains an explicit h scaling.
Fields§
§value: f64Floating value which is to be scaled by h.
h_dependency: i32Explicit h scaling power. For example, 1 h-1 will have a h_dependency of -1.
Implementations§
Source§impl CosmoValue
impl CosmoValue
Sourcepub fn approx_eq(&self, other: &Self, decimal_place: i32) -> bool
pub fn approx_eq(&self, other: &Self, decimal_place: i32) -> bool
Approximately equal method for a given decimal precision.
Helper method for determining if two CosmoValue are approximately equal. Since units are
only using f64 floating point errors can occur. In addition there are some use cases where
absolute precision is not possible (comparison to other quantities in other works with
different significant figures for example.), Here decimal_place refers to up to what
decimal should be included in the comparison.
h dependency is included in the comparison, so even if the values are within the tolerance, non-equivalent h dependency will result in a “false”.
use astroxide::units::*;
let x = CosmoValue::new(5., -1);
let y = CosmoValue::new(5., -2);
let z = CosmoValue::new(5.0001, -1);
assert!(!x.approx_eq(&y, 9));
assert!(x.approx_eq(&z, 3));Trait Implementations§
Source§impl Clone for CosmoValue
impl Clone for CosmoValue
Source§impl Debug for CosmoValue
impl Debug for CosmoValue
Source§impl Display for CosmoValue
impl Display for CosmoValue
Source§impl Div<CosmoValue> for h
impl Div<CosmoValue> for h
Source§type Output = CosmoValue
type Output = CosmoValue
/ operator.Source§impl<T: UnitLike> Div<T> for CosmoValue
impl<T: UnitLike> Div<T> for CosmoValue
Source§impl Div<h> for CosmoValue
impl Div<h> for CosmoValue
Source§impl Mul<CosmoValue> for h
impl Mul<CosmoValue> for h
Source§type Output = CosmoValue
type Output = CosmoValue
* operator.