pinv

Function pinv 

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

Compute the Moore-Penrose pseudoinverse of a matrix.

ยงExamples

use tenferro_device::LogicalMemorySpace;
use tenferro_linalg::pinv;
use tenferro_prims::CpuContext;
use tenferro_tensor::{MemoryOrder, Tensor};

let mut ctx = CpuContext::new(1);
let a = Tensor::<f64>::from_slice(
    &[1.0, 2.0, 3.0, 4.0],
    &[2, 2],
    MemoryOrder::ColumnMajor,
).unwrap();
let ap = pinv(&mut ctx, &a, None).unwrap();
assert_eq!(ap.logical_memory_space(), LogicalMemorySpace::MainMemory);