Registered Member
|
it seems that Eigen::SparseMatrix<>::rowwise() and ::colwise() do not exist.
Is there an efficient way to do rowwise().sum() on a sparse matrix ? Currently I do a for()-loop with SparseMatrix<>::row(i).sum(), but on matrices with lots of zeros, that's probably not the most efficient way. I've tried looking at the Eigen source-code, but it's hard to estimate how much work it'd be to add a sparse-rowwise() member. |
Moderator
|
you can do:
sparse_mat * VectorXd::Ones(sparse_mat.cols()) the compiler might even be able to optimize out the products with 1. |
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]