pub trait MathematicalOps {
Show 27 methods
// Required methods
fn exp(&self) -> Decimal;
fn checked_exp(&self) -> Option<Decimal>;
fn exp_with_tolerance(&self, tolerance: Decimal) -> Decimal;
fn checked_exp_with_tolerance(&self, tolerance: Decimal) -> Option<Decimal>;
fn powi(&self, exp: i64) -> Decimal;
fn checked_powi(&self, exp: i64) -> Option<Decimal>;
fn powu(&self, exp: u64) -> Decimal;
fn checked_powu(&self, exp: u64) -> Option<Decimal>;
fn powf(&self, exp: f64) -> Decimal;
fn checked_powf(&self, exp: f64) -> Option<Decimal>;
fn powd(&self, exp: Decimal) -> Decimal;
fn checked_powd(&self, exp: Decimal) -> Option<Decimal>;
fn sqrt(&self) -> Option<Decimal>;
fn ln(&self) -> Decimal;
fn checked_ln(&self) -> Option<Decimal>;
fn log10(&self) -> Decimal;
fn checked_log10(&self) -> Option<Decimal>;
fn erf(&self) -> Decimal;
fn norm_cdf(&self) -> Decimal;
fn norm_pdf(&self) -> Decimal;
fn checked_norm_pdf(&self) -> Option<Decimal>;
fn sin(&self) -> Decimal;
fn checked_sin(&self) -> Option<Decimal>;
fn cos(&self) -> Decimal;
fn checked_cos(&self) -> Option<Decimal>;
fn tan(&self) -> Decimal;
fn checked_tan(&self) -> Option<Decimal>;
}
Expand description
Trait exposing various mathematical operations that can be applied using a Decimal. This is only
present when the maths
feature has been enabled.
Required Methods§
sourcefn exp(&self) -> Decimal
fn exp(&self) -> Decimal
The estimated exponential function, ex. Stops calculating when it is within
tolerance of roughly 0.0000002
.
sourcefn checked_exp(&self) -> Option<Decimal>
fn checked_exp(&self) -> Option<Decimal>
The estimated exponential function, ex. Stops calculating when it is within
tolerance of roughly 0.0000002
. Returns None
on overflow.
sourcefn exp_with_tolerance(&self, tolerance: Decimal) -> Decimal
fn exp_with_tolerance(&self, tolerance: Decimal) -> Decimal
The estimated exponential function, ex using the tolerance
provided as a hint
as to when to stop calculating. A larger tolerance will cause the number to stop calculating
sooner at the potential cost of a slightly less accurate result.
sourcefn checked_exp_with_tolerance(&self, tolerance: Decimal) -> Option<Decimal>
fn checked_exp_with_tolerance(&self, tolerance: Decimal) -> Option<Decimal>
The estimated exponential function, ex using the tolerance
provided as a hint
as to when to stop calculating. A larger tolerance will cause the number to stop calculating
sooner at the potential cost of a slightly less accurate result.
Returns None
on overflow.
sourcefn checked_powi(&self, exp: i64) -> Option<Decimal>
fn checked_powi(&self, exp: i64) -> Option<Decimal>
Raise self to the given integer exponent xy returning None
on overflow.
sourcefn checked_powu(&self, exp: u64) -> Option<Decimal>
fn checked_powu(&self, exp: u64) -> Option<Decimal>
Raise self to the given unsigned integer exponent xy returning None
on overflow.
sourcefn checked_powf(&self, exp: f64) -> Option<Decimal>
fn checked_powf(&self, exp: f64) -> Option<Decimal>
Raise self to the given floating point exponent xy returning None
on overflow.
sourcefn powd(&self, exp: Decimal) -> Decimal
fn powd(&self, exp: Decimal) -> Decimal
Raise self to the given Decimal exponent: xy. If exp
is not whole then the approximation
ey*ln(x) is used.
sourcefn checked_powd(&self, exp: Decimal) -> Option<Decimal>
fn checked_powd(&self, exp: Decimal) -> Option<Decimal>
Raise self to the given Decimal exponent xy returning None
on overflow.
If exp
is not whole then the approximation ey*ln(x) is used.
sourcefn sqrt(&self) -> Option<Decimal>
fn sqrt(&self) -> Option<Decimal>
The square root of a Decimal. Uses a standard Babylonian method.
sourcefn ln(&self) -> Decimal
fn ln(&self) -> Decimal
Calculates the natural logarithm for a Decimal calculated using Taylor’s series.
sourcefn checked_ln(&self) -> Option<Decimal>
fn checked_ln(&self) -> Option<Decimal>
Calculates the checked natural logarithm for a Decimal calculated using Taylor’s series.
Returns None
for negative numbers or zero.
sourcefn checked_log10(&self) -> Option<Decimal>
fn checked_log10(&self) -> Option<Decimal>
Calculates the checked base 10 logarithm of a specified Decimal number.
Returns None
for negative numbers or zero.
sourcefn checked_norm_pdf(&self) -> Option<Decimal>
fn checked_norm_pdf(&self) -> Option<Decimal>
The Probability density function for a Normal distribution returning None
on overflow.
sourcefn checked_sin(&self) -> Option<Decimal>
fn checked_sin(&self) -> Option<Decimal>
Computes the checked sine of a number (in radians).
sourcefn checked_cos(&self) -> Option<Decimal>
fn checked_cos(&self) -> Option<Decimal>
Computes the checked cosine of a number (in radians).
sourcefn tan(&self) -> Decimal
fn tan(&self) -> Decimal
Computes the tangent of a number (in radians). Panics upon overflow or upon approaching a limit.
sourcefn checked_tan(&self) -> Option<Decimal>
fn checked_tan(&self) -> Option<Decimal>
Computes the checked tangent of a number (in radians). Returns None on limit.