Function lair::matrix::companion [−][src]
pub fn companion<A>(a: &[A]) -> Result<Array2<A>, InvalidInput> where
A: Scalar,
Constructs a companion matrix.
Errors
InvalidInput::Shape
ifa
contains less than two coefficients.InvalidInput::Value
ifa[0]
is zero.
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.]]));