NA values ββin Haskell
I am doing some numerical calculations in Haskell and I would like to have values NA
inside vectors and matrices, for example in R or Matlab. The most natural way I thought was Maybe
to handle these values ββand use Nothing
both NA
.
It works mostly with hoist operations, but I wanted to use HMatrix to get faster code. To use it correctly, I would need to make so many instances Maybe a
for the different classes defined in the code (and I'm not even sure if all of them are possible).
Is there some library that does this kind of work, or do I just need to define all the operations?
source to share
This is probably not what you want, but look NaN
("not a number"):
nan = 0/0
main = do
print $ nan -- NaN
print $ nan * nan -- NaN
print $ nan + 0 -- NaN
print $ nan / 2 -- NaN
print $ isNaN 0 -- false
print $ isNaN nan -- true
print $ nan == nan -- false
Notice the last line: NaN
not equal to yourself.
source to share