Registered Member
|
Hello all
Do you know if it exists a function to replace values inside a Matrix?. For example a naive implementation for a MatrixXi would be:
Best regards Koldo |
Moderator
|
you can use std::replace:
MatrixXi A; std::replace(A.data(), A.data()+A.size(), key, newval); or (more general but perhaps less efficient in this case): A = (A.array()==key).select(newval, A); |
Registered Member
|
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]