QrDecomposition

Trait QrDecomposition 

Source
pub trait QrDecomposition<T, R, C>: Sealed
where DefaultAllocator: Allocator<R, C> + Allocator<DimMinimum<R, C>> + Allocator<C>, R: DimMin<C, Output = C>, C: Dim, T: Scalar + RealField + QrReal,
{
Show 15 methods // Required method fn solve_mut<C2: Dim, S, S2>( &self, x: &mut Matrix<T, C, C2, S2>, b: Matrix<T, R, C2, S>, ) -> Result<(), Error> where S: RawStorageMut<T, R, C2> + IsContiguous, S2: RawStorageMut<T, C, C2> + IsContiguous, T: Zero; // Provided methods fn nrows(&self) -> usize { ... } fn ncols(&self) -> usize { ... } fn shape_generic(&self) -> (R, C) { ... } fn solve<C2: Dim, S>( &self, rhs: Matrix<T, R, C2, S>, ) -> Result<OMatrix<T, C, C2>, Error> where S: RawStorageMut<T, R, C2> + IsContiguous + Storage<T, R, C2>, T: Zero, DefaultAllocator: Allocator<C, C2> + Allocator<R, C2> { ... } fn q_mul_mut<C2, S>(&self, b: &mut Matrix<T, R, C2, S>) -> Result<(), Error> where C2: Dim, S: RawStorageMut<T, R, C2> + IsContiguous { ... } fn q_tr_mul_mut<C2, S>( &self, b: &mut Matrix<T, R, C2, S>, ) -> Result<(), Error> where C2: Dim, S: RawStorageMut<T, R, C2> + IsContiguous { ... } fn mul_q_mut<R2, S>(&self, b: &mut Matrix<T, R2, R, S>) -> Result<(), Error> where R2: Dim, S: RawStorageMut<T, R2, R> + IsContiguous { ... } fn mul_q_tr_mut<R2, S>( &self, b: &mut Matrix<T, R2, R, S>, ) -> Result<(), Error> where R2: Dim, S: RawStorageMut<T, R2, R> + IsContiguous { ... } fn r_mul_mut<C2, S2>( &self, b: &mut Matrix<T, C, C2, S2>, ) -> Result<(), Error> where C2: Dim, S2: RawStorageMut<T, C, C2> + IsContiguous, T: ConstOne { ... } fn r_tr_mul_mut<C2, S2>( &self, b: &mut Matrix<T, C, C2, S2>, ) -> Result<(), Error> where C2: Dim, S2: RawStorageMut<T, C, C2> + IsContiguous, T: ConstOne { ... } fn mul_r_mut<R2, S2>( &self, b: &mut Matrix<T, R2, C, S2>, ) -> Result<(), Error> where R2: Dim, S2: RawStorageMut<T, R2, C> + IsContiguous, T: ConstOne { ... } fn mul_r_tr_mut<R2, S2>( &self, b: &mut Matrix<T, R2, C, S2>, ) -> Result<(), Error> where R2: Dim, S2: RawStorageMut<T, R2, C> + IsContiguous, T: ConstOne { ... } fn q(&self) -> OMatrix<T, R, DimMinimum<R, C>> where DefaultAllocator: Allocator<R, <R as DimMin<C>>::Output>, T: Zero { ... } fn r(&self) -> OMatrix<T, DimMinimum<R, C>, C> where DefaultAllocator: Allocator<R, C> + Allocator<R, DimMinimum<R, C>> + Allocator<DimMinimum<R, C>, C> + Allocator<DimMinimum<R, C>> { ... }
}
Expand description

Common functionality for the QR decomposition of an m × n matrix A with or without column-pivoting.

Required Methods§

Source

fn solve_mut<C2: Dim, S, S2>( &self, x: &mut Matrix<T, C, C2, S2>, b: Matrix<T, R, C2, S>, ) -> Result<(), Error>
where S: RawStorageMut<T, R, C2> + IsContiguous, S2: RawStorageMut<T, C, C2> + IsContiguous, T: Zero,

Solve the square or overdetermined system in A X = B, where X ∈ R^(n × k), B ∈ R^(m × k) in a least-squares sense, such that || A X - B||^2 is minimized. The solution is placed into the matrix X ∈ R^(n × k).

Note that QR decomposition does not typically give the minimum norm solution for X, only the residual is minimized which is typically what we want.

This function might perform a small allocation.

Provided Methods§

Source

fn nrows(&self) -> usize

The number of rows of the original matrix A.

Source

fn ncols(&self) -> usize

The number of columns of the original matrix A.

Source

fn shape_generic(&self) -> (R, C)

Shape of the original matrix A.

Source

fn solve<C2: Dim, S>( &self, rhs: Matrix<T, R, C2, S>, ) -> Result<OMatrix<T, C, C2>, Error>
where S: RawStorageMut<T, R, C2> + IsContiguous + Storage<T, R, C2>, T: Zero, DefaultAllocator: Allocator<C, C2> + Allocator<R, C2>,

Solve the overdetermined linear system with the given right hand side in a least squares sense, see the comments on Self::solve_mut.

Source

fn q_mul_mut<C2, S>(&self, b: &mut Matrix<T, R, C2, S>) -> Result<(), Error>
where C2: Dim, S: RawStorageMut<T, R, C2> + IsContiguous,

Efficiently calculate the matrix product Q B of the factor Q with a given matrix B. Q acts as if it is a matrix of dimension m × m, so we require B ∈ R^(m × k). The product is calculated in place and must only be considered valid when the function returns without error.

Source

fn q_tr_mul_mut<C2, S>(&self, b: &mut Matrix<T, R, C2, S>) -> Result<(), Error>
where C2: Dim, S: RawStorageMut<T, R, C2> + IsContiguous,

Efficiently calculate the matrix product Q^T B of the factor Q with a given matrix B. Q acts as if it is a matrix of dimension m × m, so we require B ∈ R^(m × k). The product is calculated in place and must only be considered valid when the function returns without error.

Source

fn mul_q_mut<R2, S>(&self, b: &mut Matrix<T, R2, R, S>) -> Result<(), Error>
where R2: Dim, S: RawStorageMut<T, R2, R> + IsContiguous,

Efficiently calculate the matrix product B Q of the factor Q with a given matrix B. Q acts as if it is a matrix of dimension m × m, so we require B ∈ R^(k × m). The product is calculated in place and must only be considered valid when the function returns without error.

Source

fn mul_q_tr_mut<R2, S>(&self, b: &mut Matrix<T, R2, R, S>) -> Result<(), Error>
where R2: Dim, S: RawStorageMut<T, R2, R> + IsContiguous,

Efficiently calculate the matrix product B Q^T of the factor Q with a given matrix B. Q acts as if it is a matrix of dimension m × m, so we require B ∈ R^(k × m). The product is calculated in place and must only be considered valid when the function returns without error.

Source

fn r_mul_mut<C2, S2>(&self, b: &mut Matrix<T, C, C2, S2>) -> Result<(), Error>
where C2: Dim, S2: RawStorageMut<T, C, C2> + IsContiguous, T: ConstOne,

Multiply R*B and place the result in B. R is treated as an m × m upper triangular matrix. The product is calculated in place and must only be considered valid when the function returns without error.

Prefer this over qr.r() * B, since its faster and allocation-free.

Source

fn r_tr_mul_mut<C2, S2>( &self, b: &mut Matrix<T, C, C2, S2>, ) -> Result<(), Error>
where C2: Dim, S2: RawStorageMut<T, C, C2> + IsContiguous, T: ConstOne,

Multiply R^T * B and place the result in B. R is treated as an m × m upper triangular matrix. The product is calculated in place and must only be considered valid when the function returns without error.

Prefer this over qr.r().transpose() * B, since its faster and allocation-free.

Source

fn mul_r_mut<R2, S2>(&self, b: &mut Matrix<T, R2, C, S2>) -> Result<(), Error>
where R2: Dim, S2: RawStorageMut<T, R2, C> + IsContiguous, T: ConstOne,

Multiply B*R and place the result in B. R is treated as an m × m upper triangular matrix. The product is calculated in place and must only be considered valid when the function returns without error.

Prefer this over B * qr.r(), since its faster and allocation-free.

Source

fn mul_r_tr_mut<R2, S2>( &self, b: &mut Matrix<T, R2, C, S2>, ) -> Result<(), Error>
where R2: Dim, S2: RawStorageMut<T, R2, C> + IsContiguous, T: ConstOne,

Multiply B*R^T and place the result in B. R is treated as an m × m upper triangular matrix. The product is calculated in place and must only be considered valid when the function returns without error.

Prefer this over B * qr.r(), since its faster and allocation-free.

Source

fn q(&self) -> OMatrix<T, R, DimMinimum<R, C>>
where DefaultAllocator: Allocator<R, <R as DimMin<C>>::Output>, T: Zero,

Computes the orthonormal matrix Q ∈ R^(m × n) of this decomposition. Note that this matrix has economy dimensions, which means it is not square unless A is square. It satisfies Q^T Q = I. Note further that it is typically not necessary to compute Q explicitly. Rather, check if some of the provided multiplication functions can help to calculate the matrix products Q B, B Q, Q^T B, B Q^T more efficiently.

This function allocates.

Source

fn r(&self) -> OMatrix<T, DimMinimum<R, C>, C>

Retrieves the upper trapezoidal submatrix R of this decomposition. Note that it’s typically not necessary to construct this matrix directly and check if any of the provided multiplication functions can be used instead.

This function allocates.

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.

Implementors§

Source§

impl<T, R, C> QrDecomposition<T, R, C> for ColPivQR<T, R, C>
where DefaultAllocator: Allocator<R, C> + Allocator<DimMinimum<R, C>> + Allocator<C>, R: DimMin<C, Output = C>, C: Dim, T: Scalar + RealField + QrReal,

Source§

impl<T, R, C> QrDecomposition<T, R, C> for QR<T, R, C>
where DefaultAllocator: Allocator<R, C> + Allocator<DimMinimum<R, C>> + Allocator<C>, R: DimMin<C, Output = C>, C: Dim, T: Scalar + RealField + QrReal,