* Make HouseholderSequence::evalTo works in place

* Clean a bit the Triadiagonalization making sure it the inplace
  function really works inplace ;), and that only the lower
   triangular part of the matrix is referenced.
* Remove the Tridiagonalization member object of SelfAdjointEigenSolver
  exploiting the in place capability of HouseholdeSequence.
* Update unit test to check SelfAdjointEigenSolver only consider
  the lower triangular part.
This commit is contained in:
Gael Guennebaud
2010-06-10 16:39:46 +02:00
parent d2d7465bcf
commit 469382407c
4 changed files with 208 additions and 126 deletions

View File

@@ -160,18 +160,45 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
template<typename DestType> void evalTo(DestType& dst) const
{
Index vecs = m_actualVectors;
dst.setIdentity(rows(), rows());
// FIXME find a way to pass this temporary if the user want to
Matrix<Scalar, DestType::RowsAtCompileTime, 1,
AutoAlign|ColMajor, DestType::MaxRowsAtCompileTime, 1> temp(rows());
for(Index k = vecs-1; k >= 0; --k)
AutoAlign|ColMajor, DestType::MaxRowsAtCompileTime, 1> temp(rows());
if( ei_is_same_type<typename ei_cleantype<VectorsType>::type,DestType>::ret
&& ei_extract_data(dst) == ei_extract_data(m_vectors))
{
Index cornerSize = rows() - k - m_shift;
if(m_trans)
dst.bottomRightCorner(cornerSize, cornerSize)
.applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), &temp.coeffRef(0));
else
dst.bottomRightCorner(cornerSize, cornerSize)
.applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), &temp.coeffRef(0));
// in-place
dst.diagonal().setOnes();
dst.template triangularView<StrictlyUpper>().setZero();
for(Index k = vecs-1; k >= 0; --k)
{
Index cornerSize = rows() - k - m_shift;
if(m_trans)
dst.bottomRightCorner(cornerSize, cornerSize)
.applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), &temp.coeffRef(0));
else
dst.bottomRightCorner(cornerSize, cornerSize)
.applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), &temp.coeffRef(0));
// clear the off diagonal vector
dst.col(k).tail(rows()-k-1).setZero();
}
// clear the remaining columns if needed
for(Index k = 0; k<cols()-vecs ; ++k)
dst.col(k).tail(rows()-k-1).setZero();
}
else
{
dst.setIdentity(rows(), rows());
for(Index k = vecs-1; k >= 0; --k)
{
Index cornerSize = rows() - k - m_shift;
if(m_trans)
dst.bottomRightCorner(cornerSize, cornerSize)
.applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), &temp.coeffRef(0));
else
dst.bottomRightCorner(cornerSize, cornerSize)
.applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), &temp.coeffRef(0));
}
}
}