Trait MInv

Source
pub trait MInv: SquareMatrix
where Self::Output: SquareMatrix,
{ type Output; // Required method fn inv(&self) -> Option<Self::Output>; }

Required Associated Types§

Required Methods§

Source

fn inv(&self) -> Option<Self::Output>

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));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<F, M> MInv for M
where F: Inv<Output = F> + Zero, Self: Adj + Det<Output = F>, <Self as Adj>::Output: MMul<F>, <<Self as Adj>::Output as MMul<F>>::Output: SquareMatrix,

Source§

type Output = <<M as Adj>::Output as MMul<F>>::Output