pub struct HouseholderQr<T> { /* private fields */ }Expand description
Opaque compact Householder QR state.
The packed reflector tensors remain private so callers cannot accidentally treat provider state as ordinary tensor values.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_linalg::{QrOptions, TensorLinalgExt};
use tenferro_tensor::{BackendSessionHost, Tensor};
let a = Tensor::from_vec_col_major(
vec![3, 2],
vec![1.0_f64, 0.0, 1.0, 0.0, 1.0, 1.0],
)?;
let mut host = CpuBackend::new();
let r = host.with_backend_session(|session| {
let qr = a.householder_qr(session)?;
qr.r(QrOptions::default(), session)
})?;
assert_eq!(r.shape(), &[2, 2]);Implementations§
Source§impl HouseholderQr<Tensor>
impl HouseholderQr<Tensor>
Sourcepub fn from_factors(
q: &Tensor,
r: &Tensor,
session: &mut dyn BackendSession,
) -> Result<Self>
pub fn from_factors( q: &Tensor, r: &Tensor, session: &mut dyn BackendSession, ) -> Result<Self>
Construct compact state for the product of compatible factors Q * R.
§Errors
Returns tenferro_tensor::Error::Validation for incompatible rank,
shape, dtype, placement, or a non-trapezoidal R factor;
tenferro_tensor::Error::Unsupported when the provider lacks compact
QR; or tenferro_tensor::Error::BackendSource for provider failures.
Sourcepub fn append_columns(
&self,
block: &Tensor,
session: &mut dyn BackendSession,
) -> Result<Self>
pub fn append_columns( &self, block: &Tensor, session: &mut dyn BackendSession, ) -> Result<Self>
Append a column block without refactorizing existing columns.
§Errors
Returns tenferro_tensor::Error::Validation for incompatible shape,
dtype, placement, or malformed state; tenferro_tensor::Error::Unsupported
when append is unavailable; or tenferro_tensor::Error::BackendSource
for reflector or factorization failures.
Sourcepub fn r(
&self,
options: QrOptions,
session: &mut dyn BackendSession,
) -> Result<Tensor>
pub fn r( &self, options: QrOptions, session: &mut dyn BackendSession, ) -> Result<Tensor>
Extract the thin upper-trapezoidal factor.
§Errors
Returns tenferro_tensor::Error::Validation for malformed state,
tenferro_tensor::Error::Unsupported for an unavailable provider path,
or tenferro_tensor::Error::BackendSource for extraction failures.
Sourcepub fn q_columns(
&self,
columns: Range<usize>,
options: QrOptions,
session: &mut dyn BackendSession,
) -> Result<Tensor>
pub fn q_columns( &self, columns: Range<usize>, options: QrOptions, session: &mut dyn BackendSession, ) -> Result<Tensor>
Materialize a contiguous range of thin-Q columns.
§Errors
Returns tenferro_tensor::Error::Validation when the range is outside
the thin-Q width or state metadata is malformed,
tenferro_tensor::Error::Unsupported for an unavailable provider path,
or tenferro_tensor::Error::BackendSource for execution failures.
Source§impl HouseholderQr<EagerTensor>
impl HouseholderQr<EagerTensor>
Sourcepub fn from_factors(q: &EagerTensor, r: &EagerTensor) -> Result<Self>
pub fn from_factors(q: &EagerTensor, r: &EagerTensor) -> Result<Self>
Construct compact state from compatible eager factors.
§Errors
Returns tenferro_ad::Error::Validation for known invalid metadata,
tenferro_ad::Error::Extension for unsupported or provider failures,
or tenferro_ad::Error::RuntimeState when eager execution is unavailable.
Sourcepub fn append_columns(&self, block: &EagerTensor) -> Result<Self>
pub fn append_columns(&self, block: &EagerTensor) -> Result<Self>
Append an eager column block functionally.
§Errors
Returns tenferro_ad::Error::Validation for known invalid metadata,
tenferro_ad::Error::Extension for unsupported or provider failures,
or tenferro_ad::Error::RuntimeState when eager execution is unavailable.
Sourcepub fn r(&self, options: QrOptions) -> Result<EagerTensor>
pub fn r(&self, options: QrOptions) -> Result<EagerTensor>
Extract eager R.
§Errors
Returns tenferro_ad::Error::Validation for known invalid metadata,
tenferro_ad::Error::Extension for unsupported or provider failures,
or tenferro_ad::Error::RuntimeState when eager execution is unavailable.
Sourcepub fn q_columns(
&self,
columns: Range<usize>,
options: QrOptions,
) -> Result<EagerTensor>
pub fn q_columns( &self, columns: Range<usize>, options: QrOptions, ) -> Result<EagerTensor>
Materialize eager thin-Q columns.
§Errors
Returns tenferro_ad::Error::Validation for known invalid metadata,
tenferro_ad::Error::Extension for unsupported or provider failures,
or tenferro_ad::Error::RuntimeState when eager execution is unavailable.
Source§impl HouseholderQr<TracedTensor>
impl HouseholderQr<TracedTensor>
Sourcepub fn from_factors(q: &TracedTensor, r: &TracedTensor) -> Result<Self>
pub fn from_factors(q: &TracedTensor, r: &TracedTensor) -> Result<Self>
Construct compact state from compatible traced factors.
§Errors
Returns tenferro_runtime::Error::Validation for known invalid metadata
or tenferro_runtime::Error::Extension for unsupported operation state.
§Deferred errors
Symbolic shape constraints and backend provider failures may be reported during compile or execution.
Sourcepub fn append_columns(&self, block: &TracedTensor) -> Result<Self>
pub fn append_columns(&self, block: &TracedTensor) -> Result<Self>
Append a traced column block functionally.
§Errors
Returns tenferro_runtime::Error::Validation for known invalid metadata
or tenferro_runtime::Error::Extension for unsupported operation state.
§Deferred errors
Symbolic shape constraints and backend provider failures may be reported during compile or execution.
Sourcepub fn r(&self, options: QrOptions) -> Result<TracedTensor>
pub fn r(&self, options: QrOptions) -> Result<TracedTensor>
Sourcepub fn q_columns(
&self,
columns: Range<usize>,
options: QrOptions,
) -> Result<TracedTensor>
pub fn q_columns( &self, columns: Range<usize>, options: QrOptions, ) -> Result<TracedTensor>
Materialize traced thin-Q columns.
§Errors
Returns tenferro_runtime::Error::Validation for known invalid metadata
or tenferro_runtime::Error::Extension for unsupported operation state.
§Deferred errors
Symbolic shape constraints and backend provider failures may be reported during compile or execution.
Trait Implementations§
Source§impl<T: Clone> Clone for HouseholderQr<T>
impl<T: Clone> Clone for HouseholderQr<T>
Source§fn clone(&self) -> HouseholderQr<T>
fn clone(&self) -> HouseholderQr<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<T> Freeze for HouseholderQr<T>where
T: Freeze,
impl<T> RefUnwindSafe for HouseholderQr<T>where
T: RefUnwindSafe,
impl<T> Send for HouseholderQr<T>where
T: Send,
impl<T> Sync for HouseholderQr<T>where
T: Sync,
impl<T> Unpin for HouseholderQr<T>where
T: Unpin,
impl<T> UnsafeUnpin for HouseholderQr<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for HouseholderQr<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more