morphologica icon indicating copy to clipboard operation
morphologica copied to clipboard

Ensure that sum() mean() and similar statistics in vvec ignore NaNs in the array.

Open sebjameswml opened this issue 1 year ago • 3 comments

Currently, the NaNs are acted on, which is probably not what one wants in a computation.

sebjameswml avatar May 25 '23 13:05 sebjameswml

The problem with doing this is that you end up with lots of conditionals in your loops. For example, in a sum() you have to test if each element isnan() which will slow things down. Alternative is to first scan through to see if there are any nans, then loop to accumulate with isnan testing only if necessary.

sebjameswml avatar May 25 '23 13:05 sebjameswml

Best approach to have methods that explicitly deal with nans, and let client code decide which to use?

sebjameswml avatar May 25 '23 13:05 sebjameswml

So is best approach to do what I already did with minmax?:

https://github.com/ABRG-Models/morphologica/blob/main/morph/vvec.h#L609

sebjameswml avatar May 25 '23 14:05 sebjameswml