diff options
author | Gael Guennebaud <g.gael@free.fr> | 2013-11-15 11:19:19 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2013-11-15 11:19:19 +0100 |
commit | 46dd1bb1be49cad4e7eecc12813bd0ee5772cefe (patch) | |
tree | c84155c50ed334b7e3cff66a3a48d2645920a06c /Eigen/src | |
parent | 6b471f205ef00572abebaf403d55433f2ce40eee (diff) |
Workaround fixing aliasing issue in x = SparseLU::solve(x)
Diffstat (limited to 'Eigen/src')
-rw-r--r-- | Eigen/src/Core/PermutationMatrix.h | 3 | ||||
-rw-r--r-- | Eigen/src/SparseLU/SparseLU.h | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h index 4fc5dd318..1297b8413 100644 --- a/Eigen/src/Core/PermutationMatrix.h +++ b/Eigen/src/Core/PermutationMatrix.h @@ -553,7 +553,8 @@ struct permut_matrix_product_retval template<typename Dest> inline void evalTo(Dest& dst) const { const Index n = Side==OnTheLeft ? rows() : cols(); - + // FIXME we need an is_same for expression that is not sensitive to constness. For instance + // is_same_xpr<Block<const Matrix>, Block<Matrix> >::value should be true. if(is_same<MatrixTypeNestedCleaned,Dest>::value && extract_data(dst) == extract_data(m_matrix)) { // apply the permutation inplace diff --git a/Eigen/src/SparseLU/SparseLU.h b/Eigen/src/SparseLU/SparseLU.h index 71fe844ac..7a9aeec2d 100644 --- a/Eigen/src/SparseLU/SparseLU.h +++ b/Eigen/src/SparseLU/SparseLU.h @@ -229,8 +229,10 @@ class SparseLU : public internal::SparseLUImpl<typename _MatrixType::Scalar, typ // Permute the right hand side to form X = Pr*B // on return, X is overwritten by the computed solution X.resize(B.rows(),B.cols()); + + // this ugly const_cast_derived() helps to detect aliasing when applying the permutations for(Index j = 0; j < B.cols(); ++j) - X.col(j) = rowsPermutation() * B.col(j); + X.col(j) = rowsPermutation() * B.const_cast_derived().col(j); //Forward substitution with L this->matrixL().solveInPlace(X); |