Suppose I have an array filled with doubles:
Eigen::Array<double,m,n> myarray;
Now I want to replace any elements of myarray
which are not finite with the number 0.0
How would I do this?
I was thinking of multiplying it by an array of values with zeros where I find infinity, like this:
myarray *= myarray.cwiseEqual(std::numeric_limits<double>::infinity()) == 0.0;
And doing this for every invalid type. But this is really messy. Is there a better way?