inv

Function inv 

pub fn inv<T, C>(ctx: &mut C, tensor: &Tensor<T>) -> Result<Tensor<T>, Error>
Expand description

Compute the inverse of a square matrix.

ยงExamples

use tenferro_linalg::inv;
use tenferro_prims::CpuContext;
use tenferro_tensor::{MemoryOrder, Tensor};

let mut ctx = CpuContext::new(1);
let col = MemoryOrder::ColumnMajor;
let a = Tensor::<f64>::from_slice(&[1.0, 0.0, 0.0, 1.0], &[2, 2], col).unwrap();
let inv_a = inv(&mut ctx, &a).unwrap();
assert_eq!(inv_a.dims(), &[2, 2]);