pub trait QRDecompositionField: Field {
// Required method
fn scaled_qr_decomposition<V1, V2>(
&self,
matrix: SubmatrixMut<'_, V1, Self::Element>,
q: SubmatrixMut<'_, V2, Self::Element>,
) -> Vec<Self::Element>
where V1: AsPointerToSlice<Self::Element>,
V2: AsPointerToSlice<Self::Element>;
// Provided methods
fn ldl_decomposition<V>(
&self,
matrix: SubmatrixMut<'_, V, Self::Element>,
) -> Vec<Self::Element>
where V: AsPointerToSlice<Self::Element> { ... }
fn qr_decomposition<V1, V2>(
&self,
matrix: SubmatrixMut<'_, V1, Self::Element>,
q: SubmatrixMut<'_, V2, Self::Element>,
)
where V1: AsPointerToSlice<Self::Element>,
V2: AsPointerToSlice<Self::Element>,
Self: SqrtRing { ... }
}
unstable-enable
only.Expand description
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Required Methods§
Sourcefn scaled_qr_decomposition<V1, V2>(
&self,
matrix: SubmatrixMut<'_, V1, Self::Element>,
q: SubmatrixMut<'_, V2, Self::Element>,
) -> Vec<Self::Element>
fn scaled_qr_decomposition<V1, V2>( &self, matrix: SubmatrixMut<'_, V1, Self::Element>, q: SubmatrixMut<'_, V2, Self::Element>, ) -> Vec<Self::Element>
Given a matrix A
, computes an orthogonal matrix Q
and an upper triangular
matrix R
with A = Q R
. The function writes Q diag(x_1, ..., x_n)
to q
and
diag(1/x_1, ..., 1/x_n) R
to matrix
, and returns x_1^2, ..., x_n^2
, where
x_1, ..., x_n
are the elements on the diagonal of R
.
Returning the values as given above instead of just Q
and R
is done
to avoid the computation of square-roots, which may not be supported by the
underlying ring. If it is supported, you can use QRDecompositionField::qr_decomposition()
instead. Note that this means that diag(x_1^2, ..., x_n^2)
and R
are the LDL-decomposition of A^T A
.
§Rank-deficient matrices
Do not use this for matrices that do not have full rank. If the underlying ring is exact, this will panic. For approximate rings (in particular floating-point numbers), matrices that don’t have full rank, or are very badly conditioned, will give inaccurate results.
Clearly, rank-deficient matrices cannot be supported, since for those the value
diag(1/x_1, ..., 1/x_n)
is not defined.
Provided Methods§
Sourcefn ldl_decomposition<V>(
&self,
matrix: SubmatrixMut<'_, V, Self::Element>,
) -> Vec<Self::Element>where
V: AsPointerToSlice<Self::Element>,
fn ldl_decomposition<V>(
&self,
matrix: SubmatrixMut<'_, V, Self::Element>,
) -> Vec<Self::Element>where
V: AsPointerToSlice<Self::Element>,
Given a square symmetric matrix A
, computes a strict lower triangular matrix L
and
a diagonal matrix D
such that A = L D L^T
. The function writes L
to matrix
and returns the diagonal elements of D
.
§Singular matrices
Do not use this for matrices that are singular. If the underlying ring is exact, this will panic. For approximate rings (in particular floating-point numbers), matrices that don’t have full rank, or are very badly conditioned, will give inaccurate results. Note however that the matrix is not required to be positive definite, it may have both positive and negative eigenvalues (but no zero eigenvalues).
Why don’t we support singular matrices? Because many singular matrices don’t have
an LDL decomposition. For example, the matrix [[ 0, 1 ], [ 1, 1 ]]
doesn’t.
Sourcefn qr_decomposition<V1, V2>(
&self,
matrix: SubmatrixMut<'_, V1, Self::Element>,
q: SubmatrixMut<'_, V2, Self::Element>,
)
fn qr_decomposition<V1, V2>( &self, matrix: SubmatrixMut<'_, V1, Self::Element>, q: SubmatrixMut<'_, V2, Self::Element>, )
Given a matrix A
, computes an orthogonal matrix Q
and an upper triangular
matrix R
with A = Q R
. These are returned in matrix
and q
, respectively.
Note that if the ring is not a SqrtRing
, you can still use QRDecompositionField::scaled_qr_decomposition()
.
This function supports non-full-rank matrices as well.
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.