package mopsa
Install
Dune Dependency
Authors
Maintainers
Sources
md5=fdee20e988343751de440b4f6b67c0f4
sha512=f5cbf1328785d3f5ce40155dada2d95e5de5cce4f084ea30cfb04d1ab10cc9403a26cfb3fa55d0f9da72244482130fdb89c286a9aed0d640bba46b7c00e09500
doc/itvUtils/ItvUtils/FloatItv/index.html
Module ItvUtils.FloatItv
Source
FloatItv - Floating-point interval arithmetics with rounding.
We rely on C code to provide functions with correct rounding (rounding direction and rounding precision).
Types
The type of non-empty intervals: a lower bound and an upper bound. The bounds can be -∞ and +∞. In particular, we can have -∞,-∞
and +∞,+∞
(useful to model sets of floating-point numbers). We must have lo ≤ up. The bounds shall not be NaN.
The type of possibly empty intervals.
Constructors
Constructs a non-empty interval. We must have lo ≤ up, or an exception is raised. NaN bounds are transformed into infinities.
Constructs a possibly empty interval (no rounding). NaN bounds are transformed into infinities.
Predicates
A total ordering of intervals (lexical ordering) returning -1, 0, or 1. Can be used as compare for sets, maps, etc. (The hypothesis that bounds cannot be NaN is important to make the order total.
Total ordering on possibly empty intervals.
Whether the interval contains an element of the specified sign.
Whether the interval is included in the range lo,up
.
C comparison tests. Returns true if the test may succeed, false if it cannot.
Printing
Operations without rounding
Remainder (fmod).
Join of possibly empty intervals.
Join of a list of (non-empty) intervals.
Intersection of non-emtpty intervals (possibly empty)
Intersection of possibly empty intervals.
Meet of a list of (non-empty) intervals.
Positive and negative part.
Intersects with
.
Fallback for backward unary operators
Fallback for backward binary operators
Backward negation.
Backward absolute value.
Rounding-dependent functions
Interval operations support six rounding modes. The first four correspond to rounding both bounds in the same direction: to nearest, upwards, downards, or to zero. To this, we add outer rounding (lower bound downwards and upper bound upwards) and inner rounding (lower bound upwards and upper bound downwards).
Rounding can be performed for single-precision or double-precision.
Outer interval arithmetic can model soundly real arithmetic. In this case, infinities model unbounded intervals.
Directed roundings and outer arithmetics can model soundly float arithmetic. In this case, infinite bounds signal the precence of infinite float values. Directed roundings can produce -∞,-∞
or +∞,+∞
(denoting a set of floats reduced to an infinite float).
Inner rounding can return empty intervals. Divisions and square roots can return empty intervals for any rounding mode.
We do not track NaN. NaN bounds, as in -∞,-∞
+ +∞,+∞
, are transformed into infinities.
Operations with rounding mode as argument
type prec = [
| `SINGLE
(*32-bit single precision
*)| `DOUBLE
(*64-bit double precision
*)| `REAL
(*real arithmetic (outward double rounding is used)
*)
]
Precision.
type round = [
| `NEAR
(*To nearest
*)| `UP
(*Upwards
*)| `DOWN
(*Downwards
*)| `ZERO
(*Towards 0
*)| `ANY
(*Any rounding mode
*)
]
Rounding direction. This is ignored for real arithmetic.
Division. Returns a list of intervals to remain precise.
Square root.
Backward addition.
Backward subtraction.
Backward multiplication.
Backward division.
Backward conversion from int.
Backward conversion to integer.