Function russell_lab::mat_mat_mul[][src]

pub fn mat_mat_mul(
    c: &mut Matrix,
    alpha: f64,
    a: &Matrix,
    b: &Matrix
) -> Result<(), &'static str>
Expand description

Performs the matrix-matrix multiplication resulting in a matrix

  c  :=  α ⋅  a   ⋅   b
(m,n)       (m,k)   (k,n)

Example

use russell_lab::*;
let a = Matrix::from(&[
    &[1.0, 2.0],
    &[3.0, 4.0],
    &[5.0, 6.0],
])?;
let b = Matrix::from(&[
    &[-1.0, -2.0, -3.0],
    &[-4.0, -5.0, -6.0],
])?;
let mut c = Matrix::new(3, 3);
mat_mat_mul(&mut c, 1.0, &a, &b);
let correct = "┌             ┐\n\
               │  -9 -12 -15 │\n\
               │ -19 -26 -33 │\n\
               │ -29 -40 -51 │\n\
               └             ┘";
assert_eq!(format!("{}", c), correct);