ScalarField

Trait ScalarField 

Source
pub trait ScalarField:
    Mul<Output = Self>
    + Div<Output = Self>
    + Add<Output = Self>
    + Sub<Output = Self>
    + Neg<Output = Self>
    + Default
    + Debug
    + Clone
    + Copy {
    const ZERO: Self;
    const ONE: Self;

    // Provided method
    fn recip(self) -> Self { ... }
}
Expand description

A type that supports the operations of a scalar field. An implementation should support:

  • Addition and subtraction
  • Multiplication and division
  • Negation
  • Zero (additive identity)
  • One (multiplicative identity)

Within the limitations of floating point arithmetic, all the following are required to hold:

  • (Associativity of addition) For all u, v, w: Self, (u + v) + w == u + (v + w).
  • (Commutativity of addition) For all u, v: Self, u + v == v + u.
  • (Additive identity) For all v: Self, v + Self::ZERO == v.
  • (Additive inverse) For all v: Self, v - v == v + (-v) == Self::ZERO.
  • (Associativity of multiplication) For all u, v, w: Self, (u * v) * w == u * (v * w).
  • (Commutativity of multiplication) For all u, v: Self, u * v == v * u.
  • (Multiplicative identity) For all v: Self, v * Self::ONE == v.
  • (Multiplicative inverse) For all v: Self, v / v == v * v.inverse() == Self::ONE.
  • (Distributivity over addition) For all a, b: Self, u, v: Self, (u + v) * a == u * a + v * a.

Required Associated Constants§

Source

const ZERO: Self

The additive identity.

Source

const ONE: Self

The multiplicative identity.

Provided Methods§

Source

fn recip(self) -> Self

The multiplicative inverse of this element. This is equivalent to 1.0 / self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ScalarField for f32

Source§

const ZERO: f32 = 0f32

Source§

const ONE: f32 = 1f32

Source§

impl ScalarField for f64

Source§

const ZERO: f64 = 0f64

Source§

const ONE: f64 = 1f64

Implementors§