use crate::ArgminInv;
use crate::Error;
use ndarray::Array2;
use ndarray_linalg::Inverse;
use num_complex::Complex;
macro_rules! make_inv {
($t:ty) => {
impl ArgminInv<Array2<$t>> for Array2<$t>
where
Array2<$t>: Inverse,
{
#[inline]
fn inv(&self) -> Result<Array2<$t>, Error> {
Ok(<Self as Inverse>::inv(&self)?)
}
}
impl ArgminInv<$t> for $t {
#[inline]
fn inv(&self) -> Result<$t, Error> {
Ok(1.0 / self)
}
}
};
}
make_inv!(f32);
make_inv!(f64);
make_inv!(Complex<f32>);
make_inv!(Complex<f64>);
#[cfg(test)]
use crate as argmin_math;
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/ndarray-tests-src/inv.rs"
));