template<typename VectorsType, typename CoeffsType, int Side>
class Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >
Sequence of Householder reflections acting on subspaces with decreasing size.
This is defined in the Householder module.
#include <Eigen/Householder>
- 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 |
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
matrix
of the form
where the i-th Householder reflection is
. The i-th Householder coefficient
is a scalar and the i-th Householder vector
is a vector of the form
The last
entries of
are called the essential part of the Householder vector.
Typical usages are listed below, where H is a HouseholderSequence:
A.applyOnTheRight(H);
A.applyOnTheLeft(H);
A.applyOnTheRight(H.adjoint());
A.applyOnTheLeft(H.adjoint());
MatrixXd Q = H;
In addition to the adjoint, you can also apply the inverse (=adjoint), the transpose, and the conjugate operators.
See the documentation for HouseholderSequence(const VectorsType&, const CoeffsType&) for an example.
- See also
- MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()
template<typename VectorsType , typename CoeffsType , int Side>
Constructor.
- Parameters
-
[in] | v | Matrix containing the essential parts of the Householder vectors |
[in] | h | Vector containing the Householder coefficients |
Constructs the Householder sequence with coefficients given by h
and vectors given by v
. The i-th Householder coefficient
is given by h(i)
and the essential part of the i-th Householder vector
is given by v(k,i)
with k
> i
(the subdiagonal part of the i-th column). If v
has fewer columns than rows, then the Householder sequence contains as many Householder reflections as there are columns.
- Note
- The HouseholderSequence object stores
v
and h
by reference.
Example:
cout << "The matrix v is:" << endl;
cout << v << endl;
cout << "The first Householder vector is: v_0 = " << v0.transpose() << endl;
cout << "The second Householder vector is: v_1 = " << v1.transpose() << endl;
cout << "The third Householder vector is: v_2 = " << v2.transpose() << endl;
cout << "The Householder coefficients are: h = " << h.transpose() << endl;
cout << "The first Householder reflection is represented by H_0 = " << endl;
cout << H0 << endl;
cout << "The second Householder reflection is represented by H_1 = " << endl;
cout << H1 << endl;
cout << "The third Householder reflection is represented by H_2 = " << endl;
cout << H2 << endl;
cout << "Their product is H_0 H_1 H_2 = " << endl;
cout << H0 * H1 * H2 << endl;
HouseholderSequence<Matrix3d, Vector3d> hhSeq(v, h);
cout << "If we construct a HouseholderSequence from v and h" << endl;
cout << "and convert it to a matrix, we get:" << endl;
cout << hhSeqAsMatrix << endl;
Output:
The matrix v is:
0.68 0.597 -0.33
-0.211 0.823 0.536
0.566 -0.605 -0.444
The first Householder vector is: v_0 = 1 -0.211 0.566
The second Householder vector is: v_1 = 0 1 -0.605
The third Householder vector is: v_2 = 0 0 1
The Householder coefficients are: h = 0.108 -0.0452 0.258
The first Householder reflection is represented by H_0 =
0.892 0.0228 -0.0611
0.0228 0.995 0.0129
-0.0611 0.0129 0.965
The second Householder reflection is represented by H_1 =
1 0 0
0 1.05 -0.0273
0 -0.0273 1.02
The third Householder reflection is represented by H_2 =
1 0 0
0 1 0
0 0 0.742
Their product is H_0 H_1 H_2 =
0.892 0.0255 -0.0466
0.0228 1.04 -0.0105
-0.0611 -0.0129 0.728
If we construct a HouseholderSequence from v and h
and convert it to a matrix, we get:
0.892 0.0255 -0.0466
0.0228 1.04 -0.0105
-0.0611 -0.0129 0.728
- See also
- setLength(), setShift()