Eigen::HouseholderSequence< VectorsType, CoeffsType, Side > Class Template Reference

Sequence of Householder reflections acting on subspaces with decreasing size. More...

+ Inheritance diagram for Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >:

Public Types

enum  {
  RowsAtCompileTime ,
  ColsAtCompileTime ,
  MaxRowsAtCompileTime ,
  MaxColsAtCompileTime
}
 
typedef HouseholderSequence< VectorsType, std::conditional_t< NumTraits< Scalar >::IsComplex, internal::remove_all_t< typename CoeffsType::ConjugateReturnType >, CoeffsType >, Side > AdjointReturnType
 
typedef HouseholderSequence< std::conditional_t< NumTraits< Scalar >::IsComplex, internal::remove_all_t< typename VectorsType::ConjugateReturnType >, VectorsType >, std::conditional_t< NumTraits< Scalar >::IsComplex, internal::remove_all_t< typename CoeffsType::ConjugateReturnType >, CoeffsType >, Side > ConjugateReturnType
 
typedef HouseholderSequence< std::add_const_t< VectorsType >, std::add_const_t< CoeffsType >, Side > ConstHouseholderSequence
 
typedef internal::traits< HouseholderSequence >::Scalar Scalar
 
typedef HouseholderSequence< std::conditional_t< NumTraits< Scalar >::IsComplex, internal::remove_all_t< typename VectorsType::ConjugateReturnType >, VectorsType >, CoeffsType, Side > TransposeReturnType
 
- Public Types inherited from Eigen::EigenBase< HouseholderSequence< VectorsType, CoeffsType, Side > >
typedef Eigen::Index Index
 The interface type of indices. More...
 
typedef internal::traits< HouseholderSequence< VectorsType, CoeffsType, Side > >::StorageKind StorageKind
 

Public Member Functions

AdjointReturnType adjoint () const
 Adjoint (conjugate transpose) of the Householder sequence. More...
 
template<typename Dest >
void applyThisOnTheLeft (Dest &dst, bool inputIsIdentity=false) const
 
template<typename Dest , typename Workspace >
void applyThisOnTheLeft (Dest &dst, Workspace &workspace, bool inputIsIdentity=false) const
 
template<typename Dest >
void applyThisOnTheRight (Dest &dst) const
 
template<typename Dest , typename Workspace >
void applyThisOnTheRight (Dest &dst, Workspace &workspace) const
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 Number of columns of transformation viewed as a matrix. More...
 
ConjugateReturnType conjugate () const
 Complex conjugate of the Householder sequence. More...
 
template<bool Cond>
std::conditional_t< Cond, ConjugateReturnType, ConstHouseholderSequenceconjugateIf () const
 
const EssentialVectorType essentialVector (Index k) const
 Essential part of a Householder vector. More...
 
template<typename Dest , typename Workspace >
void evalTo (Dest &dst, Workspace &workspace) const
 
template<typename DestType >
void evalTo (DestType &dst) const
 
 HouseholderSequence (const HouseholderSequence &other)
 Copy constructor. More...
 
 HouseholderSequence (const VectorsType &v, const CoeffsType &h)
 Constructor. More...
 
AdjointReturnType inverse () const
 Inverse of the Householder sequence (equals the adjoint). More...
 
Index length () const
 Returns the length of the Householder sequence. More...
 
template<typename OtherDerived >
internal::matrix_type_times_scalar_type< Scalar, OtherDerived >::Type operator* (const MatrixBase< OtherDerived > &other) const
 Computes the product of a Householder sequence with a matrix. More...
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 Number of rows of transformation viewed as a matrix. More...
 
HouseholderSequencesetLength (Index length)
 Sets the length of the Householder sequence. More...
 
HouseholderSequencesetShift (Index shift)
 Sets the shift of the Householder sequence. More...
 
Index shift () const
 Returns the shift of the Householder sequence. More...
 
TransposeReturnType transpose () const
 Transpose of the Householder sequence. More...
 
- Public Member Functions inherited from Eigen::EigenBase< HouseholderSequence< VectorsType, CoeffsType, Side > >
void addTo (Dest &dst) const
 
void applyThisOnTheLeft (Dest &dst) const
 
void applyThisOnTheRight (Dest &dst) const
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
HouseholderSequence< VectorsType, CoeffsType, Side > & const_cast_derived () const
 
const HouseholderSequence< VectorsType, CoeffsType, Side > & const_derived () const
 
HouseholderSequence< VectorsType, CoeffsType, Side > & derived ()
 
const HouseholderSequence< VectorsType, CoeffsType, Side > & derived () const
 
void evalTo (Dest &dst) const
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
void subTo (Dest &dst) const
 

Protected Types

enum  { BlockSize }
 

Protected Member Functions

bool reverseFlag () const
 
HouseholderSequencesetReverseFlag (bool reverse)
 

Protected Attributes

CoeffsType::Nested m_coeffs
 
Index m_length
 
bool m_reverse
 
Index m_shift
 
VectorsType::Nested m_vectors
 

Private Types

typedef internal::hseq_side_dependent_impl< VectorsType, CoeffsType, Side >::EssentialVectorType EssentialVectorType
 

Detailed Description

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.

Template Parameters
VectorsTypetype of matrix containing the Householder vectors
CoeffsTypetype of vector containing the Householder coefficients
Sideeither 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 \( 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
MatrixXcf A
MatrixXf Q
Matrix< double, Dynamic, Dynamic > MatrixXd
Dynamic×Dynamic matrix of type double.
Definition: Matrix.h:502

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()

Definition at line 121 of file HouseholderSequence.h.

Member Typedef Documentation

◆ AdjointReturnType

template<typename VectorsType , typename CoeffsType , int Side>
typedef HouseholderSequence< VectorsType, std::conditional_t<NumTraits<Scalar>::IsComplex, internal::remove_all_t<typename CoeffsType::ConjugateReturnType>, CoeffsType>, Side > Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::AdjointReturnType

Definition at line 151 of file HouseholderSequence.h.

◆ ConjugateReturnType

template<typename VectorsType , typename CoeffsType , int Side>
typedef HouseholderSequence< std::conditional_t<NumTraits<Scalar>::IsComplex, internal::remove_all_t<typename VectorsType::ConjugateReturnType>, VectorsType>, std::conditional_t<NumTraits<Scalar>::IsComplex, internal::remove_all_t<typename CoeffsType::ConjugateReturnType>, CoeffsType>, Side > Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::ConjugateReturnType

Definition at line 143 of file HouseholderSequence.h.

◆ ConstHouseholderSequence

template<typename VectorsType , typename CoeffsType , int Side>
typedef HouseholderSequence< std::add_const_t<VectorsType>, std::add_const_t<CoeffsType>, Side > Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::ConstHouseholderSequence

Definition at line 165 of file HouseholderSequence.h.

◆ EssentialVectorType

template<typename VectorsType , typename CoeffsType , int Side>
typedef internal::hseq_side_dependent_impl<VectorsType,CoeffsType,Side>::EssentialVectorType Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::EssentialVectorType
private

Definition at line 124 of file HouseholderSequence.h.

◆ Scalar

template<typename VectorsType , typename CoeffsType , int Side>
typedef internal::traits<HouseholderSequence>::Scalar Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::Scalar

Definition at line 133 of file HouseholderSequence.h.

◆ TransposeReturnType

template<typename VectorsType , typename CoeffsType , int Side>
typedef HouseholderSequence< std::conditional_t<NumTraits<Scalar>::IsComplex, internal::remove_all_t<typename VectorsType::ConjugateReturnType>, VectorsType>, CoeffsType, Side > Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::TransposeReturnType

Definition at line 159 of file HouseholderSequence.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename VectorsType , typename CoeffsType , int Side>
anonymous enum
Enumerator
RowsAtCompileTime 
ColsAtCompileTime 
MaxRowsAtCompileTime 
MaxColsAtCompileTime 

Definition at line 127 of file HouseholderSequence.h.

127  {
128  RowsAtCompileTime = internal::traits<HouseholderSequence>::RowsAtCompileTime,
129  ColsAtCompileTime = internal::traits<HouseholderSequence>::ColsAtCompileTime,
130  MaxRowsAtCompileTime = internal::traits<HouseholderSequence>::MaxRowsAtCompileTime,
131  MaxColsAtCompileTime = internal::traits<HouseholderSequence>::MaxColsAtCompileTime
132  };

◆ anonymous enum

template<typename VectorsType , typename CoeffsType , int Side>
anonymous enum
protected
Enumerator
BlockSize 

Definition at line 516 of file HouseholderSequence.h.

Constructor & Destructor Documentation

◆ HouseholderSequence() [1/2]

template<typename VectorsType , typename CoeffsType , int Side>
Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::HouseholderSequence ( const VectorsType &  v,
const CoeffsType &  h 
)
inline

Constructor.

Parameters
[in]vMatrix containing the essential parts of the Householder vectors
[in]hVector containing the Householder coefficients

Constructs the Householder sequence with coefficients given by h and vectors given by v. The i-th Householder coefficient \( h_i \) is given by h(i) and the essential part of the i-th Householder vector \( v_i \) 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;
Vector3d v0(1, v(1,0), v(2,0));
cout << "The first Householder vector is: v_0 = " << v0.transpose() << endl;
Vector3d v1(0, 1, v(2,1));
cout << "The second Householder vector is: v_1 = " << v1.transpose() << endl;
Vector3d v2(0, 0, 1);
cout << "The third Householder vector is: v_2 = " << v2.transpose() << endl;
cout << "The Householder coefficients are: h = " << h.transpose() << endl;
Matrix3d H0 = Matrix3d::Identity() - h(0) * v0 * v0.adjoint();
cout << "The first Householder reflection is represented by H_0 = " << endl;
cout << H0 << endl;
Matrix3d H1 = Matrix3d::Identity() - h(1) * v1 * v1.adjoint();
cout << "The second Householder reflection is represented by H_1 = " << endl;
cout << H1 << endl;
Matrix3d H2 = Matrix3d::Identity() - h(2) * v2 * v2.adjoint();
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;
Array< int, Dynamic, 1 > v
Matrix3d hhSeqAsMatrix(hhSeq)
cout<< "The matrix v is:"<< endl;cout<< v<< endl;Vector3d v0(1, v(1, 0), v(2, 0));cout<< "The first Householder vector is: v_0 = "<< v0.transpose()<< endl;Vector3d v1(0, 1, v(2, 1));cout<< "The second Householder vector is: v_1 = "<< v1.transpose()<< endl;Vector3d v2(0, 0, 1);cout<< "The third Householder vector is: v_2 = "<< v2.transpose()<< endl;Vector3d h=Vector3d::Random();cout<< "The Householder coefficients are: h = "<< h.transpose()<< endl;Matrix3d H0=Matrix3d::Identity() - h(0) *v0 *v0.adjoint();cout<< "The first Householder reflection is represented by H_0 = "<< endl;cout<< H0<< endl;Matrix3d H1=Matrix3d::Identity() - h(1) *v1 *v1.adjoint();cout<< "The second Householder reflection is represented by H_1 = "<< endl;cout<< H1<< endl;Matrix3d H2=Matrix3d::Identity() - h(2) *v2 *v2.adjoint();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)
Map< RowVectorXf > v2(M2.data(), M2.size())
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
static const RandomReturnType Random()
Definition: Random.h:114
static const IdentityReturnType Identity()
Matrix< double, 3, 3 > Matrix3d
3×3 matrix of type double.
Definition: Matrix.h:502
Matrix< double, 3, 1 > Vector3d
3×1 vector of type double.
Definition: Matrix.h:502

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()

Definition at line 185 of file HouseholderSequence.h.

186  : m_vectors(v), m_coeffs(h), m_reverse(false), m_length(v.diagonalSize()),
187  m_shift(0)
188  {
189  }

◆ HouseholderSequence() [2/2]

template<typename VectorsType , typename CoeffsType , int Side>
Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::HouseholderSequence ( const HouseholderSequence< VectorsType, CoeffsType, Side > &  other)
inline

Copy constructor.

Definition at line 193 of file HouseholderSequence.h.

194  : m_vectors(other.m_vectors),
195  m_coeffs(other.m_coeffs),
196  m_reverse(other.m_reverse),
197  m_length(other.m_length),
198  m_shift(other.m_shift)
199  {
200  }

Member Function Documentation

◆ adjoint()

template<typename VectorsType , typename CoeffsType , int Side>
AdjointReturnType Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::adjoint ( ) const
inline

Adjoint (conjugate transpose) of the Householder sequence.

Definition at line 268 of file HouseholderSequence.h.

269  {
270  return AdjointReturnType(m_vectors, m_coeffs.conjugate())
271  .setReverseFlag(!m_reverse)
272  .setLength(m_length)
273  .setShift(m_shift);
274  }
HouseholderSequence< VectorsType, std::conditional_t< NumTraits< Scalar >::IsComplex, internal::remove_all_t< typename CoeffsType::ConjugateReturnType >, CoeffsType >, Side > AdjointReturnType

◆ applyThisOnTheLeft() [1/2]

template<typename VectorsType , typename CoeffsType , int Side>
template<typename Dest >
void Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::applyThisOnTheLeft ( Dest &  dst,
bool  inputIsIdentity = false 
) const
inline

Definition at line 363 of file HouseholderSequence.h.

364  {
365  Matrix<Scalar,1,Dest::ColsAtCompileTime,RowMajor,1,Dest::MaxColsAtCompileTime> workspace;
366  applyThisOnTheLeft(dst, workspace, inputIsIdentity);
367  }
void applyThisOnTheLeft(Dest &dst, bool inputIsIdentity=false) const

◆ applyThisOnTheLeft() [2/2]

template<typename VectorsType , typename CoeffsType , int Side>
template<typename Dest , typename Workspace >
void Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::applyThisOnTheLeft ( Dest &  dst,
Workspace &  workspace,
bool  inputIsIdentity = false 
) const
inline

Definition at line 371 of file HouseholderSequence.h.

372  {
373  if(inputIsIdentity && m_reverse)
374  inputIsIdentity = false;
375  // if the entries are large enough, then apply the reflectors by block
376  if(m_length>=BlockSize && dst.cols()>1)
377  {
378  // Make sure we have at least 2 useful blocks, otherwise it is point-less:
379  Index blockSize = m_length<Index(2*BlockSize) ? (m_length+1)/2 : Index(BlockSize);
380  for(Index i = 0; i < m_length; i+=blockSize)
381  {
382  Index end = m_reverse ? (std::min)(m_length,i+blockSize) : m_length-i;
383  Index k = m_reverse ? i : (std::max)(Index(0),end-blockSize);
384  Index bs = end-k;
385  Index start = k + m_shift;
386 
387  typedef Block<internal::remove_all_t<VectorsType>,Dynamic,Dynamic> SubVectorsType;
388  SubVectorsType sub_vecs1(m_vectors.const_cast_derived(), Side==OnTheRight ? k : start,
389  Side==OnTheRight ? start : k,
390  Side==OnTheRight ? bs : m_vectors.rows()-start,
391  Side==OnTheRight ? m_vectors.cols()-start : bs);
392  std::conditional_t<Side==OnTheRight, Transpose<SubVectorsType>, SubVectorsType&> sub_vecs(sub_vecs1);
393 
394  Index dstRows = rows()-m_shift-k;
395 
396  if (inputIsIdentity)
397  {
398  Block<Dest, Dynamic, Dynamic> sub_dst = dst.bottomRightCorner(dstRows, dstRows);
399  apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_reverse);
400  }
401  else
402  {
403  auto sub_dst = dst.bottomRows(dstRows);
404  apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_reverse);
405  }
406  }
407  }
408  else
409  {
410  workspace.resize(dst.cols());
411  for(Index k = 0; k < m_length; ++k)
412  {
413  Index actual_k = m_reverse ? k : m_length-k-1;
414  Index dstRows = rows()-m_shift-actual_k;
415 
416  if (inputIsIdentity)
417  {
418  Block<Dest, Dynamic, Dynamic> sub_dst = dst.bottomRightCorner(dstRows, dstRows);
419  sub_dst.applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
420  }
421  else
422  {
423  auto sub_dst = dst.bottomRows(dstRows);
424  sub_dst.applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
425  }
426  }
427  }
428  }
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Number of rows of transformation viewed as a matrix.
const EssentialVectorType essentialVector(Index k) const
Essential part of a Householder vector.
static const lastp1_t end
@ OnTheRight
Definition: Constants.h:336
bfloat16() max(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:690
bfloat16() min(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:684
void apply_block_householder_on_the_left(MatrixType &mat, const VectorsType &vectors, const CoeffsType &hCoeffs, bool forward)
const int Dynamic
Definition: Constants.h:24

◆ applyThisOnTheRight() [1/2]

template<typename VectorsType , typename CoeffsType , int Side>
template<typename Dest >
void Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::applyThisOnTheRight ( Dest &  dst) const
inline

Definition at line 343 of file HouseholderSequence.h.

344  {
345  Matrix<Scalar,1,Dest::RowsAtCompileTime,RowMajor,1,Dest::MaxRowsAtCompileTime> workspace(dst.rows());
346  applyThisOnTheRight(dst, workspace);
347  }
void applyThisOnTheRight(Dest &dst) const

◆ applyThisOnTheRight() [2/2]

template<typename VectorsType , typename CoeffsType , int Side>
template<typename Dest , typename Workspace >
void Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::applyThisOnTheRight ( Dest &  dst,
Workspace &  workspace 
) const
inline

Definition at line 351 of file HouseholderSequence.h.

352  {
353  workspace.resize(dst.rows());
354  for(Index k = 0; k < m_length; ++k)
355  {
356  Index actual_k = m_reverse ? m_length-k-1 : k;
357  dst.rightCols(rows()-m_shift-actual_k)
358  .applyHouseholderOnTheRight(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
359  }
360  }

◆ cols()

template<typename VectorsType , typename CoeffsType , int Side>
EIGEN_CONSTEXPR Index Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::cols ( void  ) const
inline

Number of columns of transformation viewed as a matrix.

Returns
Number of columns

This equals the dimension of the space that the transformation acts on.

Definition at line 214 of file HouseholderSequence.h.

214 { return rows(); }

◆ conjugate()

template<typename VectorsType , typename CoeffsType , int Side>
ConjugateReturnType Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::conjugate ( void  ) const
inline

Complex conjugate of the Householder sequence.

Definition at line 247 of file HouseholderSequence.h.

248  {
249  return ConjugateReturnType(m_vectors.conjugate(), m_coeffs.conjugate())
250  .setReverseFlag(m_reverse)
251  .setLength(m_length)
252  .setShift(m_shift);
253  }
HouseholderSequence< std::conditional_t< NumTraits< Scalar >::IsComplex, internal::remove_all_t< typename VectorsType::ConjugateReturnType >, VectorsType >, std::conditional_t< NumTraits< Scalar >::IsComplex, internal::remove_all_t< typename CoeffsType::ConjugateReturnType >, CoeffsType >, Side > ConjugateReturnType

◆ conjugateIf()

template<typename VectorsType , typename CoeffsType , int Side>
template<bool Cond>
std::conditional_t<Cond,ConjugateReturnType,ConstHouseholderSequence> Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::conjugateIf ( ) const
inline
Returns
an expression of the complex conjugate of *this if Cond==true, returns *this otherwise.

Definition at line 261 of file HouseholderSequence.h.

262  {
263  typedef std::conditional_t<Cond,ConjugateReturnType,ConstHouseholderSequence> ReturnType;
264  return ReturnType(m_vectors.template conjugateIf<Cond>(), m_coeffs.template conjugateIf<Cond>());
265  }

◆ essentialVector()

template<typename VectorsType , typename CoeffsType , int Side>
const EssentialVectorType Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::essentialVector ( Index  k) const
inline

Essential part of a Householder vector.

Parameters
[in]kIndex of Householder reflection
Returns
Vector containing non-trivial entries of k-th 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 \) equals k + shift(), corresponding to the k-th column of the matrix v passed to the constructor.

See also
setShift(), shift()

Definition at line 231 of file HouseholderSequence.h.

232  {
233  eigen_assert(k >= 0 && k < m_length);
234  return internal::hseq_side_dependent_impl<VectorsType,CoeffsType,Side>::essentialVector(*this, k);
235  }
#define eigen_assert(x)
Definition: Macros.h:902

◆ evalTo() [1/2]

template<typename VectorsType , typename CoeffsType , int Side>
template<typename Dest , typename Workspace >
void Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::evalTo ( Dest &  dst,
Workspace &  workspace 
) const
inline

Definition at line 292 of file HouseholderSequence.h.

293  {
294  workspace.resize(rows());
295  Index vecs = m_length;
297  {
298  // in-place
299  dst.diagonal().setOnes();
300  dst.template triangularView<StrictlyUpper>().setZero();
301  for(Index k = vecs-1; k >= 0; --k)
302  {
303  Index cornerSize = rows() - k - m_shift;
304  if(m_reverse)
305  dst.bottomRightCorner(cornerSize, cornerSize)
306  .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data());
307  else
308  dst.bottomRightCorner(cornerSize, cornerSize)
309  .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), workspace.data());
310 
311  // clear the off diagonal vector
312  dst.col(k).tail(rows()-k-1).setZero();
313  }
314  // clear the remaining columns if needed
315  for(Index k = 0; k<cols()-vecs ; ++k)
316  dst.col(k).tail(rows()-k-1).setZero();
317  }
318  else if(m_length>BlockSize)
319  {
320  dst.setIdentity(rows(), rows());
321  if(m_reverse)
322  applyThisOnTheLeft(dst,workspace,true);
323  else
324  applyThisOnTheLeft(dst,workspace,true);
325  }
326  else
327  {
328  dst.setIdentity(rows(), rows());
329  for(Index k = vecs-1; k >= 0; --k)
330  {
331  Index cornerSize = rows() - k - m_shift;
332  if(m_reverse)
333  dst.bottomRightCorner(cornerSize, cornerSize)
334  .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data());
335  else
336  dst.bottomRightCorner(cornerSize, cornerSize)
337  .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), workspace.data());
338  }
339  }
340  }
v setZero(3)
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Number of columns of transformation viewed as a matrix.
bool is_same_dense(const T1 &mat1, const T2 &mat2, std::enable_if_t< possibly_same_dense< T1, T2 >::value > *=0)
Definition: XprHelper.h:745

◆ evalTo() [2/2]

template<typename VectorsType , typename CoeffsType , int Side>
template<typename DestType >
void Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::evalTo ( DestType &  dst) const
inline

Definition at line 282 of file HouseholderSequence.h.

283  {
284  Matrix<Scalar, DestType::RowsAtCompileTime, 1,
285  AutoAlign|ColMajor, DestType::MaxRowsAtCompileTime, 1> workspace(rows());
286  evalTo(dst, workspace);
287  }
internal::traits< HouseholderSequence >::Scalar Scalar
void evalTo(DestType &dst) const
@ ColMajor
Definition: Constants.h:321
@ AutoAlign
Definition: Constants.h:325

◆ inverse()

template<typename VectorsType , typename CoeffsType , int Side>
AdjointReturnType Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::inverse ( ) const
inline

Inverse of the Householder sequence (equals the adjoint).

Definition at line 277 of file HouseholderSequence.h.

277 { return adjoint(); }
AdjointReturnType adjoint() const
Adjoint (conjugate transpose) of the Householder sequence.

◆ length()

template<typename VectorsType , typename CoeffsType , int Side>
Index Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::length ( ) const
inline

Returns the length of the Householder sequence.

Definition at line 483 of file HouseholderSequence.h.

◆ operator*()

template<typename VectorsType , typename CoeffsType , int Side>
template<typename OtherDerived >
internal::matrix_type_times_scalar_type<Scalar, OtherDerived>::Type Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::operator* ( const MatrixBase< OtherDerived > &  other) const
inline

Computes the product of a Householder sequence with a matrix.

Parameters
[in]otherMatrix being multiplied.
Returns
Expression object representing the product.

This function computes \( HM \) where \( H \) is the Householder sequence represented by *this and \( M \) is the matrix other.

Definition at line 438 of file HouseholderSequence.h.

439  {
441  res(other.template cast<typename internal::matrix_type_times_scalar_type<Scalar,OtherDerived>::ResultScalar>());
442  applyThisOnTheLeft(res, internal::is_identity<OtherDerived>::value && res.rows()==res.cols());
443  return res;
444  }
CastXpr< NewType >::Type cast() const
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res

◆ reverseFlag()

template<typename VectorsType , typename CoeffsType , int Side>
bool Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::reverseFlag ( ) const
inlineprotected

Definition at line 509 of file HouseholderSequence.h.

◆ rows()

template<typename VectorsType , typename CoeffsType , int Side>
EIGEN_CONSTEXPR Index Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::rows ( void  ) const
inline

Number of rows of transformation viewed as a matrix.

Returns
Number of rows

This equals the dimension of the space that the transformation acts on.

Definition at line 207 of file HouseholderSequence.h.

207 { return Side==OnTheLeft ? m_vectors.rows() : m_vectors.cols(); }
@ OnTheLeft
Definition: Constants.h:334

◆ setLength()

template<typename VectorsType , typename CoeffsType , int Side>
HouseholderSequence& Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::setLength ( Index  length)
inline

Sets the length of the Householder sequence.

Parameters
[in]lengthNew value for the length.

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 equals length.

See also
length()

Definition at line 458 of file HouseholderSequence.h.

459  {
460  m_length = length;
461  return *this;
462  }
Index length() const
Returns the length of the Householder sequence.

◆ setReverseFlag()

template<typename VectorsType , typename CoeffsType , int Side>
HouseholderSequence& Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::setReverseFlag ( bool  reverse)
inlineprotected

Definition at line 503 of file HouseholderSequence.h.

504  {
505  m_reverse = reverse;
506  return *this;
507  }

◆ setShift()

template<typename VectorsType , typename CoeffsType , int Side>
HouseholderSequence& Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::setShift ( Index  shift)
inline

Sets the shift of the Householder sequence.

Parameters
[in]shiftNew value for the shift.

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 of v corresponds to the (shift+i)-th Householder reflection.

See also
shift()

Definition at line 476 of file HouseholderSequence.h.

477  {
478  m_shift = shift;
479  return *this;
480  }
Index shift() const
Returns the shift of the Householder sequence.

◆ shift()

template<typename VectorsType , typename CoeffsType , int Side>
Index Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::shift ( ) const
inline

Returns the shift of the Householder sequence.

Definition at line 486 of file HouseholderSequence.h.

◆ transpose()

template<typename VectorsType , typename CoeffsType , int Side>
TransposeReturnType Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::transpose ( ) const
inline

Transpose of the Householder sequence.

Definition at line 238 of file HouseholderSequence.h.

239  {
240  return TransposeReturnType(m_vectors.conjugate(), m_coeffs)
241  .setReverseFlag(!m_reverse)
242  .setLength(m_length)
243  .setShift(m_shift);
244  }
HouseholderSequence< std::conditional_t< NumTraits< Scalar >::IsComplex, internal::remove_all_t< typename VectorsType::ConjugateReturnType >, VectorsType >, CoeffsType, Side > TransposeReturnType

Member Data Documentation

◆ m_coeffs

template<typename VectorsType , typename CoeffsType , int Side>
CoeffsType::Nested Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_coeffs
protected

Definition at line 512 of file HouseholderSequence.h.

◆ m_length

template<typename VectorsType , typename CoeffsType , int Side>
Index Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_length
protected

Definition at line 514 of file HouseholderSequence.h.

◆ m_reverse

template<typename VectorsType , typename CoeffsType , int Side>
bool Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_reverse
protected

Definition at line 513 of file HouseholderSequence.h.

◆ m_shift

template<typename VectorsType , typename CoeffsType , int Side>
Index Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_shift
protected

Definition at line 515 of file HouseholderSequence.h.

◆ m_vectors

template<typename VectorsType , typename CoeffsType , int Side>
VectorsType::Nested Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_vectors
protected

Definition at line 511 of file HouseholderSequence.h.


The documentation for this class was generated from the following files: