11 #ifndef EIGEN_HOUSEHOLDER_SEQUENCE_H 12 #define EIGEN_HOUSEHOLDER_SEQUENCE_H 59 template<
typename VectorsType,
typename CoeffsType,
int S
ide>
62 typedef typename VectorsType::Scalar Scalar;
63 typedef typename VectorsType::StorageIndex StorageIndex;
64 typedef typename VectorsType::StorageKind StorageKind;
68 ColsAtCompileTime = RowsAtCompileTime,
71 MaxColsAtCompileTime = MaxRowsAtCompileTime,
78 template<
typename VectorsType,
typename CoeffsType,
int S
ide>
85 template<
typename VectorsType,
typename CoeffsType,
int S
ide>
90 static inline const EssentialVectorType essentialVector(
const HouseholderSequenceType& h,
Index k)
92 Index start = k+1+h.m_shift;
97 template<
typename VectorsType,
typename CoeffsType>
102 static inline const EssentialVectorType essentialVector(
const HouseholderSequenceType& h,
Index k)
104 Index start = k+1+h.m_shift;
113 typedef Matrix<ResultScalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime,
114 0, MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime>
Type;
120 :
public EigenBase<HouseholderSequence<VectorsType,CoeffsType,Side> >
137 typename internal::conditional<NumTraits<Scalar>::IsComplex,
141 > ConjugateReturnType;
161 : m_vectors(v), m_coeffs(h), m_trans(false), m_length(v.diagonalSize()),
168 : m_vectors(other.m_vectors),
169 m_coeffs(other.m_coeffs),
170 m_trans(other.m_trans),
171 m_length(other.m_length),
172 m_shift(other.m_shift)
204 eigen_assert(k >= 0 && k < m_length);
217 return ConjugateReturnType(m_vectors.conjugate(), m_coeffs.conjugate())
226 return conjugate().setTrans(!m_trans);
230 ConjugateReturnType
inverse()
const {
return adjoint(); }
233 template<
typename DestType>
inline void evalTo(DestType& dst)
const 235 Matrix<Scalar, DestType::RowsAtCompileTime, 1,
237 evalTo(dst, workspace);
241 template<
typename Dest,
typename Workspace>
242 void evalTo(Dest& dst, Workspace& workspace)
const 244 workspace.resize(rows());
245 Index vecs = m_length;
246 if(internal::is_same_dense(dst,m_vectors))
249 dst.diagonal().setOnes();
250 dst.template triangularView<StrictlyUpper>().setZero();
251 for(
Index k = vecs-1; k >= 0; --k)
253 Index cornerSize = rows() - k - m_shift;
255 dst.bottomRightCorner(cornerSize, cornerSize)
256 .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data());
258 dst.bottomRightCorner(cornerSize, cornerSize)
259 .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), workspace.data());
262 dst.col(k).tail(rows()-k-1).setZero();
265 for(
Index k = 0; k<cols()-vecs ; ++k)
266 dst.col(k).tail(rows()-k-1).setZero();
270 dst.setIdentity(rows(), rows());
271 for(
Index k = vecs-1; k >= 0; --k)
273 Index cornerSize = rows() - k - m_shift;
275 dst.bottomRightCorner(cornerSize, cornerSize)
276 .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0));
278 dst.bottomRightCorner(cornerSize, cornerSize)
279 .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0));
285 template<
typename Dest>
inline void applyThisOnTheRight(Dest& dst)
const 288 applyThisOnTheRight(dst, workspace);
292 template<
typename Dest,
typename Workspace>
293 inline void applyThisOnTheRight(Dest& dst, Workspace& workspace)
const 295 workspace.resize(dst.rows());
296 for(
Index k = 0; k < m_length; ++k)
298 Index actual_k = m_trans ? m_length-k-1 : k;
299 dst.rightCols(rows()-m_shift-actual_k)
300 .applyHouseholderOnTheRight(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
305 template<
typename Dest>
inline void applyThisOnTheLeft(Dest& dst)
const 308 applyThisOnTheLeft(dst, workspace);
312 template<
typename Dest,
typename Workspace>
313 inline void applyThisOnTheLeft(Dest& dst, Workspace& workspace)
const 315 const Index BlockSize = 48;
317 if(m_length>=BlockSize && dst.cols()>1)
319 for(
Index i = 0; i < m_length; i+=BlockSize)
321 Index end = m_trans ? (std::min)(m_length,i+BlockSize) : m_length-i;
322 Index k = m_trans ? i : (std::max)(
Index(0),end-BlockSize);
324 Index start = k + m_shift;
327 SubVectorsType sub_vecs1(m_vectors.const_cast_derived(), Side==
OnTheRight ? k : start,
329 Side==
OnTheRight ? bs : m_vectors.rows()-start,
330 Side==
OnTheRight ? m_vectors.cols()-start : bs);
333 apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_trans);
338 workspace.resize(dst.cols());
339 for(
Index k = 0; k < m_length; ++k)
341 Index actual_k = m_trans ? k : m_length-k-1;
342 dst.bottomRows(rows()-m_shift-actual_k)
343 .applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
355 template<
typename OtherDerived>
359 res(other.template cast<
typename internal::matrix_type_times_scalar_type<Scalar,OtherDerived>::ResultScalar>());
360 applyThisOnTheLeft(res);
402 template <
typename VectorsType2,
typename CoeffsType2,
int S
ide2>
friend class HouseholderSequence;
420 bool trans()
const {
return m_trans; }
422 typename VectorsType::Nested m_vectors;
423 typename CoeffsType::Nested m_coeffs;
437 template<
typename OtherDerived,
typename VectorsType,
typename CoeffsType,
int S
ide>
441 res(other.template cast<
typename internal::matrix_type_times_scalar_type<typename VectorsType::Scalar,OtherDerived>::ResultScalar>());
442 h.applyThisOnTheRight(res);
450 template<
typename VectorsType,
typename CoeffsType>
462 template<
typename VectorsType,
typename CoeffsType>
470 #endif // EIGEN_HOUSEHOLDER_SEQUENCE_H Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:320
Index cols() const
Number of columns of transformation viewed as a matrix.
Definition: HouseholderSequence.h:186
Apply transformation on the right.
Definition: Constants.h:335
ConjugateReturnType inverse() const
Inverse of the Householder sequence (equals the adjoint).
Definition: HouseholderSequence.h:230
HouseholderSequence & setLength(Index length)
Sets the length of the Householder sequence.
Definition: HouseholderSequence.h:375
Expression of the transpose of a matrix.
Definition: Transpose.h:52
HouseholderSequence(const HouseholderSequence &other)
Copy constructor.
Definition: HouseholderSequence.h:167
bool trans() const
Returns the transpose flag.
Definition: HouseholderSequence.h:420
ConjugateReturnType adjoint() const
Adjoint (conjugate transpose) of the Householder sequence.
Definition: HouseholderSequence.h:224
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
HouseholderSequence(const VectorsType &v, const CoeffsType &h)
Constructor.
Definition: HouseholderSequence.h:160
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:37
HouseholderSequence< VectorsType, CoeffsType > householderSequence(const VectorsType &v, const CoeffsType &h)
\
Definition: HouseholderSequence.h:451
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition: EigenBase.h:28
Definition: HouseholderSequence.h:86
Definition: ForwardDeclarations.h:262
HouseholderSequence & setTrans(bool trans)
Sets the transpose flag.
Definition: HouseholderSequence.h:414
Align the matrix itself if it is vectorizable fixed-size.
Definition: Constants.h:324
Definition: HouseholderSequence.h:76
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Apply transformation on the left.
Definition: Constants.h:333
Index length() const
Returns the length of the Householder sequence.
Definition: HouseholderSequence.h:398
HouseholderSequence< VectorsType, CoeffsType, OnTheRight > rightHouseholderSequence(const VectorsType &v, const CoeffsType &h)
\
Definition: HouseholderSequence.h:463
HouseholderSequence & setShift(Index shift)
Sets the shift of the Householder sequence.
Definition: HouseholderSequence.h:392
Definition: BandTriangularSolver.h:13
Definition: CoreEvaluators.h:79
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:356
const EssentialVectorType essentialVector(Index k) const
Essential part of a Householder vector.
Definition: HouseholderSequence.h:202
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Definition: HouseholderSequence.h:109
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:757
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time, and that instead the value is stored in some runtime variable.
Definition: Constants.h:21
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
Index shift() const
Returns the shift of the Householder sequence.
Definition: HouseholderSequence.h:399
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: ForwardDeclarations.h:17
HouseholderSequence transpose() const
Transpose of the Householder sequence.
Definition: HouseholderSequence.h:209
Definition: CoreEvaluators.h:70
ConjugateReturnType conjugate() const
Complex conjugate of the Householder sequence.
Definition: HouseholderSequence.h:215
Index rows() const
Number of rows of transformation viewed as a matrix.
Definition: HouseholderSequence.h:180