Class xlifepp::HouseholderSequence#
-
template<class MatrixType, class VectorType>
class HouseholderSequence#
-
Collaboration diagram for xlifepp::HouseholderSequence:
Sequence of Householder reflections acting on subspaces with decreasing size.
This class represents a product sequence of Householder reflections where the first Householder reflection acts on the whole space, the second Householder reflection leaves the one-dimensional subspace spanned by the first unit vector invariant, the third Householder reflection leaves the two-dimensional subspace spanned by the first two unit vectors invariant, and so on up to the last reflection which leaves all but one dimensions invariant and acts only on the last dimension. Such sequences of Householder reflections are used in several algorithms to zero out certain parts of a matrix. Indeed, the methods HessenbergDecomposition::matrixQ(), Tridiagonalization::matrixQ(), HouseholderQR::householderQ(), and ColPivHouseholderQR::householderQ() all return a HouseholderSequence.
More precisely, the class HouseholderSequence represents an \( n \times n \) matrix \( H \) of the form \( H = \prod_{i=0}^{n-1} H_i \) where the i-th Householder reflection is \( H_i = I - h_i v_i v_i^* \). The i-th Householder coefficient \( h_i \) is a scalar and the i-th Householder vector \( v_i \) is a vector of the form
\[ v_i = [\underbrace{0, \ldots, 0}_{i-1\mbox{ zeros}}, 1, \underbrace{*, \ldots,*}_{n-i\mbox{ arbitrary entries}} ]. \]The last \( n-i \) entries of \( v_i \) are called the essential part of the Householder vector.Typical usages are listed below, where H is a HouseholderSequence:
A.applyOnTheRight(H); // A = A * H A.applyOnTheLeft(H); // A = H * A A.applyOnTheRight(H.adjoint()); // A = A * H^* A.applyOnTheLeft(H.adjoint()); // A = H^* * A MatrixXd Q = H; // conversion to a dense matrix
- Template Parameters:
-
VectorsType – type of matrix containing the Householder vectors
CoeffsType – type of vector containing the Householder coefficients
Side – either OnTheLeft (the default) or OnTheRight
Public Functions
-
inline HouseholderSequence(const HouseholderSequence &other)#
-
Copy constructor.
-
inline HouseholderSequence(const VectorsType &v, const CoeffsType &h)#
-
Constructor.
Constructs the Householder sequence with coefficients given by
h
and vectors given byv
. The i-th Householder coefficient \( h_i \) is given byh(i)
and the essential part of the i-th Householder vector \( v_i \) is given byv(k,i)
withk
>i
(the subdiagonal part of the i-th column). Ifv
has fewer columns than rows, then the Householder sequence contains as many Householder reflections as there are columns.See also
- Parameters:
-
v – [in] Matrix containing the essential parts of the Householder vectors
h – [in] Vector containing the Householder coefficients
Note
The HouseholderSequence object stores
v
andh
by reference.
-
inline ConjugateReturnType adjoint() const#
-
Adjoint (conjugate transpose) of the Householder sequence.
-
inline Index cols() const#
-
Number of columns of transformation viewed as a matrix.
This equals the dimension of the space that the transformation acts on.
- Returns:
-
Number of columns
-
inline ConjugateReturnType conjugate() const#
-
Complex conjugate of the Householder sequence.
-
inline const EssentialVectorType essentialVector(Index k) const#
-
Essential part of a Householder vector.
This function returns the essential part of the Householder vector \( v_i \). This is a vector of length \( n-i \) containing the last \( n-i \) entries of the vector
\[ v_i = [\underbrace{0, \ldots, 0}_{i-1\mbox{ zeros}}, 1, \underbrace{*, \ldots,*}_{n-i\mbox{ arbitrary entries}} ]. \]The index \( i \) equalsk
+ shift(), corresponding to the k-th column of the matrixv
passed to the constructor.See also
- Parameters:
-
k – [in] Index of Householder reflection
- Returns:
-
Vector containing non-trivial entries of k-th Householder vector
-
inline ConjugateReturnType inverse() const#
-
Inverse of the Householder sequence (equals the adjoint).
-
inline Index rows() const#
-
Number of rows of transformation viewed as a matrix.
This equals the dimension of the space that the transformation acts on.
- Returns:
-
Number of rows
-
inline HouseholderSequence &setLength(Index length)#
-
Sets the length of the Householder sequence.
By default, the length \( n \) of the Householder sequence \( H = H_0 H_1 \ldots H_{n-1} \) is set to the number of columns of the matrix
v
passed to the constructor, or the number of rows if that is smaller. After this function is called, the length equalslength
.See also
- Parameters:
-
length – [in] New value for the length.
-
inline HouseholderSequence &setShift(Index shift)#
-
Sets the shift of the Householder sequence.
By default, a HouseholderSequence object represents \( H = H_0 H_1 \ldots H_{n-1} \) and the i-th column of the matrix
v
passed to the constructor corresponds to the i-th Householder reflection. After this function is called, the object represents \( H = H_{\mathrm{shift}} * H_{\mathrm{shift}+1} \ldots H_{n-1} \) and the i-th column ofv
corresponds to the (shift+i)-th Householder reflection.See also
- Parameters:
-
shift – [in] New value for the shift.
-
inline HouseholderSequence transpose() const#
-
Transpose of the Householder sequence.