Struct mpmfnum::float::FloatContext

source ·
pub struct FloatContext { /* private fields */ }
Expand description

Rounding contexts for fixed-precision, floating-point numbers with unbounded exponent.

The associated storage type is Float.

This is not IEEE 754 style rounding: values rounded under this context are base-2 scientific numbers (-1)^s * c * 2^exp where c is a fixed-precision unsigned integer and exp is an unbounded signed integer.

A FloatContext is parameterized by

  • maximum precision (see Real::prec),
  • rounding mode.

By default, the rounding mode is RoundingMode::NearestTiesToEven. This rounding context is similar to the one implemented by Rug (MPFR).

Implementations§

source§

impl FloatContext

source

pub fn new(prec: usize) -> Self

Constructs a new rounding context.

source

pub fn with_max_p(self, prec: usize) -> Self

Sets the precision of this context.

source

pub fn with_rm(self, rm: RoundingMode) -> Self

Sets the rounding mode of this context.

source

pub fn max_p(&self) -> usize

Returns the maximum precision allowed by this format.

source

pub fn rm(&self) -> RoundingMode

Returns the rounding mode of this context.

Trait Implementations§

source§

impl Clone for FloatContext

source§

fn clone(&self) -> FloatContext

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for FloatContext

source§

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

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

impl RoundedAbs for FloatContext

source§

fn abs<N: Real>(&self, src: &N) -> Self::Format

Performs rounded |x|.
source§

impl RoundedAcos for FloatContext

source§

fn acos<N: Real>(&self, src: &N) -> Self::Format

Performs rounded arccos(x).
source§

impl RoundedAcosh for FloatContext

source§

fn acosh<N: Real>(&self, src: &N) -> Self::Format

Performs rounded arcosh(x).
source§

impl RoundedAdd for FloatContext

source§

fn add<N1, N2>(&self, src1: &N1, src2: &N2) -> Self::Format
where N1: Real, N2: Real,

Performs rounded x + y.
source§

impl RoundedAsin for FloatContext

source§

fn asin<N: Real>(&self, src: &N) -> Self::Format

Performs rounded arcsin(x).
source§

impl RoundedAsinh for FloatContext

source§

fn asinh<N: Real>(&self, src: &N) -> Self::Format

Performs rounded arsinh(x).
source§

impl RoundedAtan for FloatContext

source§

fn atan<N: Real>(&self, src: &N) -> Self::Format

Performs rounded arctan(x).
source§

impl RoundedAtan2 for FloatContext

source§

fn atan2<N1, N2>(&self, src1: &N1, src2: &N2) -> Self::Format
where N1: Real, N2: Real,

Performs rounded arctan(y / x).
source§

impl RoundedAtanh for FloatContext

source§

fn atanh<N: Real>(&self, src: &N) -> Self::Format

Performs rounded artanh(x).
source§

impl RoundedCbrt for FloatContext

source§

fn cbrt<N: Real>(&self, src: &N) -> Self::Format

Performs rounded cbrt(x).
source§

impl RoundedCos for FloatContext

source§

fn cos<N: Real>(&self, src: &N) -> Self::Format

Performs rounded cos(x).
source§

impl RoundedCosPi for FloatContext

source§

fn cos_pi<N: Real>(&self, src: &N) -> Self::Format

Performs rounded cos(pi * x).
source§

impl RoundedCosh for FloatContext

source§

fn cosh<N: Real>(&self, src: &N) -> Self::Format

Performs rounded cosh(x).
source§

impl RoundedDiv for FloatContext

source§

fn div<N1, N2>(&self, src1: &N1, src2: &N2) -> Self::Format
where N1: Real, N2: Real,

Performs rounded x / y.
source§

impl RoundedErf for FloatContext

source§

fn erf<N: Real>(&self, src: &N) -> Self::Format

Performs rounded erf(x).
source§

impl RoundedErfc for FloatContext

source§

fn erfc<N: Real>(&self, src: &N) -> Self::Format

Performs rounded erfc(x).
source§

impl RoundedExp for FloatContext

source§

fn exp<N: Real>(&self, src: &N) -> Self::Format

Performs rounded exp(x).
source§

impl RoundedExp10m1 for FloatContext

source§

fn exp10m1<N: Real>(&self, src: &N) -> Self::Format

Performs rounded 10^x - 1.
source§

impl RoundedExp2 for FloatContext

source§

fn exp2<N: Real>(&self, src: &N) -> Self::Format

Performs rounded 2^x.
source§

impl RoundedExp2m1 for FloatContext

source§

fn exp2m1<N: Real>(&self, src: &N) -> Self::Format

Performs rounded 2^x - 1.
source§

impl RoundedExpm1 for FloatContext

source§

fn expm1<N: Real>(&self, src: &N) -> Self::Format

Performs rounded e^x - 1.
source§

impl RoundedFMA for FloatContext

source§

fn fma<N1, N2, N3>(&self, src1: &N1, src2: &N2, src3: &N3) -> Self::Format
where N1: Real, N2: Real, N3: Real,

Performs rounded a*b + c.
source§

impl RoundedFmod for FloatContext

source§

fn fmod<N1, N2>(&self, src1: &N1, src2: &N2) -> Self::Format
where N1: Real, N2: Real,

Performs rounded fmod(x, y).
source§

impl RoundedGamma for FloatContext

source§

fn tgamma<N: Real>(&self, src: &N) -> Self::Format

Performs rounded tgamma(x).
source§

impl RoundedHypot for FloatContext

source§

fn hypot<N1, N2>(&self, src1: &N1, src2: &N2) -> Self::Format
where N1: Real, N2: Real,

Performs rounded sqrt(x^2 + y^2).
source§

impl RoundedLgamma for FloatContext

source§

fn lgamma<N: Real>(&self, src: &N) -> Self::Format

Performs rounded lgamma(x).
source§

impl RoundedLog for FloatContext

source§

fn log<N: Real>(&self, src: &N) -> Self::Format

Performs rounded ln(x).
source§

impl RoundedLog10 for FloatContext

source§

fn log10<N: Real>(&self, src: &N) -> Self::Format

Performs rounded log10(x).
source§

impl RoundedLog10p1 for FloatContext

source§

fn log10p1<N: Real>(&self, src: &N) -> Self::Format

Performs rounded log10(x + 1).
source§

impl RoundedLog1p for FloatContext

source§

fn log1p<N: Real>(&self, src: &N) -> Self::Format

Performs rounded log(x + 1).
source§

impl RoundedLog2 for FloatContext

source§

fn log2<N: Real>(&self, src: &N) -> Self::Format

Performs rounded log2(x).
source§

impl RoundedLog2p1 for FloatContext

source§

fn log2p1<N: Real>(&self, src: &N) -> Self::Format

Performs rounded log2(x + 1).
source§

impl RoundedMul for FloatContext

source§

fn mul<N1, N2>(&self, src1: &N1, src2: &N2) -> Self::Format
where N1: Real, N2: Real,

Performs rounded x * y.
source§

impl RoundedNeg for FloatContext

source§

fn neg<N: Real>(&self, src: &N) -> Self::Format

Performs rounded -x.
source§

impl RoundedPow for FloatContext

source§

fn pow<N1, N2>(&self, src1: &N1, src2: &N2) -> Self::Format
where N1: Real, N2: Real,

Performs rounded x ^ y.
source§

impl RoundedRecip for FloatContext

source§

fn recip<N: Real>(&self, src: &N) -> Self::Format

Performs rounded 1/x.
source§

impl RoundedRecipSqrt for FloatContext

source§

fn recip_sqrt<N: Real>(&self, src: &N) -> Self::Format

Performs rounded 1/sqrt(x).
source§

impl RoundedRemainder for FloatContext

source§

fn remainder<N1, N2>(&self, src1: &N1, src2: &N2) -> Self::Format
where N1: Real, N2: Real,

Performs rounded remainder(x, y).
source§

impl RoundedSin for FloatContext

source§

fn sin<N: Real>(&self, src: &N) -> Self::Format

Performs rounded sin(x).
source§

impl RoundedSinPi for FloatContext

source§

fn sin_pi<N: Real>(&self, src: &N) -> Self::Format

Performs rounded sin(pi * x).
source§

impl RoundedSinh for FloatContext

source§

fn sinh<N: Real>(&self, src: &N) -> Self::Format

Performs rounded sinh(x).
source§

impl RoundedSqrt for FloatContext

source§

fn sqrt<N: Real>(&self, src: &N) -> Self::Format

Performs rounded sqrt(x).
source§

impl RoundedSub for FloatContext

source§

fn sub<N1, N2>(&self, src1: &N1, src2: &N2) -> Self::Format
where N1: Real, N2: Real,

Performs rounded x - y.
source§

impl RoundedTan for FloatContext

source§

fn tan<N: Real>(&self, src: &N) -> Self::Format

Performs rounded tan(x).
source§

impl RoundedTanPi for FloatContext

source§

fn tan_pi<N: Real>(&self, src: &N) -> Self::Format

Performs rounded tan(pi * x).
source§

impl RoundedTanh for FloatContext

source§

fn tanh<N: Real>(&self, src: &N) -> Self::Format

Performs rounded tanh(x).
source§

impl RoundingContext for FloatContext

§

type Format = Float

Result type of operations under this context.
source§

fn round<T: Real>(&self, val: &T) -> Self::Format

Rounds any Real value to a RoundingContext::Format value, rounding according to this RoundingContext.

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> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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>,

§

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.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.