SciProgCentre/kmath

A general decision on treatments of NaNs

Closed this issue · 8 comments

Should complex number and quaternion structures be NaN-hostile?

I think that NaNs should be completely forbidden in all sensitive places. In my experience, it causes a lot of undebuggable problems. Missing values could be treated as nullable. Therefore encountering a NaN in place, which is sensitive to it should lead to an error.

If complex type depend on Double, you can't avoid NaN value

We can avoid treating them and fail-fast if we encounter them.

#156 depends on it, since I can't decide if quaternion should handle NaN components in all the operations or simply be NaN-hostile.

I think that we can safely assume zero NaN tolerance strategy for now. We can add them later if we want.

By the way. Why can't we make RealField and FloatField hostile to NaN. It can add some performance losses, but it will be consistent with making Complex (and Quaternion in future) NaN-hostile.

Performance losses should be avoided in performance-optimized algebras at all costs.