pub fn pinv<T: KernelLinalgScalar + ScaleTensorByRealSameShape<C> + Conjugate, C>(
ctx: &mut C,
tensor: &Tensor<T>,
rcond: Option<f64>,
) -> Result<Tensor<T>>where
C: TensorLinalgContextFor<T> + TensorResolveConjContextFor<T> + TensorScalarContextFor<Standard<T::Real>> + TensorSemiringContextFor<Standard<T>>,
C::Backend: 'static,
T::Real: Float + KeepCountScalar,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);