mlmpfr, OCaml bindings for MPFR
master | mlmpfr.4.0.2 | mlmpfr.4.0.1 | mlmpfr.4.0.0 | mlmpfr.3.1.6 |
---|---|---|---|---|
(tested on linux and osx)
mlmpfr
OCaml bindings for MPFR.
build and install
Building mlmpfr depends on oasis (an OCaml build system), ocaml version >= 4.04, and MPFR library version 3.1.6, 4.0.0, 4.0.1 or 4.0.2. Basically you just need to install oasis via the opam package manager, which will triggers all the dependencies (such as ocamlfind for example).
From sources (github repo or releases): in mlmpfr main directory, on branch release_316 (resp. release mlmpfr.3.1.6) for MPFR 3.1.6, release_40[0-2] for MPFR 4.0.[0-2] (resp. releases mlmpfr.4.0.[0-2]). Make sure that you have the proper MPFR library version installed because mlmpfr won’t check for it.
oasis setup
./configure --enable-tests
make
make test
make install
# `make uninstall` to remove mlmpfr library.
From opam (targeting MPFR 3.1.6).
opam install mlmpfr.3.1.6
# `opam remove mlmpfr` to remove the package.
Note: opam package mlmpfr.4.0.0
also exists and its suitable for
MPFR 4.0.0, 4.0.1 and 4.0.2 versions.
documentation
Run:
make doc # Generate HTML documentation
or see an HTML version here.
usage
For example, let example.ml as follows:
module M = Mpfr
let _ =
let op = M.make_from_float (~-. 1. /. 3.) in
Printf.printf "%s\n" (M.get_formatted_str (M.cos op))
Compile the above code with:
ocamlfind ocamlopt -o a.out -linkpkg -package mlmpfr example.ml -cclib -lmpfr
will results in:
$ ./a.out
9.449569463147377e-01