cond

Function cond 

Source
pub fn cond<T, C>(
    ctx: &mut C,
    tensor: &Tensor<T>,
    kind: NormKind,
) -> Result<Tensor<T::Real>>
where T: KernelLinalgScalar + NormPrimal<C>, C: TensorLinalgContextFor<T> + TensorScalarContextFor<Standard<T::Real>>, C::Backend: 'static,
Expand description

Compute the matrix condition number with a selected norm convention.

Complex inputs return a real-valued tensor.

ยงExamples

use num_complex::Complex64;
use tenferro_device::LogicalMemorySpace;
use tenferro_linalg::{cond, NormKind};
use tenferro_prims::CpuContext;
use tenferro_tensor::{MemoryOrder, Tensor};

let mut ctx = CpuContext::new(1);
let a = Tensor::from_slice(
    &[
        Complex64::new(3.0, 4.0),
        Complex64::new(0.0, 0.0),
        Complex64::new(0.0, 0.0),
        Complex64::new(2.0, 0.0),
    ],
    &[2, 2],
    MemoryOrder::ColumnMajor,
)
.unwrap();
let c: Tensor<f64> = cond(&mut ctx, &a, NormKind::Fro).unwrap();
assert_eq!(c.logical_memory_space(), LogicalMemorySpace::MainMemory);