Update sparse reduxions and sparse-vectors to evaluators.

This commit is contained in:
Gael Guennebaud
2014-06-25 17:24:43 +02:00
parent b868bfb84a
commit a7bd4c455a
4 changed files with 43 additions and 2 deletions

View File

@@ -18,8 +18,14 @@ SparseMatrixBase<Derived>::sum() const
{
eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
Scalar res(0);
#ifndef EIGEN_TEST_EVALUATORS
for (Index j=0; j<outerSize(); ++j)
for (typename Derived::InnerIterator iter(derived(),j); iter; ++iter)
#else
typename internal::evaluator<Derived>::type thisEval(derived());
for (Index j=0; j<outerSize(); ++j)
for (typename internal::evaluator<Derived>::InnerIterator iter(thisEval,j); iter; ++iter)
#endif
res += iter.value();
return res;
}