Struct Fast

Source
pub struct Fast<F>(/* private fields */);
Expand description

“fast-math” wrapper for f32 and f64.

The Fast type enforces no invariant and can hold any f32, f64 values. See crate docs for more details.

Implementations§

Source§

impl<F> Fast<F>

Source

pub unsafe fn new(value: F) -> Self

Create a new fast value

§Safety

The value can be used with the fast_fadd etc intrinsics without checks after it has been created like this. Refer to Rust and other sources for documentation on which operations are valid (might change with time).

Be wary of operations creating invalid values in Fast which they could potentially do depending on the operation.

Examples found in repository?
examples/sums.rs (line 7)
6pub unsafe fn fast_sum(xs: &[f64]) -> f64 {
7    xs.iter().map(|&x| Fast::new(x)).fold(Fast::new(0.), |acc, x| acc + x).get()
8}
9
10// for demonstration purposes
11pub unsafe fn fast_dot(xs: &[f64], ys: &[f64]) -> f64 {
12    xs.iter().zip(ys).fold(Fast::new(0.), |acc, (&x, &y)| acc + Fast::new(x) * Fast::new(y)).get()
13}
Source

pub fn get(self) -> F

Get the inner value

Examples found in repository?
examples/sums.rs (line 7)
6pub unsafe fn fast_sum(xs: &[f64]) -> f64 {
7    xs.iter().map(|&x| Fast::new(x)).fold(Fast::new(0.), |acc, x| acc + x).get()
8}
9
10// for demonstration purposes
11pub unsafe fn fast_dot(xs: &[f64], ys: &[f64]) -> f64 {
12    xs.iter().zip(ys).fold(Fast::new(0.), |acc, (&x, &y)| acc + Fast::new(x) * Fast::new(y)).get()
13}

Trait Implementations§

Source§

impl Add<Fast<f32>> for f32

Source§

type Output = Fast<f32>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Fast<f32>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Fast<f64>> for f64

Source§

type Output = Fast<f64>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Fast<f64>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<f32> for Fast<f32>

Source§

type Output = Fast<f32>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f32) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<f64> for Fast<f64>

Source§

type Output = Fast<f64>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for Fast<f32>

Source§

type Output = Fast<f32>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for Fast<f64>

Source§

type Output = Fast<f64>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<F, Rhs> AddAssign<Rhs> for Fast<F>
where Self: Add<Rhs, Output = Self> + Copy,

Source§

fn add_assign(&mut self, rhs: Rhs)

Performs the += operation. Read more
Source§

impl<F: Clone> Clone for Fast<F>

Source§

fn clone(&self) -> Fast<F>

Returns a duplicate 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<F: Debug> Debug for Fast<F>

Source§

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

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

impl<F: Display> Display for Fast<F>

Source§

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

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

impl Div<Fast<f32>> for f32

Source§

type Output = Fast<f32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Fast<f32>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Fast<f64>> for f64

Source§

type Output = Fast<f64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Fast<f64>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f32> for Fast<f32>

Source§

type Output = Fast<f32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f64> for Fast<f64>

Source§

type Output = Fast<f64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for Fast<f32>

Source§

type Output = Fast<f32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for Fast<f64>

Source§

type Output = Fast<f64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl<F, Rhs> DivAssign<Rhs> for Fast<F>
where Self: Div<Rhs, Output = Self> + Copy,

Source§

fn div_assign(&mut self, rhs: Rhs)

Performs the /= operation. Read more
Source§

impl Into<f32> for Fast<f32>

Source§

fn into(self) -> f32

Converts this type into the (usually inferred) input type.
Source§

impl Into<f64> for Fast<f64>

Source§

fn into(self) -> f64

Converts this type into the (usually inferred) input type.
Source§

impl<F: LowerExp> LowerExp for Fast<F>

Source§

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

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

impl Mul<Fast<f32>> for f32

Source§

type Output = Fast<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Fast<f32>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Fast<f64>> for f64

Source§

type Output = Fast<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Fast<f64>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f32> for Fast<f32>

Source§

type Output = Fast<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f64> for Fast<f64>

Source§

type Output = Fast<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for Fast<f32>

Source§

type Output = Fast<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for Fast<f64>

Source§

type Output = Fast<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<F, Rhs> MulAssign<Rhs> for Fast<F>
where Self: Mul<Rhs, Output = Self> + Copy,

Source§

fn mul_assign(&mut self, rhs: Rhs)

Performs the *= operation. Read more
Source§

impl<F: PartialEq> PartialEq for Fast<F>

Source§

fn eq(&self, other: &Fast<F>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F: PartialOrd> PartialOrd for Fast<F>

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 Rem<Fast<f32>> for f32

Source§

type Output = Fast<f32>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Fast<f32>) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<Fast<f64>> for f64

Source§

type Output = Fast<f64>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Fast<f64>) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<f32> for Fast<f32>

Source§

type Output = Fast<f32>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: f32) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<f64> for Fast<f64>

Source§

type Output = Fast<f64>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: f64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem for Fast<f32>

Source§

type Output = Fast<f32>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem for Fast<f64>

Source§

type Output = Fast<f64>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
Source§

impl<F, Rhs> RemAssign<Rhs> for Fast<F>
where Self: Rem<Rhs, Output = Self> + Copy,

Source§

fn rem_assign(&mut self, rhs: Rhs)

Performs the %= operation. Read more
Source§

impl Sub<Fast<f32>> for f32

Source§

type Output = Fast<f32>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Fast<f32>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Fast<f64>> for f64

Source§

type Output = Fast<f64>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Fast<f64>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<f32> for Fast<f32>

Source§

type Output = Fast<f32>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f32) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<f64> for Fast<f64>

Source§

type Output = Fast<f64>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for Fast<f32>

Source§

type Output = Fast<f32>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for Fast<f64>

Source§

type Output = Fast<f64>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<F, Rhs> SubAssign<Rhs> for Fast<F>
where Self: Sub<Rhs, Output = Self> + Copy,

Source§

fn sub_assign(&mut self, rhs: Rhs)

Performs the -= operation. Read more
Source§

impl<F: UpperExp> UpperExp for Fast<F>

Source§

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

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

impl<F: Copy> Copy for Fast<F>

Source§

impl<F> StructuralPartialEq for Fast<F>

Auto Trait Implementations§

§

impl<F> Freeze for Fast<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for Fast<F>
where F: RefUnwindSafe,

§

impl<F> Send for Fast<F>
where F: Send,

§

impl<F> Sync for Fast<F>
where F: Sync,

§

impl<F> Unpin for Fast<F>
where F: Unpin,

§

impl<F> UnwindSafe for Fast<F>
where F: UnwindSafe,

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

Source§

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

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.