Registered Member
|
The 3.1 version sparse matrix tutorial gives an example of iterating ALL elements over a sparse matrix using outersize and innterIterator methods. However, I just want to iterate over (non zero) elements in a SPECIFIC row (col major) or column (row major). I cannot figure it out from the documentation.
Anyone here know what is the fastest and easiest way to do that? |
Moderator
|
This cannot be done efficiently. You should find a way to avoid having doing this. For instance, if you have a m x m column major matrix, and n nonzero per column, and want to loop through a given row, then this would be a log_2(n)*m operation!!!
|
Moderator
|
In other words there is no more efficient algorithm than doing:
for(int j=0; j<m; ++j) mat(i,j); |
Registered users: Baidu [Spider], Bing [Bot], Google [Bot]