pub struct RadixFloat { /* private fields */ }Expand description
A floating-point value with an associated parse/format radix.
Implementations§
Source§impl RadixFloat
impl RadixFloat
Sourcepub fn with_radix(value: ExactNum, radix: Radix) -> Self
pub fn with_radix(value: ExactNum, radix: Radix) -> Self
Wraps value with radix without validating the radix (for const radix constants).
Sourcepub fn into_inner(self) -> ExactNum
pub fn into_inner(self) -> ExactNum
Consumes self and returns the inner ExactNum.
Methods from Deref<Target = ExactNum>§
Sourcepub fn to_inline_bytes(&self) -> Result<InlineBinaryBuffer, Error>
pub fn to_inline_bytes(&self) -> Result<InlineBinaryBuffer, Error>
Encode an inlined value into a stack buffer.
Specials always succeed. A finite mantissa wider than
BINARY_INLINE_MANT_BITS returns Error::MemoryAllocation.
Sourcepub fn write_inline_bytes(&self, dest: &mut [u8]) -> Result<usize, Error>
pub fn write_inline_bytes(&self, dest: &mut [u8]) -> Result<usize, Error>
Write the 16-byte inline record into dest.
Returns Error::InvalidArgument if dest is shorter than
BINARY_INLINE_LEN. Wider finite mantissas return
Error::MemoryAllocation.
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>, Error>
pub fn to_bytes(&self) -> Result<Vec<u8>, Error>
Encode self (inline 16 bytes, or a heap record if the mantissa is wider).
Sourcepub fn write_bytes(&self, dest: &mut [u8]) -> Result<usize, Error>
pub fn write_bytes(&self, dest: &mut [u8]) -> Result<usize, Error>
Write the compact record into dest without allocating.
Sourcepub fn normal_pdf(
&self,
mu: &Self,
sigma: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn normal_pdf( &self, mu: &Self, sigma: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Standard-form normal density (\varphi(x;\mu,\sigma)=\exp(-(x-\mu)^2/(2\sigma^2))/(\sigma\sqrt{2\pi})).
sigma ≤ 0 or a non-finite parameter is NaN.
§Precision
- Algorithm:
exp/sqrt/πatp + WORD_BIT_SIZE, then one rounding top. - Bound: working precision
p + WORD_BIT_SIZE. - MPFR oracle: no (composite of existing leaves).
Sourcepub fn normal_cdf(
&self,
mu: &Self,
sigma: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn normal_cdf( &self, mu: &Self, sigma: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Normal CDF (\Phi(x;\mu,\sigma)=(1+\mathrm{erf}((x-\mu)/(\sigma\sqrt{2})))/2).
sigma ≤ 0 is NaN.
§Precision
- Algorithm: existing
erfatp + WORD_BIT_SIZE. - Bound: working precision
p + WORD_BIT_SIZE. - MPFR oracle: no (composite of
erf).
Sourcepub fn gamma_pdf(
&self,
alpha: &Self,
beta: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn gamma_pdf( &self, alpha: &Self, beta: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Gamma density on the scale parameterization (x^{\alpha-1}e^{-x/\beta}/(\beta^\alpha\Gamma(\alpha))).
Requires x ≥ 0, alpha > 0, beta > 0.
§Precision
- Algorithm:
pow/exp/gammaatp + WORD_BIT_SIZE. - Bound: working precision
p + WORD_BIT_SIZE. - MPFR oracle: no.
Sourcepub fn beta_pdf(
&self,
alpha: &Self,
beta: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn beta_pdf( &self, alpha: &Self, beta: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Beta density (x^{\alpha-1}(1-x)^{\beta-1}/B(\alpha,\beta)) with (B(\alpha,\beta)=\Gamma(\alpha)\Gamma(\beta)/\Gamma(\alpha+\beta)).
Requires x ∈ [0, 1], alpha > 0, beta > 0.
§Precision
- Algorithm:
pow/gammaatp + WORD_BIT_SIZE. - Bound: working precision
p + WORD_BIT_SIZE. - MPFR oracle: no.
Sourcepub fn poisson_pmf(
&self,
lambda: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn poisson_pmf( &self, lambda: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Poisson PMF (\lambda^k e^{-\lambda}/k!) for a non-negative integer self (= k).
§Precision
- Algorithm:
pow/exp/ (\Gamma(k+1)) atp + WORD_BIT_SIZE. - Bound: working precision
p + WORD_BIT_SIZE. - MPFR oracle: no.
Sourcepub fn binomial_pmf(
&self,
n: &Self,
prob: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn binomial_pmf( &self, n: &Self, prob: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Binomial PMF (\binom{n}{k} \mathrm{prob}^k (1-\mathrm{prob})^{n-k}).
self is (k). Requires non-negative integers k ≤ n and prob ∈ [0, 1].
§Precision
- Algorithm: multiplicative binomial coefficient, then
pow. - Bound: working precision
p + WORD_BIT_SIZE. - MPFR oracle: no.
Sourcepub fn chi_squared_cdf(
&self,
k: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn chi_squared_cdf( &self, k: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Chi-squared CDF (P(k/2, x/2)=\gamma(k/2, x/2)/\Gamma(k/2)).
self is (x). Requires x ≥ 0 and k > 0.
§Precision
- Algorithm: lower
gammaincovergammaatp + WORD_BIT_SIZE. - Bound: working precision
p + WORD_BIT_SIZE. - MPFR oracle: no.
Sourcepub fn student_t_pdf(
&self,
nu: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn student_t_pdf( &self, nu: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Student-(t) density via (\Gamma): (\Gamma((\nu+1)/2)/(\sqrt{\nu\pi},\Gamma(\nu/2)),(1+x^2/\nu)^{-(\nu+1)/2}).
self is (x). Requires nu > 0.
§Precision
- Algorithm:
gamma/pow/sqrtatp + WORD_BIT_SIZE. - Bound: working precision
p + WORD_BIT_SIZE. - MPFR oracle: no.
Sourcepub fn is_inf_pos(&self) -> bool
pub fn is_inf_pos(&self) -> bool
Returns true if self is positive infinity.
Sourcepub fn is_inf_neg(&self) -> bool
pub fn is_inf_neg(&self) -> bool
Returns true if self is negative infinity.
Sourcepub fn add(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
pub fn add(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
Adds d2 to self and returns the result of the operation with precision p rounded according to rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
Sourcepub fn add_full_prec(&self, d2: &Self) -> Self
pub fn add_full_prec(&self, d2: &Self) -> Self
Adds d2 to self and returns the result of the operation.
The resulting precision is equal to the full precision of the result.
This operation can be used to emulate integer addition.
Sourcepub fn sub(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
pub fn sub(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
Subtracts d2 from self and returns the result of the operation with precision p rounded according to rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
Sourcepub fn sub_full_prec(&self, d2: &Self) -> Self
pub fn sub_full_prec(&self, d2: &Self) -> Self
Subtracts d2 from self and returns the result of the operation.
The resulting precision is equal to the full precision of the result.
This operation can be used to emulate integer subtraction.
Sourcepub fn mul(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
pub fn mul(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
Multiplies d2 by self and returns the result of the operation with precision p rounded according to rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
Sourcepub fn mul_full_prec(&self, d2: &Self) -> Self
pub fn mul_full_prec(&self, d2: &Self) -> Self
Multiplies d2 by self and returns the result of the operation.
The resulting precision is equal to the full precision of the result.
This operation can be used to emulate integer multiplication.
Sourcepub fn fma(&self, b: &Self, c: &Self, p: usize, rm: RoundingMode) -> Self
pub fn fma(&self, b: &Self, c: &Self, p: usize, rm: RoundingMode) -> Self
Computes self * b + c with precision p, rounded once with rm.
Unlike mul followed by add, the product is not rounded to p before the addition.
Sourcepub fn two_sum(&self, b: &Self, p: usize, rm: RoundingMode) -> (Self, Self)
pub fn two_sum(&self, b: &Self, p: usize, rm: RoundingMode) -> (Self, Self)
Knuth–Dekker two-sum: (hi, lo) with hi rounded to p bits using rm and
hi + lo equal to the exact sum of finite operands (via add_full_prec).
Unlike a hardware-float Dekker two-sum, this takes (p, rm) because the high part is an
ExactNum at a chosen precision, not an implicit machine word.
Inf / NaN: hi is self.add(b, p, rm); lo is zero (or NaN if hi is NaN).
Reconstruct with hi.add(&lo, p, rm) (not add_full_prec, which uses internal precision 0).
Sourcepub fn two_product(&self, b: &Self, p: usize, rm: RoundingMode) -> (Self, Self)
pub fn two_product(&self, b: &Self, p: usize, rm: RoundingMode) -> (Self, Self)
Two-product: (hi, lo) with hi rounded to p bits using rm and hi + lo equal to the
exact product of finite operands (via mul_full_prec).
Sourcepub fn mul_add(&self, b: &Self, c: &Self, p: usize, rm: RoundingMode) -> Self
pub fn mul_add(&self, b: &Self, c: &Self, p: usize, rm: RoundingMode) -> Self
Alias of Self::fma.
Sourcepub fn div(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
pub fn div(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
Divides self by d2 and returns the result of the operation with precision p rounded according to rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
Sourcepub fn rem(&self, d2: &Self) -> Self
pub fn rem(&self, d2: &Self) -> Self
Returns the remainder of division of |self| by |d2|. The sign of the result is set to the sign of self.
Sourcepub fn cmp(&self, d2: &ExactNum) -> Option<i128>
pub fn cmp(&self, d2: &ExactNum) -> Option<i128>
Compares self to d2.
Returns positive if self > d2, negative if self < d2, zero if self == d2, None if self or d2 is NaN.
Sourcepub fn abs_cmp(&self, d2: &Self) -> Option<i128>
pub fn abs_cmp(&self, d2: &Self) -> Option<i128>
Compares the absolute value of self to the absolute value of d2.
Returns positive if |self| is greater than |d2|, negative if |self| is smaller than |d2|, 0 if |self| equals to |d2|, None if self or d2 is NaN.
Sourcepub fn pow(&self, n: &Self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn pow(&self, n: &Self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Compute the power of self to the n with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
Sourcepub fn powi(&self, n: usize, p: usize, rm: RoundingMode) -> Self
pub fn powi(&self, n: usize, p: usize, rm: RoundingMode) -> Self
Compute the power of self to the integer n with precision p. The result is rounded using the rounding mode rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
Sourcepub fn powsi(&self, n: isize, p: usize, rm: RoundingMode) -> Self
pub fn powsi(&self, n: isize, p: usize, rm: RoundingMode) -> Self
Compute the power of self to the signed integer n with precision p. The result is rounded using the rounding mode rm.
Precision is rounded upwards to the word size.
Negative n is a reciprocal of the corresponding positive power.
The function returns NaN if the precision p is incorrect, or Inf if self is zero and n is negative.
Sourcepub fn log(&self, n: &Self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn log(&self, n: &Self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the logarithm base n of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Returns true if self is positive.
The function returns false if self is NaN.
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns true if self is negative.
The function returns false if self is NaN.
Sourcepub fn is_subnormal(&self) -> bool
pub fn is_subnormal(&self) -> bool
Returns true if self is subnormal. A number is subnormal if the most significant bit of the mantissa is not equal to 1.
Sourcepub fn clamp(&self, min: &Self, max: &Self) -> Self
pub fn clamp(&self, min: &Self, max: &Self) -> Self
Restricts the value of self to an interval determined by the values of min and max.
The function returns max if self is greater than max, min if self is less than min, and self otherwise.
If either argument is NaN or min is greater than max, the function returns NaN.
Sourcepub fn max(&self, d1: &Self) -> Self
pub fn max(&self, d1: &Self) -> Self
Returns the value of d1 if d1 is greater than self, or the value of self otherwise.
If either argument is NaN, the function returns NaN.
Sourcepub fn min(&self, d1: &Self) -> Self
pub fn min(&self, d1: &Self) -> Self
Returns value of d1 if d1 is less than self, or the value of self otherwise.
If either argument is NaN, the function returns NaN.
Sourcepub fn signum(&self) -> Self
pub fn signum(&self) -> Self
Returns a ExactNum with the value -1 if self is negative, 1 if self is positive, zero otherwise.
The function returns NaN If self is NaN.
Sourcepub fn format(
&self,
rdx: Radix,
rm: RoundingMode,
cc: &mut Consts,
) -> Result<String, Error>
pub fn format( &self, rdx: Radix, rm: RoundingMode, cc: &mut Consts, ) -> Result<String, Error>
Formats the number using radix rdx and rounding mode rm.
Note, since hexadecimal digits include the character “e”, the exponent part is separated
from the mantissa by “_”.
For example, a number with mantissa 123abcdef and exponent 123 would be formatted as 123abcdef_e+123.
§Errors
- MemoryAllocation: failed to allocate memory for mantissa.
- ExponentOverflow: the resulting exponent becomes greater than the maximum allowed value for the exponent.
Sourcepub fn classify(&self) -> FpCategory
pub fn classify(&self) -> FpCategory
Returns category of self.
Sourcepub fn atan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn atan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the arctangent of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
Sourcepub fn atan2(
&self,
x: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn atan2( &self, x: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Computes atan2(self, x) with precision p (quadrant-aware arctangent of self / x).
The result is rounded using the rounding mode rm.
This function requires constants cache cc.
Precision is rounded upwards to the word size.
Sourcepub fn hypot(&self, other: &Self, p: usize, rm: RoundingMode) -> Self
pub fn hypot(&self, other: &Self, p: usize, rm: RoundingMode) -> Self
Computes sqrt(self² + other²) with precision p.
The result is rounded using the rounding mode rm.
Precision is rounded upwards to the word size.
hypot(±Inf, y) and hypot(x, ±Inf) are +Inf, including when the other argument is NaN.
Sourcepub fn log1p(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn log1p(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes ln(1 + self) with precision p.
The result is rounded using the rounding mode rm.
This function requires constants cache cc.
Returns -Inf for self == -1, and NaN if self < -1.
Sourcepub fn expm1(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn expm1(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes exp(self) - 1 with precision p.
The result is rounded using the rounding mode rm.
This function requires constants cache cc.
Sourcepub fn tanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn tanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the hyperbolic tangent of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
Sourcepub fn exponent(&self) -> Option<Exponent>
pub fn exponent(&self) -> Option<Exponent>
Returns the exponent of self, or None if self is Inf or NaN.
Sourcepub fn precision(&self) -> Option<usize>
pub fn precision(&self) -> Option<usize>
Returns the number of significant bits used in the mantissa, or None if self is Inf or NaN.
Normal numbers use all bits of the mantissa.
Subnormal numbers use fewer bits than the mantissa can hold.
Sourcepub fn as_raw_parts(&self) -> Option<(&[Word], usize, Sign, Exponent, bool)>
pub fn as_raw_parts(&self) -> Option<(&[Word], usize, Sign, Exponent, bool)>
Decomposes self into raw parts.
The function returns a reference to a slice of words representing mantissa,
numbers of significant bits in the mantissa, sign, exponent,
and a bool value which specify whether the number is inexact.
Sourcepub fn set_exponent(&mut self, e: Exponent)
pub fn set_exponent(&mut self, e: Exponent)
Sets the exponent of self.
Note that if self is subnormal, the exponent may not change, but the mantissa will shift instead.
e will be clamped to the range from EXPONENT_MIN to EXPONENT_MAX if it’s outside of the range.
See example below.
§Examples
// construct a subnormal value.
let mut n = ExactNum::min_positive(128);
assert_eq!(n.exponent(), Some(EXPONENT_MIN));
assert_eq!(n.precision(), Some(1));
// increase exponent.
let n_exp = n.exponent().expect("n is not NaN");
n.set_exponent(n_exp + 1);
// the outcome for subnormal number.
assert_eq!(n.exponent(), Some(EXPONENT_MIN));
assert_eq!(n.precision(), Some(2));Sourcepub fn mantissa_max_bit_len(&self) -> Option<usize>
pub fn mantissa_max_bit_len(&self) -> Option<usize>
Returns the maximum mantissa length of self in bits regardless of whether self is normal or subnormal.
Sourcepub fn is_inline(&self) -> bool
pub fn is_inline(&self) -> bool
True when a finite value stores its mantissa on the stack (at most crate::INLINE_WORDS limbs).
Inf and NaN return false.
Sourcepub fn set_precision(&mut self, p: usize, rm: RoundingMode) -> Result<(), Error>
pub fn set_precision(&mut self, p: usize, rm: RoundingMode) -> Result<(), Error>
Sets the precision of self to p.
If the new precision is smaller than the existing one, the number is rounded using specified rounding mode rm.
§Errors
- MemoryAllocation: failed to allocate memory for mantissa.
- InvalidArgument: the precision is incorrect.
Sourcepub fn reciprocal(&self, p: usize, rm: RoundingMode) -> Self
pub fn reciprocal(&self, p: usize, rm: RoundingMode) -> Self
Computes the reciprocal of a number with precision p.
The result is rounded using the rounding mode rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
Sourcepub fn mantissa_digits(&self) -> Option<&[Word]>
pub fn mantissa_digits(&self) -> Option<&[Word]>
Returns the raw mantissa words of a number.
Sourcepub fn convert_to_radix(
&self,
rdx: Radix,
rm: RoundingMode,
cc: &mut Consts,
) -> Result<(Sign, Vec<u8>, Exponent), Error>
pub fn convert_to_radix( &self, rdx: Radix, rm: RoundingMode, cc: &mut Consts, ) -> Result<(Sign, Vec<u8>, Exponent), Error>
Converts self to radix rdx using rounding mode rm.
The function returns sign, mantissa digits in radix rdx, and exponent such that the converted number
can be represented as mantissa digits * rdx ^ exponent.
The first element in the mantissa is the most significant digit.
§Examples
let mut cc = Consts::new().expect("Constants cache initialized.");
let n = ExactNum::parse("123.45678", Radix::Dec, 64, RoundingMode::None, &mut cc);
let (s, m, _e) = n.convert_to_radix(Radix::Dec, RoundingMode::None, &mut cc).expect("Conversion failed");
assert_eq!(s, Sign::Pos);
assert!(!m.is_empty());§Errors
- MemoryAllocation: failed to allocate memory for mantissa.
- ExponentOverflow: the resulting exponent becomes greater than the maximum allowed value for the exponent.
- InvalidArgument:
selfis Inf or NaN.
Sourcepub fn inexact(&self) -> bool
pub fn inexact(&self) -> bool
Returns true if self is inexact. The function returns false if self is Inf or NaN.
Sourcepub fn set_inexact(&mut self, inexact: bool)
pub fn set_inexact(&mut self, inexact: bool)
Marks self as inexact if inexact is true, or exact otherwise.
The function has no effect if self is Inf or NaN.
Sourcepub fn try_set_precision(
&mut self,
p: usize,
rm: RoundingMode,
s: usize,
) -> bool
pub fn try_set_precision( &mut self, p: usize, rm: RoundingMode, s: usize, ) -> bool
Try to round and then set the precision to p, given self has s correct digits in mantissa.
The function returns true if rounding succeeded, or if self is Inf or NaN.
If the fuction returns false, self is still modified, and should be discarded.
In case of an error, self will be set to NaN with an associated error.
If the precision p is incorrect self will be set to NaN.
Sourcepub fn frexp(&self) -> (Self, Exponent)
pub fn frexp(&self) -> (Self, Exponent)
Split self = m · 2^e with m in [0.5, 1) (zeros return (0, 0); Inf/NaN return (self, 0)).
Sourcepub fn ldexp(&self, n: Exponent, p: usize, rm: RoundingMode) -> Self
pub fn ldexp(&self, n: Exponent, p: usize, rm: RoundingMode) -> Self
self · 2^n. Alias of Self::scalb.
Sourcepub fn scalb(&self, n: Exponent, p: usize, rm: RoundingMode) -> Self
pub fn scalb(&self, n: Exponent, p: usize, rm: RoundingMode) -> Self
self · 2^n (IEEE scalbn).
Sourcepub fn logb(&self, p: usize, rm: RoundingMode) -> Self
pub fn logb(&self, p: usize, rm: RoundingMode) -> Self
floor(log2(|self|)) as a float. Zero becomes -Inf; Inf/NaN unchanged in kind.
Sourcepub fn ilogb(&self) -> Option<Exponent>
pub fn ilogb(&self) -> Option<Exponent>
Integer floor(log2(|self|)). None for zero, Inf, or NaN.
Sourcepub fn copysign(&self, sign: &Self, p: usize, rm: RoundingMode) -> Self
pub fn copysign(&self, sign: &Self, p: usize, rm: RoundingMode) -> Self
Returns a value with the magnitude of self and the sign of sign.
Sourcepub fn next_after(&self, toward: &Self, p: usize, rm: RoundingMode) -> Self
pub fn next_after(&self, toward: &Self, p: usize, rm: RoundingMode) -> Self
Returns the next representable value from self toward toward at precision p.
Sourcepub fn round(&self, n: usize, rm: RoundingMode) -> Self
pub fn round(&self, n: usize, rm: RoundingMode) -> Self
Returns the rounded number with n binary positions in the fractional part of the number using rounding mode rm.
Sourcepub fn sqrt(&self, p: usize, rm: RoundingMode) -> Self
pub fn sqrt(&self, p: usize, rm: RoundingMode) -> Self
Computes the square root of a number with precision p. The result is rounded using the rounding mode rm.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn cbrt(&self, p: usize, rm: RoundingMode) -> Self
pub fn cbrt(&self, p: usize, rm: RoundingMode) -> Self
Computes the cube root of a number with precision p. The result is rounded using the rounding mode rm.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn nth_root(&self, n: usize, p: usize, rm: RoundingMode) -> Self
pub fn nth_root(&self, n: usize, p: usize, rm: RoundingMode) -> Self
Sourcepub fn ln(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn ln(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the natural logarithm of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn log2(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn log2(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the logarithm base 2 of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn log10(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn log10(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the logarithm base 10 of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn exp(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn exp(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes e to the power of self with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn exp2(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn exp2(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes 2 to the power of self with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn exp10(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn exp10(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes 10 to the power of self with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn rem_pi(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn rem_pi(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Reduces self modulo 2π into the interval (-2π, 2π) using precision p and rounding mode rm.
This function requires constants cache cc for computing the result.
Sourcepub fn sin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn sin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the sine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn cos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn cos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the cosine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn sin_cos(
&self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> (Self, Self)
pub fn sin_cos( &self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> (Self, Self)
Computes (sin(self), cos(self)) with precision p using a shared argument reduction.
Sourcepub fn tan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn tan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the tangent of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn asin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn asin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the arcsine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn acos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn acos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the arccosine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn sinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn sinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the hyperbolic sine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn cosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn cosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the hyperbolic cosine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn sinh_cosh(
&self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> (Self, Self)
pub fn sinh_cosh( &self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> (Self, Self)
Computes (sinh(self), cosh(self)) with precision p using a single exp(|x|) evaluation.
Sourcepub fn erf(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn erf(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Error function erf(self) with precision p.
§Precision
- Algorithm: Taylor series when
|x|.exponent() ≤ 2; complementary asymptotic otherwise. Saturates to±1when2|e| > p+4. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). 1 ULP vs MPFR on|x| ≲ 4. - Thresholds: exponent cut
≤ 2(not a named constant). - MPFR oracle: yes,
|x| ≲ 4undermpfr-tests. Complexerfon the real axis uses the same oracle; GNU MPC has nompc_erf.
Sourcepub fn erfc(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn erfc(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Complementary error function erfc(self) = 1 - erf(self) with precision p.
§Precision
- Algorithm:
1 - erfat extra working precision (same series / asymptotic aserf). - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). 1 ULP vs MPFR on|x| ≲ 4. - MPFR oracle: yes,
|x| ≲ 4undermpfr-tests.
Sourcepub fn gamma(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn gamma(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Gamma function Γ(self) with precision p. Poles at non-positive integers yield NaN (or +Inf at 0).
§Precision
- Algorithm: Stirling series for
ln Γthenexp; reflection across the negative axis. Integer factorials for small positive integers. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). 1 ULP vs MPFR on the oracle domain. - MPFR oracle: yes, under
mpfr-tests.
Sourcepub fn ln_gamma(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn ln_gamma(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
ln Γ(self) for positive self with precision p.
§Precision
- Algorithm: Stirling series (Bernoulli) at working precision
p + WORD_BIT_SIZE. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). 1 ULP vs MPFR on the oracle domain. - MPFR oracle: yes, under
mpfr-tests.
Sourcepub fn digamma(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn digamma(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Digamma ψ(self). Poles at non-positive integers. Reflection for z < 0.
§Precision
- Algorithm: recurrence to a large argument, then Bernoulli series; reflection for
z < 0. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). 1 ULP vs MPFRdigammaonz > 0. - MPFR oracle: yes,
z > 0undermpfr-tests.
Sourcepub fn gammainc(
&self,
x: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn gammainc( &self, x: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Lower incomplete gamma γ(self, x) for self > 0, x ≥ 0.
§Precision
- Algorithm: power series in
xat working precision;+∞inxreturnsΓ(self). - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: identity
γ(s,x)=Γ(s)−Γ(s,x); upper usesmpfr_gamma_inc.
Sourcepub fn gammainc_upper(
&self,
x: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn gammainc_upper( &self, x: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Upper incomplete gamma Γ(self, x) for self > 0, x ≥ 0.
§Precision
- Algorithm:
Γ(self) - γ(self, x)at working precision;+∞inxreturns 0. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: yes,
mpfr_gamma_incundermpfr-tests.
Sourcepub fn ei(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn ei(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Exponential integral Ei(self) (principal value for self < 0). 0 is a pole.
§Precision
- Algorithm: power series for moderate
|x|; factorial asymptotic when|x|is large (exponent() > 6and|x| ≳ 0.7 p). - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: yes,
mpfr_eintundermpfr-tests.
Sourcepub fn si(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn si(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Sine integral Si(self). +∞ → π/2, −∞ → −π/2.
§Precision
- Algorithm: series, or auxiliary
f,gasymptotic on the same cut asEi. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no (
Siodd,Si(0)=0,Si(+∞)=π/2).
Sourcepub fn ci(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn ci(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Cosine integral Ci(self) for self > 0.
§Precision
- Algorithm: series, or auxiliary
f,gasymptotic (same|x|cut asEi). Near-zero is a pole. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no (identity / series golds; GNU MPFR has no
Si/Ci).
Sourcepub fn li(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn li(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Logarithmic integral li(self) = Ei(ln self) for self > 0, self ≠ 1.
§Precision
- Algorithm:
Ei(ln self)at extra working precision (inheritsEiseries / asymptotic). - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no (
li(e)=Ei(1)identity).
Sourcepub fn fresnel_s(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn fresnel_s(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Fresnel sine integral S(self). ±∞ → ±1/2.
§Precision
- Algorithm: series, or auxiliary
f,gwhen|x|.exponent() ≥ 8(or3 x² > p). - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no (
Sodd,S(0)=0,S(+∞)=1/2).
Sourcepub fn fresnel_c(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn fresnel_c(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Fresnel cosine integral C(self). ±∞ → ±1/2.
§Precision
- Algorithm: same series / auxiliary
f,gsplit asSelf::fresnel_s. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no (same identities as
Self::fresnel_s).
Sourcepub fn ai(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn ai(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Airy (\mathrm{Ai}(\mathrm{self})). (+\infty\to 0); (-\infty) has no limit → NaN.
§Precision
- Algorithm: power series for
|x| < AIRY_SERIES_THRESHOLD(8); asymptotic otherwise. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: yes,
mpfr_aiundermpfr-tests.
Sourcepub fn bi(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn bi(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Sourcepub fn ai_prime(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn ai_prime(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
(\mathrm{Ai}’(\mathrm{self})). (+\infty\to 0); (-\infty) → NaN.
§Precision
- Algorithm: differentiated series / asymptotic;
AIRY_SERIES_THRESHOLD = 8. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn bi_prime(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn bi_prime(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
(\mathrm{Bi}’(\mathrm{self})). (+\infty\to+\infty); (-\infty) → NaN.
§Precision
- Algorithm: differentiated series / asymptotic;
AIRY_SERIES_THRESHOLD = 8. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn bessel_j(
&self,
n: usize,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn bessel_j( &self, n: usize, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Bessel function of the first kind J_n(self) for integer order n.
§Precision
- Algorithm: power series; Miller recurrence for large
n(n ≤ 1024). - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). 1 ULP vs MPFRjnforn = 0,1,2. - MPFR oracle: yes,
n = 0,1,2undermpfr-tests.
Sourcepub fn bessel_j_nu(
&self,
nu: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn bessel_j_nu( &self, nu: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
(J_ν(\mathrm{self})) for real order nu.
§Precision
- Algorithm: series in
x; integerνdelegates toSelf::bessel_j. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no (identity golds).
Sourcepub fn bessel_y(
&self,
nu: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn bessel_y( &self, nu: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
(Y_ν(\mathrm{self})) for self > 0.
§Precision
- Algorithm: Wronskian / series from (J_ν); cut on ((-\infty, 0]).
- Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: yes,
mpfr_ynforn = 0,1undermpfr-tests.
Sourcepub fn bessel_i(
&self,
nu: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn bessel_i( &self, nu: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
(I_ν(\mathrm{self})).
§Precision
- Algorithm: series; (I_ν(z) = i^{-ν} J_ν(iz)) for the complex path.
- Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn bessel_k(
&self,
nu: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn bessel_k( &self, nu: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
(K_ν(\mathrm{self})) for self > 0. (K_{-ν}=K_ν).
§Precision
- Algorithm: series / Temme; large-
|x|asymptotick_asymptotic. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn elliptic_k(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn elliptic_k(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Complete elliptic K(self). Parameter m = k². m = 1 is +∞; m > 1 uses the reciprocal-modulus transform.
§Precision
- Algorithm: Carlson
R_Fduplication; capCARLSON_DUPE_MAX = 128. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no (identity golds; GNU MPFR has no Carlson
K).
Sourcepub fn elliptic_e_complete(
&self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn elliptic_e_complete( &self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Complete elliptic E(self) for self ≤ 1. E(1) = 1.
§Precision
- Algorithm: Carlson
R_F/R_D;CARLSON_DUPE_MAX = 128. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn elliptic_f(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn elliptic_f( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Incomplete F(self | m) for |self| ≤ 1. self = sin φ, m = k².
§Precision
- Algorithm: Carlson
R_F;CARLSON_DUPE_MAX = 128. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn elliptic_e(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn elliptic_e( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Incomplete E(self | m) for |self| ≤ 1.
§Precision
- Algorithm: Carlson
R_F/R_D;CARLSON_DUPE_MAX = 128. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn elliptic_pi_complete(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn elliptic_pi_complete( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Complete Π(self, m) for self < 1, m < 1.
§Precision
- Algorithm: Carlson
R_J;CARLSON_DUPE_MAX = 128. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn elliptic_pi(
&self,
x: &Self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn elliptic_pi( &self, x: &Self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Incomplete Π(self; x | m).
§Precision
- Algorithm: Carlson
R_J;CARLSON_DUPE_MAX = 128. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn jacobi_am(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_am( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Jacobi amplitude am(self | m). Parameter m = k² ∈ [0, 1].
§Precision
- Algorithm: AGM / descending Landen; cap
JACOBI_AGM_MAX = 128. (m=0) is trig; (m=1) is hyperbolic. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no (identity golds; GNU MPFR has no Jacobi
sn).
Sourcepub fn jacobi_sn(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_sn( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
sn(self | m). Parameter m = k² ∈ [0, 1].
The inverse on (-K, K) is Self::elliptic_f: F(sn(u|m)|m) = u.
§Precision
- Algorithm: AGM amplitude; cap
JACOBI_AGM_MAX = 128. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn jacobi_cn(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_cn( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
cn(self | m). Parameter m = k² ∈ [0, 1].
§Precision
- Algorithm: AGM amplitude; cap
JACOBI_AGM_MAX = 128. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn jacobi_dn(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_dn( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
dn(self | m). Parameter m = k² ∈ [0, 1].
§Precision
- Algorithm: AGM amplitude; cap
JACOBI_AGM_MAX = 128. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn jacobi_cd(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_cd( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
cd(self | m) = cn / dn. Parameter m = k² ∈ [0, 1].
§Precision
- Algorithm: AGM amplitude; cap
JACOBI_AGM_MAX = 128. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn jacobi_ns(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_ns( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
ns(self | m) = 1/sn.
Sourcepub fn jacobi_nc(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_nc( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
nc(self | m) = 1/cn.
Sourcepub fn jacobi_nd(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_nd( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
nd(self | m) = 1/dn.
Sourcepub fn jacobi_sc(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_sc( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
sc(self | m) = sn/cn.
Sourcepub fn jacobi_sd(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_sd( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
sd(self | m) = sn/dn.
Sourcepub fn jacobi_cs(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_cs( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
cs(self | m) = cn/sn.
Sourcepub fn jacobi_ds(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_ds( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
ds(self | m) = dn/sn.
Sourcepub fn jacobi_dc(
&self,
m: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn jacobi_dc( &self, m: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
dc(self | m) = dn/cn.
Sourcepub fn legendre_p(&self, n: u32, p: usize, rm: RoundingMode) -> Self
pub fn legendre_p(&self, n: u32, p: usize, rm: RoundingMode) -> Self
Legendre (P_n(\mathrm{self})) for integer n.
§Precision
- Algorithm: three-term recurrence at
p + O(n)bits. CapORTHOPOLY_N_MAX. - Bound: working-precision recurrence (not a Ziv leaf).
- MPFR oracle: no.
Sourcepub fn assoc_legendre_p(
&self,
n: u32,
m: i32,
p: usize,
rm: RoundingMode,
) -> Self
pub fn assoc_legendre_p( &self, n: u32, m: i32, p: usize, rm: RoundingMode, ) -> Self
Associated (P_n^m(\mathrm{self})) (Condon–Shortley).
§Precision
- Algorithm: recurrence from (P_n); Condon–Shortley phase.
- Bound: working-precision recurrence (not a Ziv leaf).
- MPFR oracle: no.
Sourcepub fn hypergeom_2f1(
&self,
b: &Self,
c: &Self,
z: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn hypergeom_2f1( &self, b: &Self, c: &Self, z: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Gaussian ({}_2F_1(\mathrm{self}, b; c; z)).
§Precision
- Algorithm: series for
|z| < 1; Gauss atz = 1; Pfaff / continuation. CapHYPERGEOM_TERM_MAX = 10_000. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY) when the series converges. - MPFR oracle: no.
Sourcepub fn betainc(
&self,
b: &Self,
x: &Self,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn betainc( &self, b: &Self, x: &Self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Regularized incomplete beta (I_x(a=\mathrm{self}, b)).
§Precision
- Algorithm: series / continued fraction in
x ∈ [0, 1]fora > 0,b > 0. - Bound: Ziv correct-rounding (
MAX_PREC_RETRY). - MPFR oracle: no.
Sourcepub fn asinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn asinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the hyperbolic arcsine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn acosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn acosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the hyperbolic arccosine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn atanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn atanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
Computes the hyperbolic arctangent of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Sourcepub fn hermite_he(&self, n: usize, p: usize, rm: RoundingMode) -> Self
pub fn hermite_he(&self, n: usize, p: usize, rm: RoundingMode) -> Self
Probabilist’s Hermite polynomial He_n(self).
He_0 = 1, He_1 = x, He_{n+1} = x He_n − n He_{n−1}.
n > ORTHOPOLY_N_MAX or non-finite self is NaN.
Sourcepub fn hermite_h(&self, n: usize, p: usize, rm: RoundingMode) -> Self
pub fn hermite_h(&self, n: usize, p: usize, rm: RoundingMode) -> Self
Physicist’s Hermite polynomial H_n(self).
H_0 = 1, H_1 = 2x, H_{n+1} = 2x H_n − 2n H_{n−1}.
n > ORTHOPOLY_N_MAX or non-finite self is NaN.
Sourcepub fn laguerre(&self, n: usize, p: usize, rm: RoundingMode) -> Self
pub fn laguerre(&self, n: usize, p: usize, rm: RoundingMode) -> Self
Laguerre polynomial L_n(self).
L_0 = 1, L_1 = 1 − x,
L_{n+1} = ((2n+1−x) L_n − n L_{n−1}) / (n+1).
n > ORTHOPOLY_N_MAX or non-finite self is NaN.
Sourcepub fn gen_laguerre(
&self,
n: usize,
alpha: &Self,
p: usize,
rm: RoundingMode,
) -> Self
pub fn gen_laguerre( &self, n: usize, alpha: &Self, p: usize, rm: RoundingMode, ) -> Self
Generalized Laguerre L_n^{(α)}(self).
L_0^{(α)} = 1, L_1^{(α)} = 1+α−x,
L_{n+1}^{(α)} = (((2n+1+α−x) L_n − (n+α) L_{n−1}) / (n+1).
n > ORTHOPOLY_N_MAX or a non-finite argument is NaN.
Sourcepub fn chebyshev_t(&self, n: usize, p: usize, rm: RoundingMode) -> Self
pub fn chebyshev_t(&self, n: usize, p: usize, rm: RoundingMode) -> Self
Chebyshev polynomial of the first kind T_n(self).
T_0 = 1, T_1 = x, T_{n+1} = 2x T_n − T_{n−1}.
n > ORTHOPOLY_N_MAX or non-finite self is NaN.
Sourcepub fn chebyshev_u(&self, n: usize, p: usize, rm: RoundingMode) -> Self
pub fn chebyshev_u(&self, n: usize, p: usize, rm: RoundingMode) -> Self
Chebyshev polynomial of the second kind U_n(self).
U_0 = 1, U_1 = 2x, U_{n+1} = 2x U_n − U_{n−1}.
n > ORTHOPOLY_N_MAX or non-finite self is NaN.
Sourcepub fn gegenbauer(
&self,
n: usize,
lambda: &Self,
p: usize,
rm: RoundingMode,
) -> Self
pub fn gegenbauer( &self, n: usize, lambda: &Self, p: usize, rm: RoundingMode, ) -> Self
Gegenbauer (ultraspherical) polynomial C_n^{(λ)}(self).
C_0 = 1, C_1 = 2λ x,
C_{n+1} = (2(n+λ) x C_n − (n+2λ−1) C_{n−1}) / (n+1).
Standard C_n^{(λ)}: C_2^{(1)} = 4x² − 1 = U_2, and
C_n^{(1/2)} = P_n (Legendre). n > ORTHOPOLY_N_MAX or a
non-finite argument is NaN.
Sourcepub fn format_exact(&self, rdx: Radix) -> Option<String>
pub fn format_exact(&self, rdx: Radix) -> Option<String>
Minimum digits in rdx that recover self exactly when the value is a
terminating expansion in that radix.
Trait Implementations§
Source§impl Clone for RadixFloat
impl Clone for RadixFloat
Source§fn clone(&self) -> RadixFloat
fn clone(&self) -> RadixFloat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RadixFloat
impl Debug for RadixFloat
Source§impl Deref for RadixFloat
impl Deref for RadixFloat
Auto Trait Implementations§
impl Freeze for RadixFloat
impl RefUnwindSafe for RadixFloat
impl Send for RadixFloat
impl Sync for RadixFloat
impl Unpin for RadixFloat
impl UnsafeUnpin for RadixFloat
impl UnwindSafe for RadixFloat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more