11#ifndef EIGEN_BLOCK_HOUSEHOLDER_H
12#define EIGEN_BLOCK_HOUSEHOLDER_H
17#include "./InternalHeaderCheck.h"
54template <
typename TriangularFactorType,
typename VectorsType,
typename CoeffsType>
55void make_block_householder_triangular_factor(TriangularFactorType& triFactor,
const VectorsType& vectors,
56 const CoeffsType& hCoeffs) {
57 const Index nbVecs = vectors.cols();
58 eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows() >= nbVecs);
60 for (Index i = nbVecs - 1; i >= 0; --i) {
61 Index rs = vectors.rows() - i - 1;
62 Index rt = nbVecs - i - 1;
65 triFactor.row(i).tail(rt).noalias() = -hCoeffs(i) * vectors.col(i).tail(rs).adjoint() *
66 vectors.bottomRightCorner(rs, rt).template triangularView<UnitLower>();
71 for (Index j = nbVecs - 1; j > i; --j) {
72 typename TriangularFactorType::Scalar z = triFactor(i, j);
73 triFactor(i, j) = z * triFactor(j, j);
74 if (nbVecs - j - 1 > 0) triFactor.row(i).tail(nbVecs - j - 1) += z * triFactor.row(j).tail(nbVecs - j - 1);
77 triFactor(i, i) = hCoeffs(i);
85template <
typename MatrixType,
typename VectorsType,
typename CoeffsType>
86void apply_block_householder_on_the_left(MatrixType& mat,
const VectorsType& vectors,
const CoeffsType& hCoeffs,
88 enum { TFactorSize = VectorsType::ColsAtCompileTime };
89 Index nbVecs = vectors.cols();
90 Matrix<typename MatrixType::Scalar, TFactorSize, TFactorSize, RowMajor> T(nbVecs, nbVecs);
93 make_block_householder_triangular_factor(T, vectors, hCoeffs);
95 make_block_householder_triangular_factor(T, vectors, hCoeffs.conjugate());
96 const TriangularView<const VectorsType, UnitLower> V(vectors);
99 Matrix<
typename MatrixType::Scalar, VectorsType::ColsAtCompileTime, MatrixType::ColsAtCompileTime,
100 (VectorsType::MaxColsAtCompileTime == 1 && MatrixType::MaxColsAtCompileTime != 1) ?
RowMajor :
ColMajor,
101 VectorsType::MaxColsAtCompileTime, MatrixType::MaxColsAtCompileTime>
102 tmp = V.adjoint() * mat;
105 tmp = T.template triangularView<Upper>() * tmp;
107 tmp = T.template triangularView<Upper>().adjoint() * tmp;
108 mat.noalias() -= V * tmp;
@ ColMajor
Definition Constants.h:318
@ RowMajor
Definition Constants.h:320
Namespace containing all symbols from the Eigen library.
Definition Core:137