Registered Member
|
Dear All,
I'm new to Eigen and I'm not sure whether my question has been mentioned yet. Here's my question: I have a dense matrix with positive and negative numbers. I want to set all the negative numbers to zero and create a sparse matrix based on it. I want to ask what's the best way or the most efficient way to do this? Shall I make two for loops? Thanks! I really appreciate your help. Cheng |
Moderator
|
sparsemat = (mat.array()>0).select(mat,0).sparseView();
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]