As said I want to replace all < 0 elements in a eigen3 matrix in C++ with zero in most efficient manner.
I check that there are negative elements using:
(result.array() < 0).any()
A nicer and more efficient way than your proposed method would be to use the select
method.
result = (result.array() < 0).select(0, result);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With