Module ItvUtils.FloatItv FloatItv - Floating-point interval arithmetics with rounding.
We rely on C code to provide functions with correct rounding (rounding direction and rounding precision).
Typestype 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.
Constructorsval mk : float -> float -> t val 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.
val hull : float -> float -> t Constructs the smallest interval containing a and b.
Predicatesval equal : t -> t -> boolval included : t -> t -> boolSet ordering. = also works to compare for equality.
val intersect : t -> t -> boolWhether the intervals have an non-empty intersection.
val contains : float -> t -> boolWhether the interval contains a certain value.
val compare : t -> t -> intA 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.
val is_positive : t -> boolval is_negative : t -> boolval is_positive_strict : t -> boolval is_negative_strict : t -> boolval is_nonzero : t -> boolval contains_positive : t -> boolval contains_negative : t -> boolval contains_positive_strict : t -> boolval contains_negative_strict : t -> boolval contains_zero : t -> boolval contains_nonzero : t -> boolWhether the interval contains an element of the specified sign.
val is_singleton : t -> boolWhether the interval contains a single element.
val is_bounded : t -> boolWhether the interval has finite bounds.
val is_in_range : t -> float -> float -> boolWhether the interval is included in the range lo,up.
val is_log_eq : t -> t -> boolval is_log_leq : t -> t -> boolval is_log_geq : t -> t -> boolval is_log_lt : t -> t -> boolval is_log_gt : t -> t -> boolval is_log_neq : t -> t -> boolC comparison tests. Returns true if the test may succeed, false if it cannot.
Printing Operations without roundingConversion 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 functionsInterval 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.
val add_dbl_itv_near : t -> t -> t -> unitval add_dbl_itv_up : t -> t -> t -> unitval add_dbl_itv_down : t -> t -> t -> unitval add_dbl_itv_zero : t -> t -> t -> unitval add_dbl_itv_outer : t -> t -> t -> unitval add_dbl_itv_inner : t -> t -> t -> unitval add_sgl_itv_near : t -> t -> t -> unitval add_sgl_itv_up : t -> t -> t -> unitval add_sgl_itv_down : t -> t -> t -> unitval add_sgl_itv_zero : t -> t -> t -> unitval add_sgl_itv_outer : t -> t -> t -> unitval add_sgl_itv_inner : t -> t -> t -> unitval sub_dbl_itv_near : t -> t -> t -> unitval sub_dbl_itv_up : t -> t -> t -> unitval sub_dbl_itv_down : t -> t -> t -> unitval sub_dbl_itv_zero : t -> t -> t -> unitval sub_dbl_itv_outer : t -> t -> t -> unitval sub_dbl_itv_inner : t -> t -> t -> unitval sub_sgl_itv_near : t -> t -> t -> unitval sub_sgl_itv_up : t -> t -> t -> unitval sub_sgl_itv_down : t -> t -> t -> unitval sub_sgl_itv_zero : t -> t -> t -> unitval sub_sgl_itv_outer : t -> t -> t -> unitval sub_sgl_itv_inner : t -> t -> t -> unitval mul_dbl_itv_near : t -> t -> t -> unitval mul_dbl_itv_up : t -> t -> t -> unitval mul_dbl_itv_down : t -> t -> t -> unitval mul_dbl_itv_zero : t -> t -> t -> unitval mul_dbl_itv_outer : t -> t -> t -> unitval mul_dbl_itv_inner : t -> t -> t -> unitval mul_sgl_itv_near : t -> t -> t -> unitval mul_sgl_itv_up : t -> t -> t -> unitval mul_sgl_itv_down : t -> t -> t -> unitval mul_sgl_itv_zero : t -> t -> t -> unitval mul_sgl_itv_outer : t -> t -> t -> unitval mul_sgl_itv_inner : t -> t -> t -> unitval divpos_dbl_itv_near : t -> t -> t -> unitval divpos_dbl_itv_up : t -> t -> t -> unitval divpos_dbl_itv_down : t -> t -> t -> unitval divpos_dbl_itv_zero : t -> t -> t -> unitval divpos_dbl_itv_outer : t -> t -> t -> unitval divpos_dbl_itv_inner : t -> t -> t -> unitval divpos_sgl_itv_near : t -> t -> t -> unitval divpos_sgl_itv_up : t -> t -> t -> unitval divpos_sgl_itv_down : t -> t -> t -> unitval divpos_sgl_itv_zero : t -> t -> t -> unitval divpos_sgl_itv_outer : t -> t -> t -> unitval divpos_sgl_itv_inner : t -> t -> t -> unitval wrap_op1 : ('a -> t -> 'b ) -> 'a -> t val wrap_op2 : ('a -> 'b -> t -> 'c ) -> 'a -> 'b -> t val wrap_div_unmerged : ('a -> t -> 'b ) -> 'a -> t -> 'b listIntervals with rounding to double.
Intervals with rounding to float.
Operations with rounding mode as argumenttype prec = [ | `SINGLE | `DOUBLE | `REAL real arithmetic (outward double rounding is used)
] type 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.
val of_int64 : prec -> round -> int64 -> int64 -> t Conversion from int64 range.
Conversion from integer range.
Backward rounding to integer.
Backward rounding to float.
Backward conversion from int.
Backward conversion to integer.