11#ifndef EIGEN_HOUSEHOLDER_SEQUENCE_H
12#define EIGEN_HOUSEHOLDER_SEQUENCE_H
61template<
typename VectorsType,
typename CoeffsType,
int S
ide>
64 typedef typename VectorsType::Scalar Scalar;
65 typedef typename VectorsType::StorageIndex StorageIndex;
66 typedef typename VectorsType::StorageKind StorageKind;
70 ColsAtCompileTime = RowsAtCompileTime,
73 MaxColsAtCompileTime = MaxRowsAtCompileTime,
80template<
typename VectorsType,
typename CoeffsType,
int S
ide>
87template<
typename VectorsType,
typename CoeffsType,
int S
ide>
94 Index start = k+1+h.m_shift;
99template<
typename VectorsType,
typename CoeffsType>
106 Index start = k+1+h.m_shift;
115 typedef Matrix<ResultScalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime,
116 0, MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime>
Type;
122 :
public EigenBase<HouseholderSequence<VectorsType,CoeffsType,Side> >
137 typename internal::remove_all<typename VectorsType::ConjugateReturnType>::type,
140 typename internal::remove_all<typename CoeffsType::ConjugateReturnType>::type,
148 typename internal::remove_all<typename CoeffsType::ConjugateReturnType>::type,
155 typename internal::remove_all<typename VectorsType::ConjugateReturnType>::type,
186 : m_vectors(v), m_coeffs(h), m_reverse(
false), m_length(v.diagonalSize()),
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)
206 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
213 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
233 eigen_assert(k >= 0 && k < m_length);
241 .setReverseFlag(!m_reverse)
250 .setReverseFlag(m_reverse)
271 .setReverseFlag(!m_reverse)
280 template<
typename DestType>
281 inline EIGEN_DEVICE_FUNC
284 Matrix<Scalar, DestType::RowsAtCompileTime, 1,
290 template<
typename Dest,
typename Workspace>
292 void evalTo(Dest& dst, Workspace& workspace)
const
294 workspace.resize(
rows());
295 Index vecs = m_length;
296 if(internal::is_same_dense(dst,m_vectors))
299 dst.diagonal().setOnes();
300 dst.template triangularView<StrictlyUpper>().setZero();
301 for(
Index k = vecs-1; k >= 0; --k)
305 dst.bottomRightCorner(cornerSize, cornerSize)
306 .applyHouseholderOnTheRight(
essentialVector(k), m_coeffs.coeff(k), workspace.data());
308 dst.bottomRightCorner(cornerSize, cornerSize)
309 .applyHouseholderOnTheLeft(
essentialVector(k), m_coeffs.coeff(k), workspace.data());
312 dst.col(k).tail(
rows()-k-1).setZero();
316 dst.col(k).tail(
rows()-k-1).setZero();
318 else if(m_length>BlockSize)
322 applyThisOnTheLeft(dst,workspace,
true);
324 applyThisOnTheLeft(dst,workspace,
true);
329 for(
Index k = vecs-1; k >= 0; --k)
333 dst.bottomRightCorner(cornerSize, cornerSize)
334 .applyHouseholderOnTheRight(
essentialVector(k), m_coeffs.coeff(k), workspace.data());
336 dst.bottomRightCorner(cornerSize, cornerSize)
337 .applyHouseholderOnTheLeft(
essentialVector(k), m_coeffs.coeff(k), workspace.data());
343 template<
typename Dest>
inline void applyThisOnTheRight(Dest& dst)
const
346 applyThisOnTheRight(dst, workspace);
350 template<
typename Dest,
typename Workspace>
351 inline void applyThisOnTheRight(Dest& dst, Workspace& workspace)
const
353 workspace.resize(dst.rows());
354 for(
Index k = 0; k < m_length; ++k)
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());
363 template<
typename Dest>
inline void applyThisOnTheLeft(Dest& dst,
bool inputIsIdentity =
false)
const
366 applyThisOnTheLeft(dst, workspace, inputIsIdentity);
370 template<
typename Dest,
typename Workspace>
371 inline void applyThisOnTheLeft(Dest& dst, Workspace& workspace,
bool inputIsIdentity =
false)
const
373 if(inputIsIdentity && m_reverse)
374 inputIsIdentity =
false;
376 if(m_length>=BlockSize && dst.cols()>1)
379 Index blockSize = m_length<
Index(2*BlockSize) ? (m_length+1)/2 :
Index(BlockSize);
380 for(
Index i = 0; i < m_length; i+=blockSize)
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);
385 Index start = k + m_shift;
387 typedef Block<typename internal::remove_all<VectorsType>::type,
Dynamic,
Dynamic> SubVectorsType;
388 SubVectorsType sub_vecs1(m_vectors.const_cast_derived(), Side==
OnTheRight ? k : start,
392 typename internal::conditional<Side==OnTheRight, Transpose<SubVectorsType>, SubVectorsType&>::type sub_vecs(sub_vecs1);
394 Index dstStart = dst.rows()-
rows()+m_shift+k;
396 Block<Dest,Dynamic,Dynamic> sub_dst(dst,
398 inputIsIdentity ? dstStart : 0,
400 inputIsIdentity ? dstRows : dst.
cols());
401 apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_reverse);
406 workspace.resize(dst.cols());
407 for(
Index k = 0; k < m_length; ++k)
409 Index actual_k = m_reverse ? k : m_length-k-1;
410 Index dstStart =
rows()-m_shift-actual_k;
411 dst.bottomRightCorner(dstStart, inputIsIdentity ? dstStart : dst.
cols())
412 .applyHouseholderOnTheLeft(
essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
424 template<
typename OtherDerived>
428 res(other.template cast<
typename internal::matrix_type_times_scalar_type<Scalar,OtherDerived>::ResultScalar>());
476 template <
typename VectorsType2,
typename CoeffsType2,
int S
ide2>
friend class HouseholderSequence;
496 bool reverseFlag()
const {
return m_reverse; }
498 typename VectorsType::Nested m_vectors;
499 typename CoeffsType::Nested m_coeffs;
503 enum { BlockSize = 48 };
514template<
typename OtherDerived,
typename VectorsType,
typename CoeffsType,
int S
ide>
518 res(other.template cast<
typename internal::matrix_type_times_scalar_type<typename VectorsType::Scalar,OtherDerived>::ResultScalar>());
519 h.applyThisOnTheRight(res);
530template<
typename VectorsType,
typename CoeffsType>
545template<
typename VectorsType,
typename CoeffsType>
EIGEN_DEVICE_FUNC TransposeReturnType transpose()
Definition Transpose.h:182
\householder_module
Definition HouseholderSequence.h:123
AdjointReturnType inverse() const
Inverse of the Householder sequence (equals the adjoint).
Definition HouseholderSequence.h:277
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Number of columns of transformation viewed as a matrix.
Definition HouseholderSequence.h:214
EIGEN_DEVICE_FUNC HouseholderSequence(const VectorsType &v, const CoeffsType &h)
Constructor.
Definition HouseholderSequence.h:185
EIGEN_DEVICE_FUNC HouseholderSequence(const HouseholderSequence &other)
Copy constructor.
Definition HouseholderSequence.h:193
EIGEN_DEVICE_FUNC const EssentialVectorType essentialVector(Index k) const
Essential part of a Householder vector.
Definition HouseholderSequence.h:231
EIGEN_DEVICE_FUNC Index shift() const
Returns the shift of the Householder sequence.
Definition HouseholderSequence.h:473
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.
Definition HouseholderSequence.h:425
EIGEN_DEVICE_FUNC Index length() const
Returns the length of the Householder sequence.
Definition HouseholderSequence.h:470
ConjugateReturnType conjugate() const
Complex conjugate of the Householder sequence.
Definition HouseholderSequence.h:247
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Number of rows of transformation viewed as a matrix.
Definition HouseholderSequence.h:207
TransposeReturnType transpose() const
Transpose of the Householder sequence.
Definition HouseholderSequence.h:238
EIGEN_DEVICE_FUNC HouseholderSequence & setShift(Index shift)
Sets the shift of the Householder sequence.
Definition HouseholderSequence.h:463
EIGEN_DEVICE_FUNC internal::conditional< Cond, ConjugateReturnType, ConstHouseholderSequence >::type conjugateIf() const
Definition HouseholderSequence.h:261
EIGEN_DEVICE_FUNC HouseholderSequence & setLength(Index length)
Sets the length of the Householder sequence.
Definition HouseholderSequence.h:445
AdjointReturnType adjoint() const
Adjoint (conjugate transpose) of the Householder sequence.
Definition HouseholderSequence.h:268
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition Constants.h:319
@ AutoAlign
Align the matrix itself if it is vectorizable fixed-size.
Definition Constants.h:323
@ OnTheLeft
Apply transformation on the left.
Definition Constants.h:332
@ OnTheRight
Apply transformation on the right.
Definition Constants.h:334
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
HouseholderSequence< VectorsType, CoeffsType > householderSequence(const VectorsType &v, const CoeffsType &h)
\householder_module
Definition HouseholderSequence.h:531
HouseholderSequence< VectorsType, CoeffsType, OnTheRight > rightHouseholderSequence(const VectorsType &v, const CoeffsType &h)
\householder_module
Definition HouseholderSequence.h:546
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition Constants.h:22
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition EigenBase.h:30
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:39
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition XprHelper.h:806
Definition HouseholderSequence.h:78
Definition CoreEvaluators.h:71
Definition CoreEvaluators.h:80
Definition HouseholderSequence.h:89
Definition XprHelper.h:679
Definition HouseholderSequence.h:112
Definition ForwardDeclarations.h:17
Definition inference.c:32