Trait array_matrix::matrix::mul::MMul
source · pub trait MMul<Rhs>: Matrixwhere
Self::Output: Matrix,{
type Output;
fn mul(self, rhs: Rhs) -> Self::Output;
}
Required Associated Types§
Required Methods§
sourcefn mul(self, rhs: Rhs) -> Self::Output
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)