Types
Sourcetype t = {mutable lo : float;mutable up : float;
} 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
Sourceval of_float : float -> float -> t 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.
Sourceval hull : float -> float -> t Constructs the smallest interval containing a and b.
Predicates
Set ordering. = also works to compare for equality.
Whether the intervals have an non-empty intersection.
Sourceval contains : float -> t -> bool Whether the interval contains a certain value.
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.
Sourceval is_positive_strict : t -> bool Sourceval is_negative_strict : t -> bool Sourceval contains_positive : t -> bool Sourceval contains_negative : t -> bool Sourceval contains_positive_strict : t -> bool Sourceval contains_negative_strict : t -> bool Sourceval contains_zero : t -> bool Sourceval contains_nonzero : t -> bool Whether the interval contains an element of the specified sign.
Whether the interval contains a single element.
Whether the interval has finite bounds.
Sourceval is_in_range : t -> float -> float -> bool 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
Conversion to integer (using truncation).
Join of non-empty intervals.
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.
Basic widening: put unstable bounds to infinity.
Fallback for backward unary operators
Fallback for backward binary operators
Backward remainder (fmod).
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.
Sourceval add_dbl_itv_near : t -> t -> t -> unit Sourceval add_dbl_itv_up : t -> t -> t -> unit Sourceval add_dbl_itv_down : t -> t -> t -> unit Sourceval add_dbl_itv_zero : t -> t -> t -> unit Sourceval add_dbl_itv_outer : t -> t -> t -> unit Sourceval add_dbl_itv_inner : t -> t -> t -> unit Sourceval add_sgl_itv_near : t -> t -> t -> unit Sourceval add_sgl_itv_up : t -> t -> t -> unit Sourceval add_sgl_itv_down : t -> t -> t -> unit Sourceval add_sgl_itv_zero : t -> t -> t -> unit Sourceval add_sgl_itv_outer : t -> t -> t -> unit Sourceval add_sgl_itv_inner : t -> t -> t -> unit Sourceval sub_dbl_itv_near : t -> t -> t -> unit Sourceval sub_dbl_itv_up : t -> t -> t -> unit Sourceval sub_dbl_itv_down : t -> t -> t -> unit Sourceval sub_dbl_itv_zero : t -> t -> t -> unit Sourceval sub_dbl_itv_outer : t -> t -> t -> unit Sourceval sub_dbl_itv_inner : t -> t -> t -> unit Sourceval sub_sgl_itv_near : t -> t -> t -> unit Sourceval sub_sgl_itv_up : t -> t -> t -> unit Sourceval sub_sgl_itv_down : t -> t -> t -> unit Sourceval sub_sgl_itv_zero : t -> t -> t -> unit Sourceval sub_sgl_itv_outer : t -> t -> t -> unit Sourceval sub_sgl_itv_inner : t -> t -> t -> unit Sourceval mul_dbl_itv_near : t -> t -> t -> unit Sourceval mul_dbl_itv_up : t -> t -> t -> unit Sourceval mul_dbl_itv_down : t -> t -> t -> unit Sourceval mul_dbl_itv_zero : t -> t -> t -> unit Sourceval mul_dbl_itv_outer : t -> t -> t -> unit Sourceval mul_dbl_itv_inner : t -> t -> t -> unit Sourceval mul_sgl_itv_near : t -> t -> t -> unit Sourceval mul_sgl_itv_up : t -> t -> t -> unit Sourceval mul_sgl_itv_down : t -> t -> t -> unit Sourceval mul_sgl_itv_zero : t -> t -> t -> unit Sourceval mul_sgl_itv_outer : t -> t -> t -> unit Sourceval mul_sgl_itv_inner : t -> t -> t -> unit Sourceval divpos_dbl_itv_near : t -> t -> t -> unit Sourceval divpos_dbl_itv_up : t -> t -> t -> unit Sourceval divpos_dbl_itv_down : t -> t -> t -> unit Sourceval divpos_dbl_itv_zero : t -> t -> t -> unit Sourceval divpos_dbl_itv_outer : t -> t -> t -> unit Sourceval divpos_dbl_itv_inner : t -> t -> t -> unit Sourceval divpos_sgl_itv_near : t -> t -> t -> unit Sourceval divpos_sgl_itv_up : t -> t -> t -> unit Sourceval divpos_sgl_itv_down : t -> t -> t -> unit Sourceval divpos_sgl_itv_zero : t -> t -> t -> unit Sourceval divpos_sgl_itv_outer : t -> t -> t -> unit Sourceval divpos_sgl_itv_inner : t -> t -> t -> unit Sourceval wrap_op1 : ('a -> t -> 'b) -> 'a -> t Sourceval wrap_op2 : ('a -> 'b -> t -> 'c) -> 'a -> 'b -> t Sourceval wrap_div_unmerged : ('a -> t -> 'b) -> 'a -> t -> 'b list Intervals with rounding to double.
Intervals with rounding to float.
Operations with rounding mode as argument
Sourcetype prec = [ | `SINGLE| `DOUBLE| `REALreal arithmetic (outward double rounding is used)
] Sourcetype round = [ | `NEAR| `UP| `DOWN| `ZERO| `ANY
] Rounding direction. This is ignored for real arithmetic.
Division. Returns a list of intervals to remain precise.
Backward round to integer.
Conversion from integer range.
Conversion from int64 range.
Conversion from integer range.
Backward rounding to integer.
Backward rounding to float.
Backward conversion from int.
Backward conversion to integer.