Update HouseholderSequence.h

This commit is contained in:
Charles Schlosser 2022-04-15 16:56:17 +00:00 committed by Rasmus Munk Larsen
parent fc1d888415
commit a4bb513b99
2 changed files with 24 additions and 11 deletions

View File

@ -87,7 +87,7 @@ void make_block_householder_triangular_factor(TriangularFactorType& triFactor, c
template<typename MatrixType,typename VectorsType,typename CoeffsType>
void apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vectors, const CoeffsType& hCoeffs, bool forward)
{
enum { TFactorSize = MatrixType::ColsAtCompileTime };
enum { TFactorSize = VectorsType::ColsAtCompileTime };
Index nbVecs = vectors.cols();
Matrix<typename MatrixType::Scalar, TFactorSize, TFactorSize, RowMajor> T(nbVecs,nbVecs);

View File

@ -391,15 +391,19 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
Side==OnTheRight ? m_vectors.cols()-start : bs);
std::conditional_t<Side==OnTheRight, Transpose<SubVectorsType>, SubVectorsType&> sub_vecs(sub_vecs1);
Index dstStart = dst.rows()-rows()+m_shift+k;
Index dstRows = rows()-m_shift-k;
Block<Dest,Dynamic,Dynamic> sub_dst(dst,
dstStart,
inputIsIdentity ? dstStart : 0,
dstRows,
inputIsIdentity ? dstRows : dst.cols());
if (inputIsIdentity)
{
Block<Dest, Dynamic, Dynamic> sub_dst = dst.bottomRightCorner(dstRows, dstRows);
apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_reverse);
}
else
{
Block<Dest, Dynamic, Dest::ColsAtCompileTime> sub_dst = dst.bottomRows(dstRows);
apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_reverse);
}
}
}
else
{
@ -407,9 +411,18 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
for(Index k = 0; k < m_length; ++k)
{
Index actual_k = m_reverse ? k : m_length-k-1;
Index dstStart = rows()-m_shift-actual_k;
dst.template bottomRightCorner<Dynamic, Dest::ColsAtCompileTime>(dstStart, inputIsIdentity ? dstStart : dst.cols())
.applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
Index dstRows = rows()-m_shift-actual_k;
if (inputIsIdentity)
{
Block<Dest, Dynamic, Dynamic> sub_dst = dst.bottomRightCorner(dstRows, dstRows);
sub_dst.applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
}
else
{
Block<Dest, Dynamic, Dest::ColsAtCompileTime> sub_dst = dst.bottomRows(dstRows);
sub_dst.applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
}
}
}
}