diff --git a/Eigen/src/Sparse/SparseBlock.h b/Eigen/src/Sparse/SparseBlock.h index 989ab70c5..b7bfa57e4 100644 --- a/Eigen/src/Sparse/SparseBlock.h +++ b/Eigen/src/Sparse/SparseBlock.h @@ -243,7 +243,7 @@ class SparseInnerVectorSet, Size> { typedef typename internal::remove_all::type _NestedMatrixType; _NestedMatrixType& matrix = const_cast<_NestedMatrixType&>(m_matrix);; - // This assignement is slow if this vector set not empty + // This assignement is slow if this vector set is not empty // and/or it is not at the end of the nonzeros of the underlying matrix. // 1 - eval to a temporary to avoid transposition and/or aliasing issues @@ -252,7 +252,7 @@ class SparseInnerVectorSet, Size> // 2 - let's check whether there is enough allocated memory Index nnz = tmp.nonZeros(); Index nnz_previous = nonZeros(); - Index free_size = matrix.data().allocatedSize() - nnz_previous; + Index free_size = matrix.data().allocatedSize() + nnz_previous; std::size_t nnz_head = m_outerStart==0 ? 0 : matrix._outerIndexPtr()[m_outerStart]; std::size_t tail = m_matrix._outerIndexPtr()[m_outerStart+m_outerSize.value()]; std::size_t nnz_tail = matrix.nonZeros() - tail; @@ -298,7 +298,7 @@ class SparseInnerVectorSet, Size> // update outer index pointers Index p = nnz_head; - for(Index k=1; k SparseMatrixBase::innerVector(Ind //---------- -/** \returns the i-th row of the matrix \c *this. For row-major matrix only. */ +/** \deprecated see middleRows */ template SparseInnerVectorSet SparseMatrixBase::subrows(Index start, Index size) { @@ -422,10 +422,44 @@ SparseInnerVectorSet SparseMatrixBase::subrows(Index s return innerVectors(start, size); } +/** \deprecated see middleRows */ +template +const SparseInnerVectorSet SparseMatrixBase::subrows(Index start, Index size) const +{ + EIGEN_STATIC_ASSERT(IsRowMajor,THIS_METHOD_IS_ONLY_FOR_ROW_MAJOR_MATRICES); + return innerVectors(start, size); +} + +/** \deprecated see middleCols */ +template +SparseInnerVectorSet SparseMatrixBase::subcols(Index start, Index size) +{ + EIGEN_STATIC_ASSERT(!IsRowMajor,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES); + return innerVectors(start, size); +} + +/** \deprecated see middleCols */ +template +const SparseInnerVectorSet SparseMatrixBase::subcols(Index start, Index size) const +{ + EIGEN_STATIC_ASSERT(!IsRowMajor,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES); + return innerVectors(start, size); +} + + + +/** \returns the i-th row of the matrix \c *this. For row-major matrix only. */ +template +SparseInnerVectorSet SparseMatrixBase::middleRows(Index start, Index size) +{ + EIGEN_STATIC_ASSERT(IsRowMajor,THIS_METHOD_IS_ONLY_FOR_ROW_MAJOR_MATRICES); + return innerVectors(start, size); +} + /** \returns the i-th row of the matrix \c *this. For row-major matrix only. * (read-only version) */ template -const SparseInnerVectorSet SparseMatrixBase::subrows(Index start, Index size) const +const SparseInnerVectorSet SparseMatrixBase::middleRows(Index start, Index size) const { EIGEN_STATIC_ASSERT(IsRowMajor,THIS_METHOD_IS_ONLY_FOR_ROW_MAJOR_MATRICES); return innerVectors(start, size); @@ -433,7 +467,7 @@ const SparseInnerVectorSet SparseMatrixBase::subrows(I /** \returns the i-th column of the matrix \c *this. For column-major matrix only. */ template -SparseInnerVectorSet SparseMatrixBase::subcols(Index start, Index size) +SparseInnerVectorSet SparseMatrixBase::middleCols(Index start, Index size) { EIGEN_STATIC_ASSERT(!IsRowMajor,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES); return innerVectors(start, size); @@ -442,12 +476,14 @@ SparseInnerVectorSet SparseMatrixBase::subcols(Index s /** \returns the i-th column of the matrix \c *this. For column-major matrix only. * (read-only version) */ template -const SparseInnerVectorSet SparseMatrixBase::subcols(Index start, Index size) const +const SparseInnerVectorSet SparseMatrixBase::middleCols(Index start, Index size) const { EIGEN_STATIC_ASSERT(!IsRowMajor,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES); return innerVectors(start, size); } + + /** \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this * is col-major (resp. row-major). */ diff --git a/Eigen/src/Sparse/SparseMatrixBase.h b/Eigen/src/Sparse/SparseMatrixBase.h index 74506ad71..944dbb8e3 100644 --- a/Eigen/src/Sparse/SparseMatrixBase.h +++ b/Eigen/src/Sparse/SparseMatrixBase.h @@ -442,6 +442,12 @@ template class SparseMatrixBase : public EigenBase const SparseInnerVectorSet subrows(Index start, Index size) const; SparseInnerVectorSet subcols(Index start, Index size); const SparseInnerVectorSet subcols(Index start, Index size) const; + + + SparseInnerVectorSet middleRows(Index start, Index size); + const SparseInnerVectorSet middleRows(Index start, Index size) const; + SparseInnerVectorSet middleCols(Index start, Index size); + const SparseInnerVectorSet middleCols(Index start, Index size) const; SparseInnerVectorSet innerVectors(Index outerStart, Index outerSize); const SparseInnerVectorSet innerVectors(Index outerStart, Index outerSize) const;