pub trait TensorReadLinalgExt {
Show 25 methods
// Required methods
fn svd_read(
self,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor, Tensor)>;
fn svdvals_read(self, session: &mut dyn Engine) -> Result<Tensor>;
fn svd_with_options_read(
self,
options: SvdOptions,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor, Tensor)>;
fn svd_full_read(
self,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor, Tensor)>;
fn qr_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>;
fn qr_with_options_read(
self,
options: QrOptions,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor)>;
fn rank_revealing_qr_read(
self,
options: RankRevealingQrOptions,
session: &mut dyn Engine,
) -> Result<RankRevealingQrResult<Tensor>>;
fn lu_read(
self,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor, Tensor, Tensor)>;
fn full_piv_lu_read(
self,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor, Tensor, Tensor, Tensor)>;
fn full_piv_lu_solve_read(
self,
b: TensorRead<'_>,
session: &mut dyn Engine,
) -> Result<Tensor>;
fn solve_read(
self,
b: TensorRead<'_>,
session: &mut dyn Engine,
) -> Result<Tensor>;
fn cholesky_read(self, session: &mut dyn Engine) -> Result<Tensor>;
fn eigh_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>;
fn eigh_with_options_read(
self,
options: EighOptions,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor)>;
fn eig_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>;
fn triangular_solve_read(
self,
b: TensorRead<'_>,
left_side: bool,
lower: bool,
transpose_a: bool,
unit_diagonal: bool,
session: &mut dyn Engine,
) -> Result<Tensor>;
fn slogdet_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>;
fn det_read(self, session: &mut dyn Engine) -> Result<Tensor>;
fn inv_read(self, session: &mut dyn Engine) -> Result<Tensor>;
fn eigvalsh_read(self, session: &mut dyn Engine) -> Result<Tensor>;
fn eigvals_read(self, session: &mut dyn Engine) -> Result<Tensor>;
fn pinv_read(self, session: &mut dyn Engine) -> Result<Tensor>;
fn pinv_with_rtol_read(
self,
rtol: f64,
session: &mut dyn Engine,
) -> Result<Tensor>;
fn norm_read(
self,
ord: Option<f64>,
dim: Option<&[usize]>,
keepdim: bool,
session: &mut dyn Engine,
) -> Result<Tensor>;
// Provided method
fn solve_read_into(
self,
b: TensorRead<'_>,
out: TensorWrite<'_>,
session: &mut dyn Engine,
) -> Result<()>
where Self: Sized { ... }
}Expand description
Linear algebra methods for borrowed tensor reads.
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_linalg::TensorReadLinalgExt;
use tenferro_tensor::{Tensor, TensorRead};
let input = Tensor::from_vec_col_major(vec![2, 2], vec![2.0_f64, 0.0, 0.0, 4.0])?;
let mut host = tenferro_cpu::CpuEngine::serial();
let (_q, r) = {
TensorRead::from_tensor(&input).qr_read(&mut host)
}?;
assert_eq!(r.shape(), &[2, 2]);Required Methods§
Sourcefn svd_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor, Tensor)>
fn svd_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor, Tensor)>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, same-placement materialization, backend, numerical, or contract errors.
§Examples
let (_u, s, _vt) = {
TensorRead::from_tensor(&a).svd_read(&mut host)
}?;
assert_eq!(s.shape(), &[2]);Sourcefn svdvals_read(self, session: &mut dyn Engine) -> Result<Tensor>
fn svdvals_read(self, session: &mut dyn Engine) -> Result<Tensor>
Compute singular values from a borrowed tensor read target.
Eligible faer host views are consumed without a full input copy. A provider that requires owned compact storage may materialize explicitly; unsupported providers return a typed error.
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected
backend has no borrowed values-only capability.
§Examples
let values = TensorRead::from_tensor(&a).svdvals_read(&mut host)?;
assert_eq!(values.as_slice::<f64>()?, &[4.0, 2.0]);Sourcefn svd_with_options_read(
self,
options: SvdOptions,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor, Tensor)>
fn svd_with_options_read( self, options: SvdOptions, session: &mut dyn Engine, ) -> Result<(Tensor, Tensor, Tensor)>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation errors for metadata/options, plus read/materialization or SVD errors.
§Examples
let (_u, s, _vt) = {
TensorRead::from_tensor(&a).svd_with_options_read(SvdOptions::default(), &mut host)
}?;
assert_eq!(s.shape(), &[2]);Sourcefn svd_full_read(
self,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor, Tensor)>
fn svd_full_read( self, session: &mut dyn Engine, ) -> Result<(Tensor, Tensor, Tensor)>
Compute the full-matrices SVD (U, S, Vt) from a borrowed tensor read
target, with U shaped m x m and Vt shaped n x n.
Eligible faer host views (rank 2, host placement, non-negative strides) are consumed without an input copy. A provider that requires owned compact storage materializes explicitly inside the provider boundary; unsupported providers return a typed error instead of a thin result. The borrowed source is never modified.
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected
backend or CPU provider has no borrowed full-matrices capability.
Returns validation errors for an unsupported rank, dtype, or placement,
plus same-placement materialization, backend, numerical, or
output-contract errors.
§Examples
let (u, s, vt) = {
TensorRead::from_tensor(&a).svd_full_read(&mut host)
}?;
assert_eq!(u.shape(), &[1, 1]);
assert_eq!(s.shape(), &[1]);
assert_eq!(vt.shape(), &[2, 2]);Sourcefn qr_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>
fn qr_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, same-placement materialization, backend, numerical, or contract errors.
§Examples
let (q, r) = { TensorRead::from_tensor(&a).qr_read(&mut host) }?;
assert_eq!(q.shape(), &[2, 2]);
assert_eq!(r.shape(), &[2, 2]);Sourcefn qr_with_options_read(
self,
options: QrOptions,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor)>
fn qr_with_options_read( self, options: QrOptions, session: &mut dyn Engine, ) -> Result<(Tensor, Tensor)>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation errors for metadata/options, plus read/materialization or QR errors.
§Examples
let (q, r) = {
TensorRead::from_tensor(&a).qr_with_options_read(QrOptions::default(), &mut host)
}?;
assert_eq!(q.shape(), &[2, 2]);
assert_eq!(r.shape(), &[2, 2]);Sourcefn rank_revealing_qr_read(
self,
options: RankRevealingQrOptions,
session: &mut dyn Engine,
) -> Result<RankRevealingQrResult<Tensor>>
fn rank_revealing_qr_read( self, options: RankRevealingQrOptions, session: &mut dyn Engine, ) -> Result<RankRevealingQrResult<Tensor>>
Compute rank-revealing QR from a borrowed tensor read.
§Errors
Returns validation, same-placement materialization, numerical, backend, or explicit unsupported errors.
§Examples
let result = {
TensorRead::from_tensor(&a).rank_revealing_qr_read(
RankRevealingQrOptions::default(), &mut host)
}?;
assert_eq!(result.rank.as_slice::<i64>()?, &[2]);Sourcefn lu_read(
self,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor, Tensor, Tensor)>
fn lu_read( self, session: &mut dyn Engine, ) -> Result<(Tensor, Tensor, Tensor, Tensor)>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, same-placement materialization, backend, numerical, or contract errors.
§Examples
let (_p, l, u, _parity) = { TensorRead::from_tensor(&a).lu_read(&mut host) }?;
assert_eq!(l.shape(), &[2, 2]);
assert_eq!(u.shape(), &[2, 2]);Sourcefn full_piv_lu_read(
self,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor, Tensor, Tensor, Tensor)>
fn full_piv_lu_read( self, session: &mut dyn Engine, ) -> Result<(Tensor, Tensor, Tensor, Tensor, Tensor)>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, same-placement materialization, backend, numerical, or contract errors.
§Examples
let (p, _l, _u, q, _parity) = { TensorRead::from_tensor(&a).full_piv_lu_read(&mut host) }?;
assert_eq!(p.shape(), &[2, 2]);
assert_eq!(q.shape(), &[2, 2]);Sourcefn full_piv_lu_solve_read(
self,
b: TensorRead<'_>,
session: &mut dyn Engine,
) -> Result<Tensor>
fn full_piv_lu_solve_read( self, b: TensorRead<'_>, session: &mut dyn Engine, ) -> Result<Tensor>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns incompatible-input validation, read/materialization, backend, or singular errors.
§Examples
let x = {
TensorRead::from_tensor(&a).full_piv_lu_solve_read(TensorRead::from_tensor(&b), &mut host)
}?;
assert_eq!(x.shape(), &[2, 1]);Sourcefn solve_read(
self,
b: TensorRead<'_>,
session: &mut dyn Engine,
) -> Result<Tensor>
fn solve_read( self, b: TensorRead<'_>, session: &mut dyn Engine, ) -> Result<Tensor>
The CUDA provider does not inspect the cuSOLVER getrf status flag on
the forward solve path, so it performs no per-call non-singularity check
and issues no host round trip. An exactly singular input is left to the
caller’s verification, as in torch.linalg.solve. CPU providers may
still report their own exactly singular factor as Error::Singular.
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns incompatible-input validation, read/materialization, backend, or singular errors.
§Examples
let x = { TensorRead::from_tensor(&a).solve_read(TensorRead::from_tensor(&b), &mut host) }?;
assert_eq!(x.as_slice::<f64>()?, &[2.0, 2.0]);Sourcefn cholesky_read(self, session: &mut dyn Engine) -> Result<Tensor>
fn cholesky_read(self, session: &mut dyn Engine) -> Result<Tensor>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns matrix validation, read/materialization, backend, or positive-definiteness errors.
§Examples
let l = { TensorRead::from_tensor(&a).cholesky_read(&mut host) }?;
assert_eq!(l.shape(), &[2, 2]);Sourcefn eigh_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>
fn eigh_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, read/materialization, backend, convergence, or contract errors.
§Examples
let (values, vectors) = { TensorRead::from_tensor(&a).eigh_read(&mut host) }?;
assert_eq!(values.as_slice::<f64>()?, &[1.0, 3.0]);
assert_eq!(vectors.shape(), &[2, 2]);Sourcefn eigh_with_options_read(
self,
options: EighOptions,
session: &mut dyn Engine,
) -> Result<(Tensor, Tensor)>
fn eigh_with_options_read( self, options: EighOptions, session: &mut dyn Engine, ) -> Result<(Tensor, Tensor)>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation errors for metadata/options, plus read or Eigh backend errors.
§Examples
let (values, vectors) = {
TensorRead::from_tensor(&a).eigh_with_options_read(EighOptions::default(), &mut host)
}?;
assert_eq!(values.shape(), &[2]);
assert_eq!(vectors.shape(), &[2, 2]);Sourcefn eig_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>
fn eig_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, read/materialization, backend, convergence, or contract errors.
§Examples
let (values, vectors) = { TensorRead::from_tensor(&a).eig_read(&mut host) }?;
assert_eq!(values.shape(), &[2]);
assert_eq!(vectors.shape(), &[2, 2]);Sourcefn triangular_solve_read(
self,
b: TensorRead<'_>,
left_side: bool,
lower: bool,
transpose_a: bool,
unit_diagonal: bool,
session: &mut dyn Engine,
) -> Result<Tensor>
fn triangular_solve_read( self, b: TensorRead<'_>, left_side: bool, lower: bool, transpose_a: bool, unit_diagonal: bool, session: &mut dyn Engine, ) -> Result<Tensor>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns incompatible-input/flag validation, read, backend, or singular errors.
§Examples
let x = {
TensorRead::from_tensor(&a).triangular_solve_read(
TensorRead::from_tensor(&b),
true,
false,
false,
false,
&mut host,
)
}?;
assert_eq!(x.shape(), &[2, 1]);Sourcefn slogdet_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>
fn slogdet_read(self, session: &mut dyn Engine) -> Result<(Tensor, Tensor)>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, read/materialization, backend, numerical, or LU contract errors.
§Examples
let (sign, logabsdet) = { TensorRead::from_tensor(&a).slogdet_read(&mut host) }?;
assert_eq!(sign.as_slice::<f64>()?, &[1.0]);
assert_eq!(logabsdet.shape(), &[] as &[usize]);Sourcefn det_read(self, session: &mut dyn Engine) -> Result<Tensor>
fn det_read(self, session: &mut dyn Engine) -> Result<Tensor>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, read/materialization, backend, numerical, or contract errors.
§Examples
let determinant = { TensorRead::from_tensor(&a).det_read(&mut host) }?;
assert!((determinant.as_slice::<f64>()?[0] - 8.0).abs() < 1.0e-12);Sourcefn inv_read(self, session: &mut dyn Engine) -> Result<Tensor>
fn inv_read(self, session: &mut dyn Engine) -> Result<Tensor>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, read/materialization, backend, or singular-solve errors.
§Examples
let inverse = { TensorRead::from_tensor(&a).inv_read(&mut host) }?;
assert_eq!(inverse.as_slice::<f64>()?, &[0.5, 0.0, 0.0, 0.25]);Sourcefn eigvalsh_read(self, session: &mut dyn Engine) -> Result<Tensor>
fn eigvalsh_read(self, session: &mut dyn Engine) -> Result<Tensor>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, read/materialization, backend, convergence, or contract errors.
§Examples
let values = { TensorRead::from_tensor(&a).eigvalsh_read(&mut host) }?;
assert_eq!(values.as_slice::<f64>()?, &[1.0, 3.0]);Sourcefn eigvals_read(self, session: &mut dyn Engine) -> Result<Tensor>
fn eigvals_read(self, session: &mut dyn Engine) -> Result<Tensor>
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, read/materialization, backend, convergence, or contract errors.
§Examples
let values = { TensorRead::from_tensor(&a).eigvals_read(&mut host) }?;
assert_eq!(values.shape(), &[2]);Sourcefn pinv_read(self, session: &mut dyn Engine) -> Result<Tensor>
fn pinv_read(self, session: &mut dyn Engine) -> Result<Tensor>
Compute the Moore-Penrose pseudoinverse with the dtype-default cutoff.
The threshold is applied to an accuracy-preserving default SVD
(SvdDriver::Auto), so a rank-deficient rank is retained or dropped the
same way as on CPU.
§Errors
Returns tenferro_tensor::Error::Unsupported when the selected backend does not support the operation.
Returns validation, read/materialization, backend, numerical, or SVD contract errors.
§Examples
let pseudoinverse = { TensorRead::from_tensor(&a).pinv_read(&mut host) }?;
assert_eq!(pseudoinverse.shape(), &[2, 2]);Sourcefn pinv_with_rtol_read(
self,
rtol: f64,
session: &mut dyn Engine,
) -> Result<Tensor>
fn pinv_with_rtol_read( self, rtol: f64, session: &mut dyn Engine, ) -> 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_read.
§Examples
let pseudoinverse = { TensorRead::from_tensor(&a).pinv_with_rtol_read(1.0e-12, &mut host) }?;
assert_eq!(pseudoinverse.shape(), &[2, 2]);Sourcefn norm_read(
self,
ord: Option<f64>,
dim: Option<&[usize]>,
keepdim: bool,
session: &mut dyn Engine,
) -> Result<Tensor>
fn norm_read( self, ord: Option<f64>, dim: Option<&[usize]>, keepdim: bool, session: &mut dyn Engine, ) -> 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 read/backend operations.
§Examples
let frobenius = { TensorRead::from_tensor(&a).norm_read(None, None, false, &mut host) }?;
assert_eq!(frobenius.shape(), &[] as &[usize]);Provided Methods§
Sourcefn solve_read_into(
self,
b: TensorRead<'_>,
out: TensorWrite<'_>,
session: &mut dyn Engine,
) -> Result<()>where
Self: Sized,
fn solve_read_into(
self,
b: TensorRead<'_>,
out: TensorWrite<'_>,
session: &mut dyn Engine,
) -> Result<()>where
Self: Sized,
Solve into a caller-owned destination without allocating the result at the public API boundary.
Backends with a native path may write directly into a compatible target; the trait default preserves the ordinary solve-read plus copy behavior.
The CUDA provider does not inspect the cuSOLVER getrf status flag on
the forward solve path, so it performs no per-call non-singularity check
and issues no host round trip. An exactly singular input is left to the
caller’s verification, as in torch.linalg.solve. CPU providers may
still report their own exactly singular factor as Error::Singular.
§Errors
Returns tenferro_tensor_core::ShapeMismatch or
tenferro_tensor_core::ValidationError::DTypeMismatch for incompatible
destination metadata, tenferro_tensor_core::ValidationError::InvalidArgument
for aliasing or placement violations, Error::Unsupported when the
extension implementation or provider is unavailable, and Error::Singular
for a singular system.
§Examples
{
TensorRead::from_tensor(&a).solve_read_into(
TensorRead::from_tensor(&b),
TensorWrite::from_tensor(&mut out),
&mut host,
)
}?;
assert_eq!(out.as_slice::<f64>()?, &[2.0, 2.0]);Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".