From 938b68f013bcb389bac78605ef42e55fdae6d7e0 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Wed, 20 Oct 2004 12:27:08 +0000 Subject: [PATCH] FIX sparse non_zeros is capacity, consistent with coordinate and compressed FIX sparse_matrix removed minumum in restrict_nz --- include/boost/numeric/ublas/matrix_sparse.hpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/boost/numeric/ublas/matrix_sparse.hpp b/include/boost/numeric/ublas/matrix_sparse.hpp index d8222fdb..a5522469 100644 --- a/include/boost/numeric/ublas/matrix_sparse.hpp +++ b/include/boost/numeric/ublas/matrix_sparse.hpp @@ -296,7 +296,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE size_type non_zeros () const { - return data_.size (); + return detail::map_capacity (data ()); } BOOST_UBLAS_INLINE const array_type &data () const { @@ -311,9 +311,7 @@ namespace boost { namespace numeric { namespace ublas { private: BOOST_UBLAS_INLINE size_type restrict_nz (size_type non_zeros) const { - non_zeros = (std::max) (non_zeros, (std::min) (size1_, size2_)); - // Guarding against overflow. - // Thanks to Alexei Novakov for the hint. + // Guarding against overflow - Thanks to Alexei Novakov for the hint. // non_zeros_ = (std::min) (non_zeros, size1_ * size2_); if (size1_ > 0 && non_zeros / size1_ >= size2_) non_zeros = size1_ * size2_; @@ -1354,7 +1352,7 @@ namespace boost { namespace numeric { namespace ublas { size_type non_zeros () const { size_type non_zeros = 0; for (vector_const_iterator_type itv = data_ ().begin (); itv != data_ ().end (); ++ itv) - non_zeros += (*itv).size (); + non_zeros += detail::map_capacity (*itv); return non_zeros; } BOOST_UBLAS_INLINE