47 const Eigen::SparseMatrix<AType> & A,
50 Eigen::PlainObjectBase<DerivedB> & B)
52 typedef typename Eigen::SparseMatrix<AType>::StorageIndex Index;
53 assert((dim == 1 || dim == 2) &&
"dim must be 2 or 1");
58 B = DerivedB::Zero(dim==1?n:m);
59 const auto func_wrap = [&func,&B,&dim](
const Index i,
const Index j,
const AType v)
63 B(j) = i == 0? v : func(B(j),v);
66 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:46