This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Eigen::SparseMatrix<>::rowwise() ?

Tags: None
(comma "," separated)
twithaar
Registered Member
Posts
23
Karma
0

Eigen::SparseMatrix<>::rowwise() ?

Mon Sep 22, 2014 8:02 pm
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.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
you can do:

sparse_mat * VectorXd::Ones(sparse_mat.cols())

the compiler might even be able to optimize out the products with 1.


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]