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§
Sourcefn svd<B: LinalgBackend>(
&self,
backend: &mut B,
) -> Result<(Tensor, Tensor, Tensor)>
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.
Sourcefn svd_with_options<B: LinalgBackend>(
&self,
options: SvdOptions,
backend: &mut B,
) -> Result<(Tensor, Tensor, Tensor)>
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.
Sourcefn qr<B: LinalgBackend>(&self, backend: &mut B) -> Result<(Tensor, Tensor)>
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.
Sourcefn qr_with_options<B: LinalgBackend>(
&self,
options: QrOptions,
backend: &mut B,
) -> Result<(Tensor, Tensor)>
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.
Sourcefn lu<B: LinalgBackend>(
&self,
backend: &mut B,
) -> Result<(Tensor, Tensor, Tensor, Tensor)>
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.
Sourcefn full_piv_lu<B: LinalgBackend>(
&self,
backend: &mut B,
) -> Result<(Tensor, Tensor, Tensor, Tensor, Tensor)>
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.
Sourcefn full_piv_lu_solve<B: LinalgBackend>(
&self,
b: &Tensor,
backend: &mut B,
) -> Result<Tensor>
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.
Sourcefn solve<B: LinalgBackend>(&self, b: &Tensor, backend: &mut B) -> Result<Tensor>
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.
Sourcefn cholesky<B: LinalgBackend>(&self, backend: &mut B) -> Result<Tensor>
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.
Sourcefn eigh<B: LinalgBackend>(&self, backend: &mut B) -> Result<(Tensor, Tensor)>
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.
Sourcefn eigh_with_options<B: LinalgBackend>(
&self,
options: EighOptions,
backend: &mut B,
) -> Result<(Tensor, Tensor)>
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.
Sourcefn eig<B: LinalgBackend>(&self, backend: &mut B) -> Result<(Tensor, Tensor)>
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.
Sourcefn triangular_solve<B: LinalgBackend>(
&self,
b: &Tensor,
left_side: bool,
lower: bool,
transpose_a: bool,
unit_diagonal: bool,
backend: &mut B,
) -> Result<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>
§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.
Sourcefn slogdet<B: LinalgBackend>(&self, backend: &mut B) -> Result<(Tensor, Tensor)>
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.
Sourcefn det<B: LinalgBackend>(&self, backend: &mut B) -> Result<Tensor>
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.
Sourcefn inv<B: LinalgBackend>(&self, backend: &mut B) -> Result<Tensor>
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.
Sourcefn eigvalsh<B: LinalgBackend>(&self, backend: &mut B) -> Result<Tensor>
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.
Sourcefn pinv<B: LinalgBackend>(&self, backend: &mut B) -> Result<Tensor>
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.
Sourcefn pinv_with_rtol<B: LinalgBackend>(
&self,
rtol: f64,
backend: &mut B,
) -> Result<Tensor>
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.
Sourcefn norm<B: LinalgBackend>(
&self,
ord: Option<f64>,
dim: Option<&[usize]>,
keepdim: bool,
backend: &mut B,
) -> Result<Tensor>
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.