Function russell_lab::mat_vec_mul[][src]

pub fn mat_vec_mul(v: &mut Vector, alpha: f64, a: &Matrix, u: &Vector)
Expand description

Performs the matrix-vector multiplication resulting in a vector

 v  := alpha * a   multiply  u
(m)          (m,n)          (n)

Note

The length of vector u must equal the rows of matrix a and the length of vector v must equal the columns of matrix a

Examples

use russell_lab::*;
let a = Matrix::from(&[
    &[ 5.0, -2.0, 1.0],
    &[-4.0,  0.0, 2.0],
    &[15.0, -6.0, 0.0],
    &[ 3.0,  5.0, 1.0],
]);
let u = Vector::from(&[1.0, 2.0, 3.0]);
let mut v = Vector::new(a.nrow());
mat_vec_mul(&mut v, 0.5, &a, &u);
let correct = "┌     ┐\n\
               │   2 │\n\
               │   1 │\n\
               │ 1.5 │\n\
               │   8 │\n\
               └     ┘";
assert_eq!(format!("{}", v), correct);