Skip to main content

TypedTensorLinalgExt

Trait TypedTensorLinalgExt 

Source
pub trait TypedTensorLinalgExt<T: LinalgScalar> {
Show 21 methods // Required methods fn svd<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedSvd<T>>; fn svd_with_options<B: LinalgBackend>( &self, options: SvdOptions, backend: &mut B, ) -> Result<TypedSvd<T>>; fn qr<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<(TypedTensor<T>, TypedTensor<T>)>; fn qr_with_options<B: LinalgBackend>( &self, options: QrOptions, backend: &mut B, ) -> Result<(TypedTensor<T>, TypedTensor<T>)>; fn lu<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedLu<T>>; fn full_piv_lu<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<TypedFullPivLu<T>>; fn full_piv_lu_solve<B: LinalgBackend>( &self, b: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>; fn solve<B: LinalgBackend>( &self, b: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>; fn cholesky<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<TypedTensor<T>>; fn eigh<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<(TypedTensor<<T as TensorScalar>::Real>, TypedTensor<T>)>; fn eigh_with_options<B: LinalgBackend>( &self, options: EighOptions, backend: &mut B, ) -> Result<(TypedTensor<<T as TensorScalar>::Real>, TypedTensor<T>)>; fn eig<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedEig<T>>; fn triangular_solve<B: LinalgBackend>( &self, b: &TypedTensor<T>, left_side: bool, lower: bool, transpose_a: bool, unit_diagonal: bool, backend: &mut B, ) -> Result<TypedTensor<T>>; fn slogdet<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<(TypedTensor<T>, TypedTensor<<T as TensorScalar>::Real>)>; fn det<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn inv<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn eigvalsh<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<TypedTensor<<T as TensorScalar>::Real>>; fn eigvals<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<TypedTensor<T::Complex>>; fn pinv<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn pinv_with_rtol<B: LinalgBackend>( &self, rtol: f64, backend: &mut B, ) -> Result<TypedTensor<T>>; fn norm<B: LinalgBackend>( &self, ord: Option<f64>, dim: Option<&[usize]>, keepdim: bool, backend: &mut B, ) -> Result<TypedTensor<<T as TensorScalar>::Real>>;
}
Expand description

Linear algebra methods with statically typed inputs and outputs.

Singular values, Hermitian eigenvalues, determinant log-magnitudes, and norms use T::Real; general eigenvalues and eigenvectors use T::Complex.

§Examples

use tenferro_cpu::{with_cpu_exec_session, CpuBackend};
use tenferro_linalg::TypedTensorLinalgExt;
use tenferro_tensor::{BackendSessionHost, TypedTensor};

let input = TypedTensor::<f64>::from_vec_col_major(
    vec![2, 2],
    vec![2.0, 0.0, 0.0, 4.0],
)?;
let mut host = CpuBackend::new();
let (_u, singular_values, _vt) = host.with_backend_session(|session| {
    with_cpu_exec_session(session, |backend| input.svd(backend))
        .expect("CpuBackend must expose a CpuExecSession")
})?;
assert_eq!(singular_values.as_slice()?, &[4.0, 2.0]);

Required Methods§

Source

fn svd<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedSvd<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, numerical, output-contract, or typed-downcast errors.

Source

fn svd_with_options<B: LinalgBackend>( &self, options: SvdOptions, backend: &mut B, ) -> Result<TypedSvd<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for metadata/options, plus backend or typed-output errors.

Source

fn qr<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<(TypedTensor<T>, TypedTensor<T>)>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, numerical, output-contract, or typed-downcast errors.

Source

fn qr_with_options<B: LinalgBackend>( &self, options: QrOptions, backend: &mut B, ) -> Result<(TypedTensor<T>, TypedTensor<T>)>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for metadata/options, plus backend or typed-output errors.

Source

fn lu<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedLu<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, numerical, output-contract, or typed-downcast errors.

Source

fn full_piv_lu<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<TypedFullPivLu<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, numerical, output-contract, or typed-downcast errors.

Source

fn full_piv_lu_solve<B: LinalgBackend>( &self, b: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns incompatible-input validation, backend, singular, or typed-downcast errors.

Source

fn solve<B: LinalgBackend>( &self, b: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns incompatible-input validation, backend, singular, or typed-downcast errors.

Source

fn cholesky<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns matrix validation, backend, positive-definiteness, or typed-downcast errors.

Source

fn eigh<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<(TypedTensor<<T as TensorScalar>::Real>, TypedTensor<T>)>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, convergence, output-contract, or typed-downcast errors.

Source

fn eigh_with_options<B: LinalgBackend>( &self, options: EighOptions, backend: &mut B, ) -> Result<(TypedTensor<<T as TensorScalar>::Real>, TypedTensor<T>)>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for metadata/options, plus backend or typed-output errors.

Source

fn eig<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedEig<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, convergence, output-contract, or typed-downcast errors.

Source

fn triangular_solve<B: LinalgBackend>( &self, b: &TypedTensor<T>, left_side: bool, lower: bool, transpose_a: bool, unit_diagonal: bool, backend: &mut B, ) -> Result<TypedTensor<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns incompatible-input/flag validation, backend, singular, or typed-output errors.

Source

fn slogdet<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<(TypedTensor<T>, TypedTensor<<T as TensorScalar>::Real>)>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, numerical, output-contract, or typed-downcast errors.

Source

fn det<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, numerical, output-contract, or typed-downcast errors.

Source

fn inv<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, singular-solve, or typed-downcast errors.

Source

fn eigvalsh<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<TypedTensor<<T as TensorScalar>::Real>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, convergence, output-contract, or typed-downcast errors.

Source

fn eigvals<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<TypedTensor<T::Complex>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, convergence, output-contract, or typed-downcast errors.

Source

fn pinv<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation, backend, numerical, output-contract, or typed-downcast errors.

Source

fn pinv_with_rtol<B: LinalgBackend>( &self, rtol: f64, backend: &mut B, ) -> Result<TypedTensor<T>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns a validation error for invalid rtol, plus backend or typed-output errors.

Source

fn norm<B: LinalgBackend>( &self, ord: Option<f64>, dim: Option<&[usize]>, keepdim: bool, backend: &mut B, ) -> Result<TypedTensor<<T as TensorScalar>::Real>>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for axes/order combinations, backend, or typed-output errors.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: LinalgScalar> TypedTensorLinalgExt<T> for TypedTensor<T>

Source§

fn svd<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedSvd<T>>

Source§

fn svd_with_options<B: LinalgBackend>( &self, options: SvdOptions, backend: &mut B, ) -> Result<TypedSvd<T>>

Source§

fn qr<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<(TypedTensor<T>, TypedTensor<T>)>

Source§

fn qr_with_options<B: LinalgBackend>( &self, options: QrOptions, backend: &mut B, ) -> Result<(TypedTensor<T>, TypedTensor<T>)>

Source§

fn lu<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedLu<T>>

Source§

fn full_piv_lu_solve<B: LinalgBackend>( &self, b: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

Source§

fn full_piv_lu<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<TypedFullPivLu<T>>

Source§

fn solve<B: LinalgBackend>( &self, b: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

Source§

fn cholesky<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Source§

fn eigh<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<(TypedTensor<<T as TensorScalar>::Real>, TypedTensor<T>)>

Source§

fn eigh_with_options<B: LinalgBackend>( &self, options: EighOptions, backend: &mut B, ) -> Result<(TypedTensor<<T as TensorScalar>::Real>, TypedTensor<T>)>

Source§

fn eig<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedEig<T>>

Source§

fn triangular_solve<B: LinalgBackend>( &self, b: &TypedTensor<T>, left_side: bool, lower: bool, transpose_a: bool, unit_diagonal: bool, backend: &mut B, ) -> Result<TypedTensor<T>>

Source§

fn slogdet<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<(TypedTensor<T>, TypedTensor<<T as TensorScalar>::Real>)>

Source§

fn det<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Source§

fn inv<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Source§

fn eigvalsh<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<TypedTensor<<T as TensorScalar>::Real>>

Source§

fn eigvals<B: LinalgBackend>( &self, backend: &mut B, ) -> Result<TypedTensor<T::Complex>>

Source§

fn pinv<B: LinalgBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Source§

fn pinv_with_rtol<B: LinalgBackend>( &self, rtol: f64, backend: &mut B, ) -> Result<TypedTensor<T>>

Source§

fn norm<B: LinalgBackend>( &self, ord: Option<f64>, dim: Option<&[usize]>, keepdim: bool, backend: &mut B, ) -> Result<TypedTensor<<T as TensorScalar>::Real>>

Implementors§