Function lair::matrix::companion[][src]

pub fn companion<A>(a: &[A]) -> Result<Array2<A>, InvalidInput> where
    A: Scalar

Constructs a companion matrix.

Errors

Examples

use lair::matrix::companion;

let a = vec![1., -10., 31., -30.];
let c = companion(&a).expect("valid input");
assert_eq!(c, ndarray::aview2(&[[10., -31., 30.], [1., 0., 0.], [0., 1., 0.]]));