minoki / haskell-floating-point

Haskell libraries for floating point numbers (fp-ieee and rounded-hw)
5 stars 2 forks source link

Avoid changing rounding modes by flipping the sign of the upper bound #7

Open sheaf opened 5 months ago

sheaf commented 5 months ago

If we internally represent the interval [a,b] as a pair (a, -b) in which the supremum has been negated, then all interval arithmetic computations can be done using only downwards rounding (avoiding the need to switch rounding modes).

(Perhaps you are already using this trick in this library, in which case I apologise.)

sheaf commented 5 months ago

The paper "Fast and Correct SIMD Algorithms for Interval Arithmetic" contains more details. I believe those algorithms are implemented in the GAOL C++ library.

sheaf commented 4 months ago

I think that if we really want to make this efficient, we would need to store intervals directly in an xmm register, e.g. using the DoubleX2# type. That's LLVM-only for now unfortunately, but I would be interested in seeing the potential performance benefits.