Fix sparseLU solver when destination has a non-unit stride.

(cherry picked from commit ab2b26fbc2)
This commit is contained in:
Antonio Sánchez
2022-11-29 19:37:03 +00:00
committed by Antonio Sanchez
parent 5547205092
commit 26adb0e5af
3 changed files with 14 additions and 10 deletions

View File

@@ -35,8 +35,8 @@ public:
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
};
SparseLUTransposeView() : m_sparseLU(NULL) {}
SparseLUTransposeView(const SparseLUTransposeView& view) {
SparseLUTransposeView() : APIBase(), m_sparseLU(NULL) {}
SparseLUTransposeView(const SparseLUTransposeView& view) : APIBase() {
this->m_sparseLU = view.m_sparseLU;
}
void setIsInitialized(const bool isInitialized) {this->m_isInitialized = isInitialized;}
@@ -833,7 +833,6 @@ struct SparseLUMatrixUReturnType : internal::no_assignment_operator
template<typename Dest> void solveInPlace(MatrixBase<Dest> &X) const
{
Index nrhs = X.cols();
Index n = X.rows();
// Backward solve with U
for (Index k = m_mapL.nsuper(); k >= 0; k--)
{
@@ -853,7 +852,7 @@ struct SparseLUMatrixUReturnType : internal::no_assignment_operator
{
// FIXME: the following lines should use Block expressions and not Map!
Map<const Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > A( &(m_mapL.valuePtr()[luptr]), nsupc, nsupc, OuterStride<>(lda) );
Map< Matrix<Scalar,Dynamic,Dest::ColsAtCompileTime, ColMajor>, 0, OuterStride<> > U (&(X.coeffRef(fsupc,0)), nsupc, nrhs, OuterStride<>(n) );
typename Dest::RowsBlockXpr U = X.derived().middleRows(fsupc, nsupc);
U = A.template triangularView<Upper>().solve(U);
}
@@ -876,7 +875,6 @@ struct SparseLUMatrixUReturnType : internal::no_assignment_operator
{
using numext::conj;
Index nrhs = X.cols();
Index n = X.rows();
// Forward solve with U
for (Index k = 0; k <= m_mapL.nsuper(); k++)
{
@@ -907,7 +905,7 @@ struct SparseLUMatrixUReturnType : internal::no_assignment_operator
else
{
Map<const Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > A( &(m_mapL.valuePtr()[luptr]), nsupc, nsupc, OuterStride<>(lda) );
Map< Matrix<Scalar,Dynamic,Dest::ColsAtCompileTime, ColMajor>, 0, OuterStride<> > U (&(X(fsupc,0)), nsupc, nrhs, OuterStride<>(n) );
typename Dest::RowsBlockXpr U = X.derived().middleRows(fsupc, nsupc);
if(Conjugate)
U = A.adjoint().template triangularView<Lower>().solve(U);
else