Skip to main content

TensorLinalgExt

Trait TensorLinalgExt 

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

Linear algebra methods for dtype-erased owned tensors.

§Examples

use tenferro_cpu::{with_cpu_exec_session, CpuBackend};
use tenferro_linalg::TensorLinalgExt;
use tenferro_tensor::{BackendSessionHost, Tensor};

let a = Tensor::from_vec_col_major(vec![2, 2], vec![2.0_f64, 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| a.svd(backend))
        .expect("CpuBackend must expose a CpuExecSession")
})?;
assert_eq!(singular_values.as_slice::<f64>()?, &[4.0, 2.0]);

Required Methods§

Source

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

§Errors

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

Source

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

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for matrix metadata or options, plus SVD backend errors.

Source

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

§Errors

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

Source

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

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for matrix metadata or options, plus QR backend errors.

Source

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

§Errors

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

Source

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

§Errors

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

Source

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

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for incompatible inputs or a backend/singular-system error.

Source

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

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for incompatible inputs or a backend/singular-system error.

Source

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

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for a non-square input or backend/numerical errors.

Source

fn eigh<B: LinalgBackend>(&self, backend: &mut B) -> Result<(Tensor, Tensor)>

§Errors

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

Source

fn eigh_with_options<B: LinalgBackend>( &self, options: EighOptions, backend: &mut B, ) -> Result<(Tensor, Tensor)>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for matrix metadata or options, plus Eigh backend errors.

Source

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

§Errors

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

Source

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

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for incompatible inputs/flags or backend/numerical errors.

Source

fn slogdet<B: LinalgBackend>(&self, backend: &mut B) -> Result<(Tensor, Tensor)>

§Errors

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

Source

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

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns the validation, backend, numerical, or contract errors from Self::slogdet.

Source

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

§Errors

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

Source

fn eigvalsh<B: LinalgBackend>(&self, backend: &mut B) -> Result<Tensor>

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns the validation, backend, convergence, or contract errors from Self::eigh.

Source

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

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns the validation, backend, convergence, or contract errors from Self::eig.

Source

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

§Errors

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

Source

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

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns a validation error for invalid rtol, plus errors from Self::pinv.

Source

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

§Errors

Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation. Returns validation errors for axes/order combinations or required backend operations.

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 TensorLinalgExt for Tensor

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn eigh<B: LinalgBackend>(&self, backend: &mut B) -> Result<(Tensor, Tensor)>

Source§

fn eigh_with_options<B: LinalgBackend>( &self, options: EighOptions, backend: &mut B, ) -> Result<(Tensor, Tensor)>

Source§

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

Source§

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

Source§

fn slogdet<B: LinalgBackend>(&self, backend: &mut B) -> Result<(Tensor, Tensor)>

Source§

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

Source§

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

Source§

fn eigvalsh<B: LinalgBackend>(&self, backend: &mut B) -> Result<Tensor>

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§