Trait MMul

Source
pub trait MMul<Rhs>: Matrix
where Self::Output: Matrix,
{ type Output; // Required method fn mul(self, rhs: Rhs) -> Self::Output; }

Required Associated Types§

Required Methods§

Source

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

Returns the matrix product

AB

§Arguments
  • rhs - A scalar or a matrix with height equal this matrix’s length
§Examples
// Scaling
let a = [
    [1.0, 2.0],
    [3.0, 4.0]
];
let b = 2.0;
let ab = [
    [2.0, 4.0],
    [6.0, 8.0]
];
assert_eq!(a.mul(b), ab)
 
// Matrix multiplication
let a = [
    [1.0],
    [2.0],
    [3.0]
];
let b = [
    [1.0, 2.0, 3.0]
];
let ab = [
    [1.0, 2.0, 3.0],
    [2.0, 4.0, 6.0],
    [3.0, 6.0, 9.0]
];
assert_eq!(a.mul(b), ab)

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<F, const L: usize, const H1: usize, const H2: usize> MMul<[[F; H2]; L]> for [[F; L]; H1]
where Self: Matrix, [[<F as Mul<F>>::Output; H2]; H1]: Matrix, F: Clone + Mul<F>, <F as Mul<F>>::Output: Add<<F as Mul<F>>::Output, Output = <F as Mul<F>>::Output>,

Source§

type Output = [[<F as Mul>::Output; H2]; H1]

Source§

fn mul(self, rhs: [[F; H2]; L]) -> Self::Output

Source§

impl<F, const L: usize, const H: usize> MMul<F> for [[F; L]; H]
where Self: Matrix, [[<F as Mul<F>>::Output; L]; H]: Matrix, F: Clone + Mul<F>,

Source§

type Output = [[<F as Mul>::Output; L]; H]

Source§

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

Implementors§