From cfd7f9b84a27d9b88a525560a5d7ee847bc8c507 Mon Sep 17 00:00:00 2001 From: Desire NUENTSA Date: Tue, 16 Jul 2013 15:56:05 +0200 Subject: [PATCH] avoid unneeded const_cast --- Eigen/src/SparseLU/SparseLU.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Eigen/src/SparseLU/SparseLU.h b/Eigen/src/SparseLU/SparseLU.h index a024b2e16..503942b84 100644 --- a/Eigen/src/SparseLU/SparseLU.h +++ b/Eigen/src/SparseLU/SparseLU.h @@ -377,12 +377,13 @@ void SparseLU::analyzePattern(const MatrixType& mat) if (m_perm_c.size()) { m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers. FIXME : This vector is filled but not subsequently used. //Then, permute only the column pointers - Index * outerIndexPtr; - if (mat.isCompressed()) outerIndexPtr = const_cast(mat.outerIndexPtr()); + const Index * outerIndexPtr; + if (mat.isCompressed()) outerIndexPtr = mat.outerIndexPtr(); else { - outerIndexPtr = new Index[mat.cols()+1]; - for(Index i = 0; i <= mat.cols(); i++) outerIndexPtr[i] = m_mat.outerIndexPtr()[i]; + Index *outerIndexPtr_t = new Index[mat.cols()+1]; + for(Index i = 0; i <= mat.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i]; + outerIndexPtr = outerIndexPtr_t; } for (Index i = 0; i < mat.cols(); i++) { @@ -461,12 +462,13 @@ void SparseLU::factorize(const MatrixType& matrix) { m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers. //Then, permute only the column pointers - Index * outerIndexPtr; - if (matrix.isCompressed()) outerIndexPtr = const_cast(matrix.outerIndexPtr()); + const Index * outerIndexPtr; + if (matrix.isCompressed()) outerIndexPtr = matrix.outerIndexPtr(); else { - outerIndexPtr = new Index[matrix.cols()+1]; - for(Index i = 0; i <= matrix.cols(); i++) outerIndexPtr[i] = m_mat.outerIndexPtr()[i]; + Index* outerIndexPtr_t = new Index[matrix.cols()+1]; + for(Index i = 0; i <= matrix.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i]; + outerIndexPtr = outerIndexPtr_t; } for (Index i = 0; i < matrix.cols(); i++) {