11 #ifndef EIGEN_HOUSEHOLDER_SEQUENCE_H 12 #define EIGEN_HOUSEHOLDER_SEQUENCE_H 59 template<
typename VectorsType,
typename CoeffsType,
int S
ide>
68 ColsAtCompileTime = RowsAtCompileTime,
71 MaxColsAtCompileTime = MaxRowsAtCompileTime,
78 template<
typename VectorsType,
typename CoeffsType,
int S
ide>
85 template<
typename VectorsType,
typename CoeffsType,
int S
ide>
97 template<
typename VectorsType,
typename CoeffsType>
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,
145 typename internal::conditional<NumTraits<Scalar>::IsComplex,
146 typename internal::remove_all<typename CoeffsType::ConjugateReturnType>::type,
152 typename internal::conditional<NumTraits<Scalar>::IsComplex,
153 typename internal::remove_all<typename VectorsType::ConjugateReturnType>::type,
184 : m_vectors(v), m_coeffs(h), m_reverse(false), m_length(v.diagonalSize()),
192 : m_vectors(other.m_vectors),
193 m_coeffs(other.m_coeffs),
194 m_reverse(other.m_reverse),
195 m_length(other.m_length),
196 m_shift(other.m_shift)
239 .setReverseFlag(!m_reverse)
248 .setReverseFlag(m_reverse)
262 return ReturnType(m_vectors.template conjugateIf<Cond>(), m_coeffs.template conjugateIf<Cond>());
269 .setReverseFlag(!m_reverse)
278 template<
typename DestType>
284 evalTo(dst, workspace);
288 template<
typename Dest,
typename Workspace>
290 void evalTo(Dest& dst, Workspace& workspace)
const 292 workspace.resize(
rows());
293 Index vecs = m_length;
297 dst.diagonal().setOnes();
298 dst.template triangularView<StrictlyUpper>().
setZero();
299 for(
Index k = vecs-1; k >= 0; --k)
303 dst.bottomRightCorner(cornerSize, cornerSize)
304 .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data());
306 dst.bottomRightCorner(cornerSize, cornerSize)
307 .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), workspace.data());
310 dst.col(k).tail(
rows()-k-1).setZero();
314 dst.col(k).tail(
rows()-k-1).setZero();
316 else if(m_length>BlockSize)
320 applyThisOnTheLeft(dst,workspace,
true);
322 applyThisOnTheLeft(dst,workspace,
true);
327 for(
Index k = vecs-1; k >= 0; --k)
331 dst.bottomRightCorner(cornerSize, cornerSize)
332 .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data());
334 dst.bottomRightCorner(cornerSize, cornerSize)
335 .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), workspace.data());
344 applyThisOnTheRight(dst, workspace);
348 template<
typename Dest,
typename Workspace>
351 workspace.resize(dst.rows());
352 for(
Index k = 0; k < m_length; ++k)
354 Index actual_k = m_reverse ? m_length-k-1 : k;
355 dst.rightCols(
rows()-m_shift-actual_k)
356 .applyHouseholderOnTheRight(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
361 template<
typename Dest>
inline void applyThisOnTheLeft(Dest& dst,
bool inputIsIdentity =
false)
const 364 applyThisOnTheLeft(dst, workspace, inputIsIdentity);
368 template<
typename Dest,
typename Workspace>
371 if(inputIsIdentity && m_reverse)
372 inputIsIdentity =
false;
374 if(m_length>=BlockSize && dst.cols()>1)
377 Index blockSize = m_length<
Index(2*BlockSize) ? (m_length+1)/2 :
Index(BlockSize);
378 for(
Index i = 0;
i < m_length;
i+=blockSize)
383 Index start = k + m_shift;
386 SubVectorsType sub_vecs1(m_vectors.const_cast_derived(), Side==
OnTheRight ? k : start,
388 Side==
OnTheRight ? bs : m_vectors.rows()-start,
389 Side==
OnTheRight ? m_vectors.cols()-start : bs);
392 Index dstStart = dst.rows()-
rows()+m_shift+k;
396 inputIsIdentity ? dstStart : 0,
398 inputIsIdentity ? dstRows : dst.cols());
404 workspace.resize(dst.cols());
405 for(
Index k = 0; k < m_length; ++k)
407 Index actual_k = m_reverse ? k : m_length-k-1;
408 Index dstStart =
rows()-m_shift-actual_k;
409 dst.bottomRightCorner(dstStart, inputIsIdentity ? dstStart : dst.cols())
410 .applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
422 template<
typename OtherDerived>
501 enum { BlockSize = 48 };
512 template<
typename OtherDerived,
typename VectorsType,
typename CoeffsType,
int S
ide>
525 template<
typename VectorsType,
typename CoeffsType>
537 template<
typename VectorsType,
typename CoeffsType>
545 #endif // EIGEN_HOUSEHOLDER_SEQUENCE_H HouseholderSequence< VectorsType, CoeffsType, OnTheRight > HouseholderSequenceType
HouseholderSequenceShape Shape
void adjoint(const MatrixType &m)
void apply_block_householder_on_the_left(MatrixType &mat, const VectorsType &vectors, const CoeffsType &hCoeffs, bool forward)
HouseholderSequence< typename internal::conditional< NumTraits< Scalar >::IsComplex, typename internal::remove_all< typename VectorsType::ConjugateReturnType >::type, VectorsType >::type, typename internal::conditional< NumTraits< Scalar >::IsComplex, typename internal::remove_all< typename CoeffsType::ConjugateReturnType >::type, CoeffsType >::type, Side > ConjugateReturnType
EIGEN_DEVICE_FUNC void evalTo(Dest &dst, Workspace &workspace) const
Matrix< ResultScalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime, 0, MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime > Type
ScalarBinaryOpTraits< OtherScalarType, typename MatrixType::Scalar >::ReturnType ResultScalar
internal::hseq_side_dependent_impl< VectorsType, CoeffsType, Side >::EssentialVectorType EssentialVectorType
void applyThisOnTheLeft(Dest &dst, Workspace &workspace, bool inputIsIdentity=false) const
Expression of the transpose of a matrix.
Namespace containing all symbols from the Eigen library.
VectorsType::Scalar Scalar
EIGEN_DEVICE_FUNC HouseholderSequence(const VectorsType &v, const CoeffsType &h)
Constructor.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
EIGEN_DEVICE_FUNC Index length() const
Returns the length of the Householder sequence.
Eigen::Index Index
The interface type of indices.
HouseholderSequence< VectorsType, CoeffsType > householderSequence(const VectorsType &v, const CoeffsType &h)
Convenience function for constructing a Householder sequence.
VectorsType::StorageIndex StorageIndex
Block< const VectorsType, Dynamic, 1 > EssentialVectorType
EIGEN_DEVICE_FUNC Index shift() const
Returns the shift of the Householder sequence.
Sequence of Householder reflections acting on subspaces with decreasing size.
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Transpose< Block< const VectorsType, 1, Dynamic > > EssentialVectorType
AdjointReturnType inverse() const
Inverse of the Householder sequence (equals the adjoint).
EIGEN_DEVICE_FUNC HouseholderSequence & setShift(Index shift)
Sets the shift of the Householder sequence.
void applyThisOnTheLeft(Dest &dst, bool inputIsIdentity=false) const
VectorsType::Nested m_vectors
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Array< int, Dynamic, 1 > v
HouseholderSequence< typename internal::conditional< NumTraits< Scalar >::IsComplex, typename internal::remove_all< typename VectorsType::ConjugateReturnType >::type, VectorsType >::type, CoeffsType, Side > TransposeReturnType
EIGEN_DEVICE_FUNC NewType cast(const OldType &x)
EIGEN_DEVICE_FUNC HouseholderSequence & setLength(Index length)
Sets the length of the Householder sequence.
HouseholderSequence & setReverseFlag(bool reverse)
AdjointReturnType adjoint() const
Adjoint (conjugate transpose) of the Householder sequence.
EIGEN_DEVICE_FUNC bool is_same_dense(const T1 &mat1, const T2 &mat2, typename enable_if< possibly_same_dense< T1, T2 >::value >::type *=0)
HouseholderSequence< typename internal::add_const< VectorsType >::type, typename internal::add_const< CoeffsType >::type, Side > ConstHouseholderSequence
CoeffsType::Nested m_coeffs
HouseholderSequence< VectorsType, CoeffsType, OnTheRight > rightHouseholderSequence(const VectorsType &v, const CoeffsType &h)
Convenience function for constructing a Householder sequence.
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorUInt128< uint64_t, uint64_t > operator*(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
VectorsType::StorageKind StorageKind
EIGEN_DEVICE_FUNC const EssentialVectorType essentialVector(Index k) const
Essential part of a Householder vector.
static EIGEN_DEVICE_FUNC const EssentialVectorType essentialVector(const HouseholderSequenceType &h, Index k)
#define EIGEN_DEVICE_FUNC
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.
Expression of a fixed-size or dynamic-size block.
void applyThisOnTheRight(Dest &dst, Workspace &workspace) const
void reverse(const MatrixType &m)
EIGEN_DEVICE_FUNC void evalTo(DestType &dst) const
static EIGEN_DEPRECATED const end_t end
EIGEN_DEVICE_FUNC internal::conditional< Cond, ConjugateReturnType, ConstHouseholderSequence >::type conjugateIf() const
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
internal::conditional< NumTraits< Scalar >::IsComplex, const CwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, const Derived >, const Derived &>::type ConjugateReturnType
Generic expression where a coefficient-wise unary operator is applied to an expression.
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Number of columns of transformation viewed as a matrix.
The matrix class, also used for vectors and row-vectors.
void applyThisOnTheRight(Dest &dst) const
HouseholderSequence< VectorsType, CoeffsType, OnTheLeft > HouseholderSequenceType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
TransposeReturnType transpose() const
Transpose of the Householder sequence.
Base class for all dense matrices, vectors, and expressions.
HouseholderSequence< VectorsType, typename internal::conditional< NumTraits< Scalar >::IsComplex, typename internal::remove_all< typename CoeffsType::ConjugateReturnType >::type, CoeffsType >::type, Side > AdjointReturnType
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Number of rows of transformation viewed as a matrix.
static const EssentialVectorType essentialVector(const HouseholderSequenceType &h, Index k)
EIGEN_DEVICE_FUNC HouseholderSequence(const HouseholderSequence &other)
Copy constructor.
ConjugateReturnType conjugate() const
Complex conjugate of the Householder sequence.
internal::traits< HouseholderSequence >::Scalar Scalar