49 const Eigen::SparseMatrix<AType> & A,
52 Eigen::PlainObjectBase<DerivedB> & B)
54 typedef typename Eigen::SparseMatrix<AType>::StorageIndex Index;
55 assert((dim == 1 || dim == 2) &&
"dim must be 2 or 1");
60 B = DerivedB::Zero(dim==1?n:m);
61 const auto func_wrap = [&func,&B,&dim](
const Index i,
const Index j,
const AType v)
65 B(j) = i == 0? v : func(B(j),v);
68 B(i) = j == 0? v : func(B(i),v);
void for_each(const Eigen::SparseMatrix< AType > &A, const Func &func)
FOR_EACH Call a given function for each non-zero (i.e., explicit value might actually be ==0) in a Sp...
Definition for_each.h:31
void redux(const Eigen::SparseMatrix< AType > &A, const int dim, const Func &func, Eigen::PlainObjectBase< DerivedB > &B)
Perform reductions on the rows or columns of a SparseMatrix.
Definition redux.h:48