What is the armadillo/c++ equivalent for the following matlab code?
A(isnan(A))=b;
Use the .transform() member function to change only the NaN entries. This is also faster than using find_nonfinite() and it will leave any Inf values unchanged.
A.transform( [](double val) { return (std::isnan(val) ? double(b) : val); } );
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