pub fn norm<T, C>(
ctx: &mut C,
tensor: &Tensor<T>,
kind: NormKind,
) -> Result<Tensor<T::Real>>Expand description
Compute a norm.
Complex inputs return a tensor over the associated real scalar type.
ยงExamples
use num_complex::Complex64;
use tenferro_device::LogicalMemorySpace;
use tenferro_linalg::{norm, 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)],
&[2],
MemoryOrder::ColumnMajor,
)
.unwrap();
let n: Tensor<f64> = norm(&mut ctx, &a, NormKind::Fro).unwrap();
assert_eq!(n.logical_memory_space(), LogicalMemorySpace::MainMemory);