Skip to main content

Multiplication

Trait Multiplication 

Source
pub trait Multiplication:
    Addition
    + Mul<Output = Self>
    + MulAssign<Self>
    + Div<Self, Output = Self>
    + DivAssign<Self>
    + Rem<Self, Output = Self>
    + RemAssign<Self> {
    const ONE: Self;

    // Required methods
    fn mul_add(self, a: Self, b: Self) -> Self;
    fn mul_add_assign(&mut self, a: Self, b: Self);
    fn powi(self, exp: i32) -> Self;

    // Provided methods
    fn half(self) -> Self { ... }
    fn double(self) -> Self { ... }
    fn inv(self) -> Self { ... }
}
Expand description

The Multiplication trait provides the multiplicative identity and operations for a Number type.

Required Associated Constants§

Source

const ONE: Self

The multiplicative identity.

Required Methods§

Source

fn mul_add(self, a: Self, b: Self) -> Self

Returns self + a * b, potentially as a fused multiply-add operation.

Source

fn mul_add_assign(&mut self, a: Self, b: Self)

Replace self with self + a * b, potentially as a fused multiply-add-assign operation.

Source

fn powi(self, exp: i32) -> Self

Returns self raised to the power of exp.

Provided Methods§

Source

fn half(self) -> Self

Returns self / 2.

Source

fn double(self) -> Self

Returns self * 2.

Source

fn inv(self) -> Self

Returns the multiplicative inverse of self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Multiplication for f32

Source§

const ONE: Self = 1.0

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for f64

Source§

const ONE: Self = 1.0

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for i8

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for i16

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for i32

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for i64

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for i128

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for isize

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for u8

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for u16

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for u32

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for u64

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for u128

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Source§

impl Multiplication for usize

Source§

const ONE: Self = 1

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

fn mul_add_assign(&mut self, a: Self, b: Self)

Source§

fn powi(self, exp: i32) -> Self

Implementors§