What is the armadillo/c++ equivalent for the following matlab code?
A(isnan(A))=b;
From the docs, you can use has_nan()
to see if any of the values is NaN. However, there doesn't seem to be a function to return the indexes of which of them are NaN, so it looks like you may need to loop, and check individual elements one by one.
However, if you are not worried about having infinites, then you could use find_nonfinite( X )
that will give you the index of the Inf and NaN values.