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

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

#include <HouseholderSequence.h>

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

Public Types

enum  { RowsAtCompileTime = internal::traits<HouseholderSequence>::RowsAtCompileTime , ColsAtCompileTime = internal::traits<HouseholderSequence>::ColsAtCompileTime , MaxRowsAtCompileTime = internal::traits<HouseholderSequence>::MaxRowsAtCompileTime , MaxColsAtCompileTime = internal::traits<HouseholderSequence>::MaxColsAtCompileTime }
 
typedef internal::traits< HouseholderSequence >::Scalar Scalar
 
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 >, SideConjugateReturnType
 
typedef HouseholderSequence< VectorsType, std::conditional_t< NumTraits< Scalar >::IsComplex, internal::remove_all_t< typename CoeffsType::ConjugateReturnType >, CoeffsType >, SideAdjointReturnType
 
typedef HouseholderSequence< std::conditional_t< NumTraits< Scalar >::IsComplex, internal::remove_all_t< typename VectorsType::ConjugateReturnType >, VectorsType >, CoeffsType, SideTransposeReturnType
 
typedef HouseholderSequence< std::add_const_t< VectorsType >, std::add_const_t< CoeffsType >, SideConstHouseholderSequence
 
- 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

EIGEN_DEVICE_FUNC HouseholderSequence (const VectorsType &v, const CoeffsType &h)
 Constructor. More...
 
EIGEN_DEVICE_FUNC HouseholderSequence (const HouseholderSequence &other)
 Copy constructor. More...
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 Number of rows of transformation viewed as a matrix. More...
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 Number of columns of transformation viewed as a matrix. More...
 
EIGEN_DEVICE_FUNC const EssentialVectorType essentialVector (Index k) const
 Essential part of a Householder vector. More...
 
TransposeReturnType transpose () const
 Transpose of the Householder sequence. More...
 
ConjugateReturnType conjugate () const
 Complex conjugate of the Householder sequence. More...
 
template<bool Cond>
EIGEN_DEVICE_FUNC std::conditional_t< Cond, ConjugateReturnType, ConstHouseholderSequenceconjugateIf () const
 
AdjointReturnType adjoint () const
 Adjoint (conjugate transpose) of the Householder sequence. More...
 
AdjointReturnType inverse () const
 Inverse of the Householder sequence (equals the adjoint). More...
 
template<typename DestType >
EIGEN_DEVICE_FUNC void evalTo (DestType &dst) const
 
template<typename Dest , typename Workspace >
EIGEN_DEVICE_FUNC void evalTo (Dest &dst, Workspace &workspace) const
 
template<typename Dest >
void applyThisOnTheRight (Dest &dst) const
 
template<typename Dest , typename Workspace >
void applyThisOnTheRight (Dest &dst, Workspace &workspace) const
 
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 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_DEVICE_FUNC HouseholderSequencesetLength (Index length)
 Sets the length of the Householder sequence. More...
 
EIGEN_DEVICE_FUNC HouseholderSequencesetShift (Index shift)
 Sets the shift of the Householder sequence. More...
 
EIGEN_DEVICE_FUNC Index length () const
 Returns the length of the Householder sequence. More...
 
EIGEN_DEVICE_FUNC Index shift () const
 Returns the shift of the Householder sequence. More...
 
- Public Member Functions inherited from Eigen::EigenBase< HouseholderSequence< VectorsType, CoeffsType, Side > >
constexpr EIGEN_DEVICE_FUNC HouseholderSequence< VectorsType, CoeffsType, Side > & derived ()
 
constexpr EIGEN_DEVICE_FUNC const HouseholderSequence< VectorsType, CoeffsType, Side > & derived () const
 
EIGEN_DEVICE_FUNC HouseholderSequence< VectorsType, CoeffsType, Side > & const_cast_derived () const
 
EIGEN_DEVICE_FUNC const HouseholderSequence< VectorsType, CoeffsType, Side > & const_derived () const
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC void evalTo (Dest &dst) const
 
EIGEN_DEVICE_FUNC void addTo (Dest &dst) const
 
EIGEN_DEVICE_FUNC void subTo (Dest &dst) const
 
EIGEN_DEVICE_FUNC void applyThisOnTheRight (Dest &dst) const
 
EIGEN_DEVICE_FUNC void applyThisOnTheLeft (Dest &dst) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper< HouseholderSequence< VectorsType, CoeffsType, Side >, Device > device (Device &device)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper< const HouseholderSequence< VectorsType, CoeffsType, Side >, Device > device (Device &device) const
 

Protected Types

enum  { BlockSize = 48 }
 

Protected Member Functions

HouseholderSequencesetReverseFlag (bool reverse)
 Sets the reverse flag. More...
 
bool reverseFlag () const
 Returns the reverse flag. More...
 

Protected Attributes

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

Private Types

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

Friends

template<typename VectorsType_ , typename CoeffsType_ , int Side_>
struct internal::hseq_side_dependent_impl
 
template<typename VectorsType2 , typename CoeffsType2 , int Side2>
class HouseholderSequence
 

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.

\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
MatrixXf H
Definition: HessenbergDecomposition_matrixH.cpp:4
MatrixXf Q
Definition: HouseholderQR_householderQ.cpp:1
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47

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

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

◆ 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

◆ 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

◆ 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

◆ Scalar

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

◆ 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

Member Enumeration Documentation

◆ anonymous enum

template<typename VectorsType , typename CoeffsType , int Side>
anonymous enum
Enumerator
RowsAtCompileTime 
ColsAtCompileTime 
MaxRowsAtCompileTime 
MaxColsAtCompileTime 
122  {
123  RowsAtCompileTime = internal::traits<HouseholderSequence>::RowsAtCompileTime,
124  ColsAtCompileTime = internal::traits<HouseholderSequence>::ColsAtCompileTime,
125  MaxRowsAtCompileTime = internal::traits<HouseholderSequence>::MaxRowsAtCompileTime,
126  MaxColsAtCompileTime = internal::traits<HouseholderSequence>::MaxColsAtCompileTime
127  };
@ ColsAtCompileTime
Definition: HouseholderSequence.h:124
@ MaxColsAtCompileTime
Definition: HouseholderSequence.h:126
@ MaxRowsAtCompileTime
Definition: HouseholderSequence.h:125
@ RowsAtCompileTime
Definition: HouseholderSequence.h:123

◆ anonymous enum

template<typename VectorsType , typename CoeffsType , int Side>
anonymous enum
protected
Enumerator
BlockSize 
458 { BlockSize = 48 };
@ BlockSize
Definition: HouseholderSequence.h:458

Constructor & Destructor Documentation

◆ HouseholderSequence() [1/2]

template<typename VectorsType , typename CoeffsType , int Side>
EIGEN_DEVICE_FUNC 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:

Matrix3d v = Matrix3d::Random();
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);
Matrix3d hhSeqAsMatrix(hhSeq);
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
Definition: Array_initializer_list_vector_cxx11.cpp:1
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())
double H0
Definition: refineable_two_layer_soluble_surfactant.cc:97

Output:

See also
setLength(), setShift()
172  : m_vectors(v), m_coeffs(h), m_reverse(false), m_length(v.diagonalSize()), m_shift(0) {}
Index m_length
Definition: HouseholderSequence.h:456
bool m_reverse
Definition: HouseholderSequence.h:455
CoeffsType::Nested m_coeffs
Definition: HouseholderSequence.h:454
VectorsType::Nested m_vectors
Definition: HouseholderSequence.h:453
Index m_shift
Definition: HouseholderSequence.h:457

◆ HouseholderSequence() [2/2]

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

Copy constructor.

176  : m_vectors(other.m_vectors),
177  m_coeffs(other.m_coeffs),
178  m_reverse(other.m_reverse),
179  m_length(other.m_length),
180  m_shift(other.m_shift) {}

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.

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

References Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_coeffs, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_length, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_reverse, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_shift, and Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_vectors.

Referenced by householder(), Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::inverse(), and selfadjointeigensolver().

◆ 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
322  {
323  Matrix<Scalar, 1, Dest::ColsAtCompileTime, RowMajor, 1, Dest::MaxColsAtCompileTime> workspace;
324  applyThisOnTheLeft(dst, workspace, inputIsIdentity);
325  }
void applyThisOnTheLeft(Dest &dst, bool inputIsIdentity=false) const
Definition: HouseholderSequence.h:322

Referenced by Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::evalTo(), and Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::operator*().

◆ 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
329  {
330  if (inputIsIdentity && m_reverse) inputIsIdentity = false;
331  // if the entries are large enough, then apply the reflectors by block
332  if (m_length >= BlockSize && dst.cols() > 1) {
333  // Make sure we have at least 2 useful blocks, otherwise it is point-less:
334  Index blockSize = m_length < Index(2 * BlockSize) ? (m_length + 1) / 2 : Index(BlockSize);
335  for (Index i = 0; i < m_length; i += blockSize) {
336  Index end = m_reverse ? (std::min)(m_length, i + blockSize) : m_length - i;
337  Index k = m_reverse ? i : (std::max)(Index(0), end - blockSize);
338  Index bs = end - k;
339  Index start = k + m_shift;
340 
341  typedef Block<internal::remove_all_t<VectorsType>, Dynamic, Dynamic> SubVectorsType;
342  SubVectorsType sub_vecs1(m_vectors.const_cast_derived(), Side == OnTheRight ? k : start,
343  Side == OnTheRight ? start : k, Side == OnTheRight ? bs : m_vectors.rows() - start,
344  Side == OnTheRight ? m_vectors.cols() - start : bs);
345  std::conditional_t<Side == OnTheRight, Transpose<SubVectorsType>, SubVectorsType&> sub_vecs(sub_vecs1);
346 
347  Index dstRows = rows() - m_shift - k;
348 
349  if (inputIsIdentity) {
350  Block<Dest, Dynamic, Dynamic> sub_dst = dst.bottomRightCorner(dstRows, dstRows);
351  apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_reverse);
352  } else {
353  auto sub_dst = dst.bottomRows(dstRows);
354  apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_reverse);
355  }
356  }
357  } else {
358  workspace.resize(dst.cols());
359  for (Index k = 0; k < m_length; ++k) {
360  Index actual_k = m_reverse ? k : m_length - k - 1;
361  Index dstRows = rows() - m_shift - actual_k;
362 
363  if (inputIsIdentity) {
364  Block<Dest, Dynamic, Dynamic> sub_dst = dst.bottomRightCorner(dstRows, dstRows);
365  sub_dst.applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
366  } else {
367  auto sub_dst = dst.bottomRows(dstRows);
368  sub_dst.applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
369  }
370  }
371  }
372  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Side
Definition: Side.h:9
EIGEN_DEVICE_FUNC const EssentialVectorType essentialVector(Index k) const
Essential part of a Householder vector.
Definition: HouseholderSequence.h:210
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Number of rows of transformation viewed as a matrix.
Definition: HouseholderSequence.h:186
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
static constexpr lastp1_t end
Definition: IndexedViewHelper.h:79
@ OnTheRight
Definition: Constants.h:333
char char char int int * k
Definition: level2_impl.h:374
void apply_block_householder_on_the_left(MatrixType &mat, const VectorsType &vectors, const CoeffsType &hCoeffs, bool forward)
Definition: BlockHouseholder.h:86
const int Dynamic
Definition: Constants.h:25
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.cc:243
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:43

References Eigen::internal::apply_block_householder_on_the_left(), Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::BlockSize, Eigen::Dynamic, Eigen::placeholders::end, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::essentialVector(), i, k, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_coeffs, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_length, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_reverse, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_shift, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_vectors, max, min, Eigen::OnTheRight, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::rows(), and oomph::CumulativeTimings::start().

◆ applyThisOnTheRight() [1/2]

template<typename VectorsType , typename CoeffsType , int Side>
template<typename Dest >
void Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::applyThisOnTheRight ( Dest &  dst) const
inline
304  {
305  Matrix<Scalar, 1, Dest::RowsAtCompileTime, RowMajor, 1, Dest::MaxRowsAtCompileTime> workspace(dst.rows());
306  applyThisOnTheRight(dst, workspace);
307  }
void applyThisOnTheRight(Dest &dst) const
Definition: HouseholderSequence.h:304

Referenced by Eigen::operator*().

◆ 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

◆ cols()

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

◆ conjugate()

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

Complex conjugate of the Householder sequence.

224  {
225  return ConjugateReturnType(m_vectors.conjugate(), m_coeffs.conjugate())
226  .setReverseFlag(m_reverse)
227  .setLength(m_length)
228  .setShift(m_shift);
229  }
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
Definition: HouseholderSequence.h:136

References Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_coeffs, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_length, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_reverse, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_shift, and Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_vectors.

Referenced by householder().

◆ conjugateIf()

template<typename VectorsType , typename CoeffsType , int Side>
template<bool Cond>
EIGEN_DEVICE_FUNC 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.
235  {
236  typedef std::conditional_t<Cond, ConjugateReturnType, ConstHouseholderSequence> ReturnType;
237  return ReturnType(m_vectors.template conjugateIf<Cond>(), m_coeffs.template conjugateIf<Cond>());
238  }

References Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_coeffs, and Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_vectors.

◆ essentialVector()

template<typename VectorsType , typename CoeffsType , int Side>
EIGEN_DEVICE_FUNC 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()
210  {
211  eigen_assert(k >= 0 && k < m_length);
213  }
#define eigen_assert(x)
Definition: Macros.h:910
static EIGEN_DEVICE_FUNC const EssentialVectorType essentialVector(const HouseholderSequenceType &h, Index k)
Definition: HouseholderSequence.h:90

References eigen_assert, Eigen::internal::hseq_side_dependent_impl< VectorsType, CoeffsType, Side >::essentialVector(), k, and Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_length.

Referenced by Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::applyThisOnTheLeft(), Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::applyThisOnTheRight(), and Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::evalTo().

◆ evalTo() [1/2]

template<typename VectorsType , typename CoeffsType , int Side>
template<typename Dest , typename Workspace >
EIGEN_DEVICE_FUNC void Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::evalTo ( Dest &  dst,
Workspace &  workspace 
) const
inline
261  {
262  workspace.resize(rows());
263  Index vecs = m_length;
265  // in-place
266  dst.diagonal().setOnes();
267  dst.template triangularView<StrictlyUpper>().setZero();
268  for (Index k = vecs - 1; k >= 0; --k) {
269  Index cornerSize = rows() - k - m_shift;
270  if (m_reverse)
271  dst.bottomRightCorner(cornerSize, cornerSize)
272  .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data());
273  else
274  dst.bottomRightCorner(cornerSize, cornerSize)
275  .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), workspace.data());
276 
277  // clear the off diagonal vector
278  dst.col(k).tail(rows() - k - 1).setZero();
279  }
280  // clear the remaining columns if needed
281  for (Index k = 0; k < cols() - vecs; ++k) dst.col(k).tail(rows() - k - 1).setZero();
282  } else if (m_length > BlockSize) {
283  dst.setIdentity(rows(), rows());
284  if (m_reverse)
285  applyThisOnTheLeft(dst, workspace, true);
286  else
287  applyThisOnTheLeft(dst, workspace, true);
288  } else {
289  dst.setIdentity(rows(), rows());
290  for (Index k = vecs - 1; k >= 0; --k) {
291  Index cornerSize = rows() - k - m_shift;
292  if (m_reverse)
293  dst.bottomRightCorner(cornerSize, cornerSize)
294  .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data());
295  else
296  dst.bottomRightCorner(cornerSize, cornerSize)
297  .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), workspace.data());
298  }
299  }
300  }
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Number of columns of transformation viewed as a matrix.
Definition: HouseholderSequence.h:194
res setZero()
EIGEN_DEVICE_FUNC bool is_same_dense(const T1 &mat1, const T2 &mat2, std::enable_if_t< possibly_same_dense< T1, T2 >::value > *=0)
Definition: XprHelper.h:869

References Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::applyThisOnTheLeft(), Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::BlockSize, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::cols(), Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::essentialVector(), Eigen::internal::is_same_dense(), k, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_coeffs, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_length, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_reverse, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_shift, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_vectors, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::rows(), and setZero().

◆ evalTo() [2/2]

template<typename VectorsType , typename CoeffsType , int Side>
template<typename DestType >
EIGEN_DEVICE_FUNC void Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::evalTo ( DestType &  dst) const
inline
253  {
254  Matrix<Scalar, DestType::RowsAtCompileTime, 1, AutoAlign | ColMajor, DestType::MaxRowsAtCompileTime, 1> workspace(
255  rows());
256  evalTo(dst, workspace);
257  }
EIGEN_DEVICE_FUNC void evalTo(DestType &dst) const
Definition: HouseholderSequence.h:253

References Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::rows().

Referenced by Eigen::internal::tridiagonalization_inplace_selector< MatrixType, Size, IsComplex >::run().

◆ 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).

249 { return adjoint(); }
AdjointReturnType adjoint() const
Adjoint (conjugate transpose) of the Householder sequence.
Definition: HouseholderSequence.h:241

References Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::adjoint().

Referenced by randomMatrixWithRealEivals(), randomMatrixWithImagEivals< MatrixType, 0 >::run(), and randomMatrixWithImagEivals< MatrixType, 1 >::run().

◆ length()

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

◆ 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.

383  {
387  return res;
388  }
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
EIGEN_DEVICE_FUNC NewType cast(const OldType &x)
Definition: MathFunctions.h:362
@ value
Definition: XprHelper.h:845
ScalarBinaryOpTraits< OtherScalarType, typename MatrixType::Scalar >::ReturnType ResultScalar
Definition: HouseholderSequence.h:108
Matrix< ResultScalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime, 0, MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime > Type
Definition: HouseholderSequence.h:111

References Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::applyThisOnTheLeft(), Eigen::internal::cast(), and res.

◆ reverseFlag()

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

◆ rows()

◆ setLength()

template<typename VectorsType , typename CoeffsType , int Side>
EIGEN_DEVICE_FUNC 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()
402  {
403  m_length = length;
404  return *this;
405  }
EIGEN_DEVICE_FUNC Index length() const
Returns the length of the Householder sequence.
Definition: HouseholderSequence.h:423

References Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::length(), and Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_length.

Referenced by householder(), and Eigen::internal::tridiagonalization_inplace_selector< MatrixType, Size, IsComplex >::run().

◆ setReverseFlag()

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

Sets the reverse flag.

Parameters
[in]reverseNew value of the reverse flag.

By default, the reverse flag is not set. If the reverse flag is set, then this object represents \( H^r = H_{n-1} \ldots H_1 H_0 \) instead of \( H = H_0 H_1 \ldots H_{n-1} \).

Note
For real valued HouseholderSequence this is equivalent to transposing \( H \).
See also
reverseFlag(), transpose(), adjoint()
446  {
447  m_reverse = reverse;
448  return *this;
449  }
void reverse(const MatrixType &m)
Definition: array_reverse.cpp:17

References Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_reverse, and reverse().

◆ setShift()

template<typename VectorsType , typename CoeffsType , int Side>
EIGEN_DEVICE_FUNC 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()
418  {
419  m_shift = shift;
420  return *this;
421  }
EIGEN_DEVICE_FUNC Index shift() const
Returns the shift of the Householder sequence.
Definition: HouseholderSequence.h:427

References Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_shift, and Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::shift().

Referenced by householder(), and Eigen::internal::tridiagonalization_inplace_selector< MatrixType, Size, IsComplex >::run().

◆ shift()

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

◆ transpose()

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

Transpose of the Householder sequence.

216  {
217  return TransposeReturnType(m_vectors.conjugate(), m_coeffs)
218  .setReverseFlag(!m_reverse)
219  .setLength(m_length)
220  .setShift(m_shift);
221  }
HouseholderSequence< std::conditional_t< NumTraits< Scalar >::IsComplex, internal::remove_all_t< typename VectorsType::ConjugateReturnType >, VectorsType >, CoeffsType, Side > TransposeReturnType
Definition: HouseholderSequence.h:149

References Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_coeffs, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_length, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_reverse, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_shift, and Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::m_vectors.

Referenced by householder(), Eigen::HybridNonLinearSolver< FunctorType, Scalar >::solveNumericalDiffOneStep(), and Eigen::HybridNonLinearSolver< FunctorType, Scalar >::solveOneStep().

Friends And Related Function Documentation

◆ HouseholderSequence

template<typename VectorsType , typename CoeffsType , int Side>
template<typename VectorsType2 , typename CoeffsType2 , int Side2>
friend class HouseholderSequence
friend

◆ internal::hseq_side_dependent_impl

template<typename VectorsType , typename CoeffsType , int Side>
template<typename VectorsType_ , typename CoeffsType_ , int Side_>
friend struct internal::hseq_side_dependent_impl
friend

Member Data Documentation

◆ m_coeffs

◆ m_length

◆ m_reverse

◆ m_shift

◆ m_vectors


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