Trait array_matrix::matrix::inv::MInv

source ·
pub trait MInv: SquareMatrixwhere
    Self::Output: SquareMatrix,
{ type Output; fn inv(&self) -> Option<Self::Output>; }

Required Associated Types§

Required Methods§

Returns the inverted matrix if the matrix is non-singular

A⁻¹

Examples
// Returns none if matrix is singular
let a = [
    [1.0, 2.0],
    [2.0, 4.0]
];
assert_eq!(a.inv(), None);
 
// Otherwise equals adjunct matrix divided by determinant
let a = [
    [1.0, 2.0],
    [3.0, 4.0]
];
let ai = a.adj().dot(a.det().recip());
assert_eq!(a.inv(), Some(ai));

Implementors§