Implement custom inplace triangular product to avoid a temporary

This commit is contained in:
Gael Guennebaud 2018-07-03 14:02:46 +02:00
parent 3ae2083e23
commit 6a241bd8ee

View File

@ -63,8 +63,15 @@ void make_block_householder_triangular_factor(TriangularFactorType& triFactor, c
triFactor.row(i).tail(rt).noalias() = -hCoeffs(i) * vectors.col(i).tail(rs).adjoint()
* vectors.bottomRightCorner(rs, rt).template triangularView<UnitLower>();
// FIXME add .noalias() once the triangular product can work inplace
triFactor.row(i).tail(rt) = triFactor.row(i).tail(rt) * triFactor.bottomRightCorner(rt,rt).template triangularView<Upper>();
// FIXME use the following line with .noalias() once the triangular product can work inplace
// triFactor.row(i).tail(rt) = triFactor.row(i).tail(rt) * triFactor.bottomRightCorner(rt,rt).template triangularView<Upper>();
for(Index j=nbVecs-1; j>i; --j)
{
typename TriangularFactorType::Scalar z = triFactor(i,j);
triFactor(i,j) = z * triFactor(j,j);
if(nbVecs-j-1>0)
triFactor.row(i).tail(nbVecs-j-1) += z * triFactor.row(j).tail(nbVecs-j-1);
}
}
triFactor(i,i) = hCoeffs(i);