aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Eigen/src/SparseCore/SparseBlock.h2
-rw-r--r--test/sparse_basic.cpp20
2 files changed, 21 insertions, 1 deletions
diff --git a/Eigen/src/SparseCore/SparseBlock.h b/Eigen/src/SparseCore/SparseBlock.h
index a6cde9df3..2b092dc21 100644
--- a/Eigen/src/SparseCore/SparseBlock.h
+++ b/Eigen/src/SparseCore/SparseBlock.h
@@ -243,7 +243,7 @@ class SparseInnerVectorSet<SparseMatrix<_Scalar, _Options, _Index>, Size>
else if(m_outerSize.value()==0)
return 0;
else
- return Map<const Matrix<Index,Size,1> >(m_matrix.innerNonZeroPtr(), m_outerSize.value()).sum();
+ return Map<const Matrix<Index,Size,1> >(m_matrix.innerNonZeroPtr()+m_outerStart, m_outerSize.value()).sum();
}
const Scalar& lastCoeff() const
diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp
index 276db65aa..f36fcb36d 100644
--- a/test/sparse_basic.cpp
+++ b/test/sparse_basic.cpp
@@ -237,6 +237,26 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
VERIFY_IS_APPROX(m2.innerVector(j0)+m2.innerVector(j1), refMat2.row(j0)+refMat2.row(j1));
else
VERIFY_IS_APPROX(m2.innerVector(j0)+m2.innerVector(j1), refMat2.col(j0)+refMat2.col(j1));
+
+ SparseMatrixType m3(rows,rows);
+ m3.reserve(VectorXi::Constant(rows,rows/2));
+ for(int j=0; j<rows; ++j)
+ for(int k=0; k<j; ++k)
+ m3.insertByOuterInner(j,k) = k+1;
+ for(int j=0; j<rows; ++j)
+ {
+ VERIFY(j==m3.innerVector(j).nonZeros());
+ if(j>0)
+ VERIFY(j==m3.innerVector(j).lastCoeff());
+ }
+ m3.makeCompressed();
+ for(int j=0; j<rows; ++j)
+ {
+ VERIFY(j==m3.innerVector(j).nonZeros());
+ if(j>0)
+ VERIFY(j==m3.innerVector(j).lastCoeff());
+ }
+
//m2.innerVector(j0) = 2*m2.innerVector(j1);
//refMat2.col(j0) = 2*refMat2.col(j1);
//VERIFY_IS_APPROX(m2, refMat2);