package interval_crlibm

  1. Overview
  2. Docs
An interval library for OCaml (crlibm version)

Install

Dune Dependency

Authors

Maintainers

Sources

interval-1.6.tbz
sha256=a2807d7860a9f965a3f91b40de17b98321e5c3f7da9e69dccf3dc20f1ac77e96
sha512=76196b171a41ce1374cae946b7c7a1dea6d614db61743ead14d628a12dce30a0dbd82db1960ad17b58f1f65a6f3fc61aaa5eac42face474baf840efb670feee8

Description

This library uses assembly code to compute all operations with proper roundings, and currently ONLY works on intel processors.

This package uses CRlibm (a proved correctly rounded mathematical library) to provide enclosures of transcendental functions. It may be slower than the version using the implementation in the CPU but the bounds are proved correct. It also provides *pi versions of the trigonometric functions and their inverse.

Tags

interval science

Published: 09 Dec 2022

README

README.md

Interval

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

# #require "interval.top";;
...
# open Interval_crlibm;;
# let v = I.singleton 1.;;
val v : Interval_crlibm.I.t = [1, 1]
# I.sin v;;
- : Interval_crlibm.I.t = [0.841471, 0.841471]
# I.Precision.set (Some 16);;
- : unit = ()
# I.sin v;;
- : Interval_crlibm.I.t = [0.8414709848078965, 0.8414709848078966]

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 (module Interval).

  • 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. It also provides interval.top used 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.

Dependencies (3)

  1. crlibm >= "0.5"
  2. dune
  3. interval_base = version

Dev Dependencies

None

Used by (1)

  1. interval >= "1.6"

Conflicts

None