Skip to main content

ExactNum

Struct ExactNum 

Source
pub struct ExactNum { /* private fields */ }
Expand description

A floating point number of arbitrary precision.

Implementations§

Source§

impl ExactNum

Source

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.

Source

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.

Source

pub fn from_inline_bytes(bytes: &[u8; 16]) -> Result<Self, Error>

Decode a 16-byte inline record.

Source

pub fn to_bytes(&self) -> Result<Vec<u8>, Error>

Encode self (inline 16 bytes, or a heap record if the mantissa is wider).

Source

pub fn write_bytes(&self, dest: &mut [u8]) -> Result<usize, Error>

Write the compact record into dest without allocating.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>

Decode a compact record. Extra trailing bytes are Error::InvalidArgument.

Source§

impl ExactNum

Source

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 / π at p + WORD_BIT_SIZE, then one rounding to p.
  • Bound: working precision p + WORD_BIT_SIZE.
  • MPFR oracle: no (composite of existing leaves).
Source

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 erf at p + WORD_BIT_SIZE.
  • Bound: working precision p + WORD_BIT_SIZE.
  • MPFR oracle: no (composite of erf).
Source

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 / gamma at p + WORD_BIT_SIZE.
  • Bound: working precision p + WORD_BIT_SIZE.
  • MPFR oracle: no.
Source

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 / gamma at p + WORD_BIT_SIZE.
  • Bound: working precision p + WORD_BIT_SIZE.
  • MPFR oracle: no.
Source

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)) at p + WORD_BIT_SIZE.
  • Bound: working precision p + WORD_BIT_SIZE.
  • MPFR oracle: no.
Source

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.
Source

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 gammainc over gamma at p + WORD_BIT_SIZE.
  • Bound: working precision p + WORD_BIT_SIZE.
  • MPFR oracle: no.
Source

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 / sqrt at p + WORD_BIT_SIZE.
  • Bound: working precision p + WORD_BIT_SIZE.
  • MPFR oracle: no.
Source§

impl ExactNum

Source

pub fn new(p: usize) -> Self

Returns a new number with value of 0 and precision of p bits. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source

pub fn nan(err: Option<Error>) -> Self

Constructs not-a-number with an associated error err.

Source

pub fn is_inf_pos(&self) -> bool

Returns true if self is positive infinity.

Source

pub fn is_inf_neg(&self) -> bool

Returns true if self is negative infinity.

Source

pub fn is_inf(&self) -> bool

Returns true if self is infinite.

Source

pub fn is_nan(&self) -> bool

Return true if self is not a number.

Source

pub fn is_int(&self) -> bool

Return true if self is an integer number.

Source

pub fn err(&self) -> Option<Error>

Returns the associated with NaN error, if any.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Source

pub fn fused_sum(xs: &[Self], p: usize, rm: RoundingMode) -> Self

Sum xs at extra working precision and round once to p bits.

Source

pub fn fused_dot(xs: &[Self], ys: &[Self], p: usize, rm: RoundingMode) -> Self

Dot product of equal-length slices: extra-precision ∑ xs[i]*ys[i], then one round to p. Length mismatch yields NaN (InvalidArgument).

Source

pub fn polyval(coeffs: &[Self], x: &Self, p: usize, rm: RoundingMode) -> Self

Horner evaluation a₀ + x(a₁ + x(a₂ + …)) with fused multiply-add at extra working precision, then one round to p. coeffs[0] is the constant term (lowest degree first). Empty coeffs yields zero.

Source

pub fn mul_add(&self, b: &Self, c: &Self, p: usize, rm: RoundingMode) -> Self

Alias of Self::fma.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn inv_sign(&mut self)

Reverses the sign of self.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn is_positive(&self) -> bool

Returns true if self is positive. The function returns false if self is NaN.

Source

pub fn is_negative(&self) -> bool

Returns true if self is negative. The function returns false if self is NaN.

Source

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.

Source

pub fn is_zero(&self) -> bool

Returns true if self is zero.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn parse( s: &str, rdx: Radix, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Parses a number from the string s. The function expects s to be a number in scientific format in radix rdx, or +-Inf, or NaN. if p equals to usize::MAX then the precision of the resulting number is determined automatically from the input.

§Examples
let mut cc = Consts::new().expect("Constants cache initialized.");

let n = ExactNum::parse("0.0", Radix::Bin, 64, RoundingMode::ToEven, &mut cc);
assert!(n.is_zero());

let n = ExactNum::parse("-Inf", Radix::Hex, 1, RoundingMode::None, &mut cc);
assert!(n.is_inf_neg());

let n = ExactNum::parse("NaN", Radix::Oct, 2, RoundingMode::None, &mut cc);
assert!(n.is_nan());
Source

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.
Source

pub fn with_radix(self, radix: Radix) -> RadixFloat

Wraps self in a crate::RadixFloat tagged with radix for parse/format.

Source

pub fn classify(&self) -> FpCategory

Returns category of self.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn exponent(&self) -> Option<Exponent>

Returns the exponent of self, or None if self is Inf or NaN.

Source

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.

Source

pub fn max_value(p: usize) -> Self

Returns the maximum value for the specified precision p: all bits of the mantissa are set to 1, the exponent has the maximum possible value, and the sign is positive. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source

pub fn min_value(p: usize) -> Self

Returns the minimum value for the specified precision p: all bits of the mantissa are set to 1, the exponent has the maximum possible value, and the sign is negative. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source

pub fn min_positive(p: usize) -> Self

Returns the minimum positive subnormal value for the specified precision p: only the least significant bit of the mantissa is set to 1, the exponent has the minimum possible value, and the sign is positive. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source

pub fn min_positive_normal(p: usize) -> Self

Returns the minimum positive normal value for the specified precision p: only the most significant bit of the mantissa is set to 1, the exponent has the minimum possible value, and the sign is positive. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source

pub fn from_word(d: Word, p: usize) -> Self

Returns a new number with value d and the precision p. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source

pub fn neg(&self) -> Self

Returns a copy of the number with the sign reversed.

Source

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.

Source

pub fn from_raw_parts( m: &[Word], n: usize, s: Sign, e: Exponent, inexact: bool, ) -> Self

Constructs a number from the raw parts:

  • m is the mantisaa.
  • n is the number of significant bits in mantissa.
  • s is the sign.
  • e is the exponent.
  • inexact specify whether number is inexact.

This function returns NaN in the following situations:

  • n is larger than the number of bits in m.
  • n is smaller than the number of bits in m, but m does not represent corresponding subnormal number mantissa.
  • n is smaller than the number of bits in m, but e is not the minimum possible exponent.
  • n or the size of m is too large (larger than isize::MAX / 2 + EXPONENT_MIN).
  • e is less than EXPONENT_MIN or greater than EXPONENT_MAX.
Source

pub fn from_words(m: &[Word], s: Sign, e: Exponent) -> Self

Constructs a number from the slice of words:

  • m is the mantissa.
  • s is the sign.
  • e is the exponent.

The function returns NaN if e is less than EXPONENT_MIN or greater than EXPONENT_MAX.

Source

pub fn sign(&self) -> Option<Sign>

Returns the sign of self, or None if self is NaN.

Source

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));
Source

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.

Source

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.

Source

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.
Source

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.

Source

pub fn set_sign(&mut self, s: Sign)

Sets the sign of self.

Source

pub fn mantissa_digits(&self) -> Option<&[Word]>

Returns the raw mantissa words of a number.

Source

pub fn convert_from_radix( sign: Sign, digits: &[u8], e: Exponent, rdx: Radix, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Converts an array of digits in radix rdx to ExactNum with precision p. digits represents mantissa and is interpreted as a number smaller than 1 and greater or equal to 1/rdx. The first element in digits is the most significant digit. e is the exponent part of the number, such that the number can be represented as digits * rdx ^ e. Precision is rounded upwards to the word size. if p equals usize::MAX then the precision of the resulting number is determined automatically from the input.

§Examples

Code below converts -0.1234567₈ × 10₈^3₈ given in radix 8 to ExactNum.

let mut cc = Consts::new().expect("Constants cache initialized.");

let n = ExactNum::convert_from_radix(
    Sign::Neg,
    &[1, 2, 3, 4, 5, 6, 7, 0],
    3,
    Radix::Oct,
    64,
    RoundingMode::None,
    &mut cc);
assert!(!n.is_nan());
assert!(n.is_negative());
§Errors

On error, the function returns NaN with the following associated error:

  • MemoryAllocation: failed to allocate memory for mantissa.
  • ExponentOverflow: the resulting exponent becomes greater than the maximum allowed value for the exponent.
  • InvalidArgument: the precision is incorrect, or digits contains unacceptable digits for given radix, or when e is less than EXPONENT_MIN or greater than EXPONENT_MAX.
Source

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: self is Inf or NaN.
Source

pub fn inexact(&self) -> bool

Returns true if self is inexact. The function returns false if self is Inf or NaN.

Source

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.

Source

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.

Source

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)).

Source

pub fn ldexp(&self, n: Exponent, p: usize, rm: RoundingMode) -> Self

self · 2^n. Alias of Self::scalb.

Source

pub fn scalb(&self, n: Exponent, p: usize, rm: RoundingMode) -> Self

self · 2^n (IEEE scalbn).

Source

pub fn logb(&self, p: usize, rm: RoundingMode) -> Self

floor(log2(|self|)) as a float. Zero becomes -Inf; Inf/NaN unchanged in kind.

Source

pub fn ilogb(&self) -> Option<Exponent>

Integer floor(log2(|self|)). None for zero, Inf, or NaN.

Source§

impl ExactNum

Source

pub fn abs(&self) -> Self

Returns the absolute value of self.

Source

pub fn copysign(&self, sign: &Self, p: usize, rm: RoundingMode) -> Self

Returns a value with the magnitude of self and the sign of sign.

Source

pub fn next_after(&self, toward: &Self, p: usize, rm: RoundingMode) -> Self

Returns the next representable value from self toward toward at precision p.

Source

pub fn int(&self) -> Self

Returns the integer part of self.

Source

pub fn fract(&self) -> Self

Returns the fractional part of self.

Source

pub fn ceil(&self) -> Self

Returns the smallest integer greater than or equal to self.

Source

pub fn floor(&self) -> Self

Returns the largest integer less than or equal to self.

Source

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.

Source

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.

Source

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.

Source

pub fn nth_root(&self, n: usize, p: usize, rm: RoundingMode) -> Self

Computes the n-th root of self with precision p. n = 2 and n = 3 delegate to sqrt and cbrt.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn rem_pi(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Reduces self modulo into the interval (-2π, 2π) using precision p and rounding mode rm. This function requires constants cache cc for computing the result.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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 ±1 when 2|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| ≲ 4 under mpfr-tests. Complex erf on the real axis uses the same oracle; GNU MPC has no mpc_erf.
Source

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 - erf at extra working precision (same series / asymptotic as erf).
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY). 1 ULP vs MPFR on |x| ≲ 4.
  • MPFR oracle: yes, |x| ≲ 4 under mpfr-tests.
Source

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 Γ then exp; 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.
Source

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.
Source

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 MPFR digamma on z > 0.
  • MPFR oracle: yes, z > 0 under mpfr-tests.
Source

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 x at working precision; +∞ in x returns Γ(self).
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: identity γ(s,x)=Γ(s)−Γ(s,x); upper uses mpfr_gamma_inc.
Source

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; +∞ in x returns 0.
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: yes, mpfr_gamma_inc under mpfr-tests.
Source

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() > 6 and |x| ≳ 0.7 p).
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: yes, mpfr_eint under mpfr-tests.
Source

pub fn si(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Sine integral Si(self). +∞ → π/2, −∞ → −π/2.

§Precision
  • Algorithm: series, or auxiliary f,g asymptotic on the same cut as Ei.
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: no (Si odd, Si(0)=0, Si(+∞)=π/2).
Source

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,g asymptotic (same |x| cut as Ei). Near-zero is a pole.
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: no (identity / series golds; GNU MPFR has no Si/Ci).
Source

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 (inherits Ei series / asymptotic).
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: no (li(e)=Ei(1) identity).
Source

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,g when |x|.exponent() ≥ 8 (or 3 x² > p).
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: no (S odd, S(0)=0, S(+∞)=1/2).
Source

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,g split as Self::fresnel_s.
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: no (same identities as Self::fresnel_s).
Source

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_ai under mpfr-tests.
Source

pub fn bi(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Airy (\mathrm{Bi}(\mathrm{self})). (+\infty\to+\infty); (-\infty) has no limit → NaN.

§Precision
  • Algorithm: same AIRY_SERIES_THRESHOLD = 8 split as Self::ai.
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: no (Ai Bi' − Ai' Bi = 1/π; GNU MPFR has no Bi).
Source

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.
Source

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.
Source

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 MPFR jn for n = 0,1,2.
  • MPFR oracle: yes, n = 0,1,2 under mpfr-tests.
Source

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 to Self::bessel_j.
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: no (identity golds).
Source

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_yn for n = 0,1 under mpfr-tests.
Source

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.
Source

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| asymptotic k_asymptotic.
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: no.
Source

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_F duplication; cap CARLSON_DUPE_MAX = 128.
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: no (identity golds; GNU MPFR has no Carlson K).
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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. Cap ORTHOPOLY_N_MAX.
  • Bound: working-precision recurrence (not a Ziv leaf).
  • MPFR oracle: no.
Source

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.
Source

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 at z = 1; Pfaff / continuation. Cap HYPERGEOM_TERM_MAX = 10_000.
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY) when the series converges.
  • MPFR oracle: no.
Source

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] for a > 0, b > 0.
  • Bound: Ziv correct-rounding (MAX_PREC_RETRY).
  • MPFR oracle: no.
Source

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.

Source

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.

Source

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.

Source§

impl ExactNum

Source

pub fn from_i8(i: i8, p: usize) -> Self

Constructs ExactNum with precision p from an integer value i. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source§

impl ExactNum

Source

pub fn from_i16(i: i16, p: usize) -> Self

Constructs ExactNum with precision p from an integer value i. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source§

impl ExactNum

Source

pub fn from_i32(i: i32, p: usize) -> Self

Constructs ExactNum with precision p from an integer value i. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source§

impl ExactNum

Source

pub fn from_i64(i: i64, p: usize) -> Self

Constructs ExactNum with precision p from an integer value i. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source§

impl ExactNum

Source

pub fn from_i128(i: i128, p: usize) -> Self

Constructs ExactNum with precision p from an integer value i. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source§

impl ExactNum

Source

pub fn from_u8(i: u8, p: usize) -> Self

Constructs ExactNum with precision p from an integer value i. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source§

impl ExactNum

Source

pub fn from_u16(i: u16, p: usize) -> Self

Constructs ExactNum with precision p from an integer value i. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source§

impl ExactNum

Source

pub fn from_u32(i: u32, p: usize) -> Self

Constructs ExactNum with precision p from an integer value i. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source§

impl ExactNum

Source

pub fn from_u64(i: u64, p: usize) -> Self

Constructs ExactNum with precision p from an integer value i. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source§

impl ExactNum

Source

pub fn from_u128(i: u128, p: usize) -> Self

Constructs ExactNum with precision p from an integer value i. Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.

Source§

impl ExactNum

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source§

impl ExactNum

Source

pub fn parse_exact(s: &str) -> Option<Self>

Parse a decimal that is exact in binary (a dyadic rational). None if the value is not a finite dyadic (so 0.1 is None here; use ExactRational::parse_exact).

Source

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 Add for ExactNum

Source§

type Output = ExactNum

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ExactNum) -> ExactNum

Performs the + operation. Read more
Source§

impl Add<&ExactNum> for &ExactNum

Source§

type Output = ExactNum

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &ExactNum) -> ExactNum

Performs the + operation. Read more
Source§

impl Add<&ExactNum> for ExactNum

Source§

type Output = ExactNum

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &ExactNum) -> ExactNum

Performs the + operation. Read more
Source§

impl Add<ExactNum> for &ExactNum

Source§

type Output = ExactNum

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ExactNum) -> ExactNum

Performs the + operation. Read more
Source§

impl Binary for ExactNum

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the number. The implementation is not available in no_std environment.

Source§

impl Clone for ExactNum

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExactNum

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ExactNum

Source§

fn default() -> ExactNum

Returns the “default value” for a type. Read more
Source§

impl Display for ExactNum

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the number. The implementation is not available in no_std environment.

Source§

impl Div for ExactNum

Source§

type Output = ExactNum

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ExactNum) -> ExactNum

Performs the / operation. Read more
Source§

impl Div<&ExactNum> for &ExactNum

Source§

type Output = ExactNum

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &ExactNum) -> ExactNum

Performs the / operation. Read more
Source§

impl Div<&ExactNum> for ExactNum

Source§

type Output = ExactNum

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &ExactNum) -> ExactNum

Performs the / operation. Read more
Source§

impl Div<ExactNum> for &ExactNum

Source§

type Output = ExactNum

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ExactNum) -> ExactNum

Performs the / operation. Read more
Source§

impl Eq for ExactNum

Source§

impl From<i8> for ExactNum

Source§

fn from(v: i8) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for ExactNum

Source§

fn from(v: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for ExactNum

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for ExactNum

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for ExactNum

Source§

fn from(v: i128) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for ExactNum

Source§

fn from(v: u8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for ExactNum

Source§

fn from(v: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for ExactNum

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for ExactNum

Source§

fn from(v: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for ExactNum

Source§

fn from(v: u128) -> Self

Converts to this type from the input type.
Source§

impl FromExt<&str> for ExactNum

Source§

fn from_ext(v: &str, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Converts v to ExactNum with precision p using rounding mode rm.
Source§

impl<T> FromExt<T> for ExactNum
where ExactNum: From<T>,

Source§

fn from_ext(v: T, p: usize, rm: RoundingMode, _cc: &mut Consts) -> Self

Converts v to ExactNum with precision p using rounding mode rm.
Source§

impl FromStr for ExactNum

Available on crate feature std only.
Source§

fn from_str(src: &str) -> Result<ExactNum, Self::Err>

Returns parsed number or NAN in case of error. The implementation is not available in no_std environment.

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl LowerExp for ExactNum

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the number. The implementation is not available in no_std environment.

Source§

impl LowerHex for ExactNum

Available on crate feature std only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Mul for ExactNum

Source§

type Output = ExactNum

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ExactNum) -> ExactNum

Performs the * operation. Read more
Source§

impl Mul<&ExactNum> for &ExactNum

Source§

type Output = ExactNum

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &ExactNum) -> ExactNum

Performs the * operation. Read more
Source§

impl Mul<&ExactNum> for ExactNum

Source§

type Output = ExactNum

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &ExactNum) -> ExactNum

Performs the * operation. Read more
Source§

impl Mul<ExactNum> for &ExactNum

Source§

type Output = ExactNum

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ExactNum) -> ExactNum

Performs the * operation. Read more
Source§

impl Neg for ExactNum

Source§

type Output = ExactNum

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Neg for &ExactNum

Source§

type Output = ExactNum

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Octal for ExactNum

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the number. The implementation is not available in no_std environment.

Source§

impl PartialEq for ExactNum

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> PartialEq<&'a ExactNum> for ExactNum

Source§

fn eq(&self, other: &&'a ExactNum) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for ExactNum

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> PartialOrd<&'a ExactNum> for ExactNum

Source§

fn partial_cmp(&self, other: &&'a ExactNum) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub for ExactNum

Source§

type Output = ExactNum

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ExactNum) -> ExactNum

Performs the - operation. Read more
Source§

impl Sub<&ExactNum> for &ExactNum

Source§

type Output = ExactNum

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &ExactNum) -> ExactNum

Performs the - operation. Read more
Source§

impl Sub<&ExactNum> for ExactNum

Source§

type Output = ExactNum

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &ExactNum) -> ExactNum

Performs the - operation. Read more
Source§

impl Sub<ExactNum> for &ExactNum

Source§

type Output = ExactNum

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ExactNum) -> ExactNum

Performs the - operation. Read more
Source§

impl UpperExp for ExactNum

Available on crate feature std only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl UpperHex for ExactNum

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the number. The implementation is not available in no_std environment.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.