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 -> bool
val included : t -> t -> bool
Set ordering. = also works to compare for equality.
val intersect : t -> t -> bool
Whether the intervals have an non-empty intersection.
val contains : float -> t -> bool
Whether the interval contains a certain value.
val compare : t -> t -> int
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.
val is_positive : t -> bool
val is_negative : t -> bool
val is_positive_strict : t -> bool
val is_negative_strict : t -> bool
val is_nonzero : t -> bool
val contains_positive : t -> bool
val contains_negative : t -> bool
val contains_positive_strict : t -> bool
val contains_negative_strict : t -> bool
val contains_zero : t -> bool
val contains_nonzero : t -> bool
Whether the interval contains an element of the specified sign.
val is_singleton : t -> bool
Whether the interval contains a single element.
val is_bounded : t -> bool
Whether the interval has finite bounds.
val is_in_range : t -> float -> float -> bool
Whether the interval is included in the range lo,up
.
val is_log_eq : t -> t -> bool
val is_log_leq : t -> t -> bool
val is_log_geq : t -> t -> bool
val is_log_lt : t -> t -> bool
val is_log_gt : t -> t -> bool
val is_log_neq : t -> t -> bool
C 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 -> unit
val add_dbl_itv_up : t -> t -> t -> unit
val add_dbl_itv_down : t -> t -> t -> unit
val add_dbl_itv_zero : t -> t -> t -> unit
val add_dbl_itv_outer : t -> t -> t -> unit
val add_dbl_itv_inner : t -> t -> t -> unit
val add_sgl_itv_near : t -> t -> t -> unit
val add_sgl_itv_up : t -> t -> t -> unit
val add_sgl_itv_down : t -> t -> t -> unit
val add_sgl_itv_zero : t -> t -> t -> unit
val add_sgl_itv_outer : t -> t -> t -> unit
val add_sgl_itv_inner : t -> t -> t -> unit
val sub_dbl_itv_near : t -> t -> t -> unit
val sub_dbl_itv_up : t -> t -> t -> unit
val sub_dbl_itv_down : t -> t -> t -> unit
val sub_dbl_itv_zero : t -> t -> t -> unit
val sub_dbl_itv_outer : t -> t -> t -> unit
val sub_dbl_itv_inner : t -> t -> t -> unit
val sub_sgl_itv_near : t -> t -> t -> unit
val sub_sgl_itv_up : t -> t -> t -> unit
val sub_sgl_itv_down : t -> t -> t -> unit
val sub_sgl_itv_zero : t -> t -> t -> unit
val sub_sgl_itv_outer : t -> t -> t -> unit
val sub_sgl_itv_inner : t -> t -> t -> unit
val mul_dbl_itv_near : t -> t -> t -> unit
val mul_dbl_itv_up : t -> t -> t -> unit
val mul_dbl_itv_down : t -> t -> t -> unit
val mul_dbl_itv_zero : t -> t -> t -> unit
val mul_dbl_itv_outer : t -> t -> t -> unit
val mul_dbl_itv_inner : t -> t -> t -> unit
val mul_sgl_itv_near : t -> t -> t -> unit
val mul_sgl_itv_up : t -> t -> t -> unit
val mul_sgl_itv_down : t -> t -> t -> unit
val mul_sgl_itv_zero : t -> t -> t -> unit
val mul_sgl_itv_outer : t -> t -> t -> unit
val mul_sgl_itv_inner : t -> t -> t -> unit
val divpos_dbl_itv_near : t -> t -> t -> unit
val divpos_dbl_itv_up : t -> t -> t -> unit
val divpos_dbl_itv_down : t -> t -> t -> unit
val divpos_dbl_itv_zero : t -> t -> t -> unit
val divpos_dbl_itv_outer : t -> t -> t -> unit
val divpos_dbl_itv_inner : t -> t -> t -> unit
val divpos_sgl_itv_near : t -> t -> t -> unit
val divpos_sgl_itv_up : t -> t -> t -> unit
val divpos_sgl_itv_down : t -> t -> t -> unit
val divpos_sgl_itv_zero : t -> t -> t -> unit
val divpos_sgl_itv_outer : t -> t -> t -> unit
val divpos_sgl_itv_inner : t -> t -> t -> unit
val 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 list
Intervals 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.