11 #ifndef EIGEN_HOUSEHOLDER_SEQUENCE_H 12 #define EIGEN_HOUSEHOLDER_SEQUENCE_H 59 template<
typename VectorsType,
typename CoeffsType,
int S
ide>
63 typedef typename VectorsType::Index Index;
64 typedef typename VectorsType::StorageKind StorageKind;
68 ColsAtCompileTime = RowsAtCompileTime,
71 MaxColsAtCompileTime = MaxRowsAtCompileTime,
76 template<
typename VectorsType,
typename CoeffsType,
int S
ide>
81 typedef typename VectorsType::Index Index;
82 static inline const EssentialVectorType essentialVector(
const HouseholderSequenceType& h, Index k)
84 Index start = k+1+h.m_shift;
89 template<
typename VectorsType,
typename CoeffsType>
94 typedef typename VectorsType::Index Index;
95 static inline const EssentialVectorType essentialVector(
const HouseholderSequenceType& h, Index k)
97 Index start = k+1+h.m_shift;
106 typedef Matrix<ResultScalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime,
107 0, MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime>
Type;
113 :
public EigenBase<HouseholderSequence<VectorsType,CoeffsType,Side> >
125 typedef typename VectorsType::Index Index;
131 typename internal::conditional<NumTraits<Scalar>::IsComplex,
135 > ConjugateReturnType;
155 : m_vectors(v), m_coeffs(h), m_trans(false), m_length(v.diagonalSize()),
162 : m_vectors(other.m_vectors),
163 m_coeffs(other.m_coeffs),
164 m_trans(other.m_trans),
165 m_length(other.m_length),
166 m_shift(other.m_shift)
174 Index
rows()
const {
return Side==
OnTheLeft ? m_vectors.rows() : m_vectors.cols(); }
180 Index
cols()
const {
return rows(); }
198 eigen_assert(k >= 0 && k < m_length);
211 return ConjugateReturnType(m_vectors.conjugate(), m_coeffs.conjugate())
220 return conjugate().setTrans(!m_trans);
224 ConjugateReturnType
inverse()
const {
return adjoint(); }
227 template<
typename DestType>
inline void evalTo(DestType& dst)
const 231 evalTo(dst, workspace);
235 template<
typename Dest,
typename Workspace>
236 void evalTo(Dest& dst, Workspace& workspace)
const 238 workspace.resize(rows());
239 Index vecs = m_length;
241 && internal::extract_data(dst) == internal::extract_data(m_vectors))
244 dst.diagonal().setOnes();
245 dst.template triangularView<StrictlyUpper>().setZero();
246 for(Index k = vecs-1; k >= 0; --k)
248 Index cornerSize = rows() - k - m_shift;
250 dst.bottomRightCorner(cornerSize, cornerSize)
251 .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data());
253 dst.bottomRightCorner(cornerSize, cornerSize)
254 .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), workspace.data());
257 dst.col(k).tail(rows()-k-1).setZero();
260 for(Index k = 0; k<cols()-vecs ; ++k)
261 dst.col(k).tail(rows()-k-1).setZero();
265 dst.setIdentity(rows(), rows());
266 for(Index k = vecs-1; k >= 0; --k)
268 Index cornerSize = rows() - k - m_shift;
270 dst.bottomRightCorner(cornerSize, cornerSize)
271 .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0));
273 dst.bottomRightCorner(cornerSize, cornerSize)
274 .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0));
280 template<
typename Dest>
inline void applyThisOnTheRight(Dest& dst)
const 283 applyThisOnTheRight(dst, workspace);
287 template<
typename Dest,
typename Workspace>
288 inline void applyThisOnTheRight(Dest& dst, Workspace& workspace)
const 290 workspace.resize(dst.rows());
291 for(Index k = 0; k < m_length; ++k)
293 Index actual_k = m_trans ? m_length-k-1 : k;
294 dst.rightCols(rows()-m_shift-actual_k)
295 .applyHouseholderOnTheRight(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
300 template<
typename Dest>
inline void applyThisOnTheLeft(Dest& dst)
const 303 applyThisOnTheLeft(dst, workspace);
307 template<
typename Dest,
typename Workspace>
308 inline void applyThisOnTheLeft(Dest& dst, Workspace& workspace)
const 310 workspace.resize(dst.cols());
311 for(Index k = 0; k < m_length; ++k)
313 Index actual_k = m_trans ? k : m_length-k-1;
314 dst.bottomRows(rows()-m_shift-actual_k)
315 .applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
326 template<
typename OtherDerived>
330 res(other.template cast<
typename internal::matrix_type_times_scalar_type<Scalar,OtherDerived>::ResultScalar>());
331 applyThisOnTheLeft(res);
369 Index
length()
const {
return m_length; }
370 Index
shift()
const {
return m_shift; }
373 template <
typename VectorsType2,
typename CoeffsType2,
int S
ide2>
friend class HouseholderSequence;
391 bool trans()
const {
return m_trans; }
393 typename VectorsType::Nested m_vectors;
394 typename CoeffsType::Nested m_coeffs;
408 template<
typename OtherDerived,
typename VectorsType,
typename CoeffsType,
int S
ide>
412 res(other.template cast<
typename internal::matrix_type_times_scalar_type<typename VectorsType::Scalar,OtherDerived>::ResultScalar>());
413 h.applyThisOnTheRight(res);
421 template<
typename VectorsType,
typename CoeffsType>
433 template<
typename VectorsType,
typename CoeffsType>
441 #endif // EIGEN_HOUSEHOLDER_SEQUENCE_H Apply transformation on the right.
Definition: Constants.h:279
Index cols() const
Number of columns of transformation viewed as a matrix.
Definition: HouseholderSequence.h:180
ConjugateReturnType inverse() const
Inverse of the Householder sequence (equals the adjoint).
Definition: HouseholderSequence.h:224
HouseholderSequence & setLength(Index length)
Sets the length of the Householder sequence.
Definition: HouseholderSequence.h:346
Expression of the transpose of a matrix.
Definition: Transpose.h:57
HouseholderSequence(const HouseholderSequence &other)
Copy constructor.
Definition: HouseholderSequence.h:161
bool trans() const
Returns the transpose flag.
Definition: HouseholderSequence.h:391
ConjugateReturnType adjoint() const
Adjoint (conjugate transpose) of the Householder sequence.
Definition: HouseholderSequence.h:218
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
HouseholderSequence(const VectorsType &v, const CoeffsType &h)
Constructor.
Definition: HouseholderSequence.h:154
const internal::permut_matrix_product_retval< PermutationDerived, Derived, OnTheRight > operator*(const MatrixBase< Derived > &matrix, const PermutationBase< PermutationDerived > &permutation)
Definition: PermutationMatrix.h:539
size< coerce_list< Ts... >> length
Synonym for typepack::size.
Definition: Size.h:59
HouseholderSequence< VectorsType, CoeffsType > householderSequence(const VectorsType &v, const CoeffsType &h)
\
Definition: HouseholderSequence.h:422
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition: EigenBase.h:26
Definition: HouseholderSequence.h:77
Definition: ForwardDeclarations.h:227
HouseholderSequence & setTrans(bool trans)
Sets the transpose flag.
Definition: HouseholderSequence.h:385
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:264
Index length() const
Returns the length of the Householder sequence.
Definition: HouseholderSequence.h:369
HouseholderSequence< VectorsType, CoeffsType, OnTheRight > rightHouseholderSequence(const VectorsType &v, const CoeffsType &h)
\
Definition: HouseholderSequence.h:434
HouseholderSequence & setShift(Index shift)
Sets the shift of the Householder sequence.
Definition: HouseholderSequence.h:363
Definition: BandTriangularSolver.h:13
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:327
const EssentialVectorType essentialVector(Index k) const
Essential part of a Householder vector.
Definition: HouseholderSequence.h:196
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Definition: HouseholderSequence.h:102
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Index shift() const
Returns the shift of the Householder sequence.
Definition: HouseholderSequence.h:370
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:203
Apply transformation on the left.
Definition: Constants.h:277
Align the matrix itself if it is vectorizable fixed-size.
Definition: Constants.h:268
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48
ConjugateReturnType conjugate() const
Complex conjugate of the Householder sequence.
Definition: HouseholderSequence.h:209
Index rows() const
Number of rows of transformation viewed as a matrix.
Definition: HouseholderSequence.h:174