interval_base

An interval library for OCaml (base package)
README


Interval

This is an interval arithmetic library for OCaml. Here is a small
example in the REPL:

# #require "interval_intel";;
~/.opam/4.06.1/lib/interval_base: added to search path
~/.opam/4.06.1/lib/interval_base/interval.cma: loaded
~/.opam/4.06.1/lib/interval_intel: added to search path
~/.opam/4.06.1/lib/interval_intel/interval_intel.cma: loaded
# open Interval_intel;;
# let v = I.v 1. 1.;;
val v : Interval.t = {Interval.low = 1.; high = 1.}
# I.sin v;;
- : Interval_intel.t =
{low = 0.841470984807896505; high = 0.841470984807896616}

Several OPAM packages are provided by this repository:

  • interval_base: basic interval library that defines the datatype
    Interval.t and uses Intel assembly if possible or C99 instructions
    to perform arithmetic operations.

  • interval_crlibm: relies on crlibm to implement the interval
    operations. CRlibm provides proved correctly-rounded operations,
    so this is the library of choice for computer assisted proofs.

  • interval_intel: use Intel FPU instructions with directed rounding
    to implement interval operations. However, the Intel FPU operations
    may not always be correctly rounded for, say, trigonometric
    functions.

    interval_intel uses assembly code to compute all operations with
    proper rounding, and currently ONLY works on Intel processors.
    The package has been developed for Linux systems but works on
    MacOSX and Windows when compiled with GCC.

  • interval is a meta-package installing all the packages above.

Note that ocamlopt does float constant propagation in round to the
nearest
mode which may invalidate interval computations. Use the
compiler flag -no-float-const-prop to deactivate it.

Happy interval programming...

Installation

The easier way to install this library is to use OPAM:

opam install interval

interval is a meta-package that will install all packages mentioned above.

If you cloned this repository, first install dune and
type make in the main directory. This will compile the libraries,
the examples and run basic tests. You can compile the examples with The
programs of the examples will be in _build/default/examples/.

Documentation

To documentation is build using dune build @doc and will be in
_build/default/_doc/ in HTML format. You can also consult the
interfaces of

or online.
It is extremely wise to read the whole documentation, even if you
intend to only use the Interval_intel module.

Some examples are available in the examples/ directory. There is a
B_AND_B sub-directory with an example of a branch-and-bound
algorithm that uses interval arithmetics for function optimization
(the example is for the Griewank function, but you can substitute any
function you like).

Tests

Tests are available in the tests/ directory. They are mainly for
debugging purpose and quite complicated. You may run them (make tests) to check that everything is working properly for your machine.
The test program runs also a speed test for your particular
architecture.

Bug reports should be open at
https://github.com/Chris00/ocaml-interval/issues

Remark: This library was originally published on Jean-Marc Alliot
website but was moved to Github
with the permission of the authors.

Install
Sources
interval-1.5.1.tbz
sha256=623b6117ba2d36f4ddbf78777d1ba1fad324d00db1f641f064fc231602b40aa2
sha512=09fbca71c9eeb89b56bbf752240f1fec8515757ecb4245912e6e6e7c9baa1cce1e6b009f40f17b5aa97f405ac870c6203f472eba6600efdaf43066e58a018d04
Dependencies
Reverse Dependencies
interval
>= "1.5.1"
interval_intel
>= "1.5.1"