Crates.io | honestintervals |
lib.rs | honestintervals |
version | 0.2.0 |
source | src |
created_at | 2017-05-02 20:20:06.146286 |
updated_at | 2017-05-04 22:41:24.632382 |
description | Comprehensive, correctly rounding interval arithmetic library. |
homepage | |
repository | https://github.com/eseraygun/rust-honestintervals/ |
max_upload_size | |
id | 12845 |
size | 148,286 |
Honest Intervals is an arbitrary precision interval arithmetic library with correct rounding.
It implements elementary arithmetic (addition, subtraction, multiplication and division) as well as complicated mathematical functions such as logarithm and power over intervals and interval sets. Bounds of the return values are always correctly rounded up or down to ensure that all possible results are contained.
In addition to the Interval
and IntervalSet
structs, the library also provides the Mpfr
struct that wraps the GNU MPFR library. The Mpfr
struct is an ideal (and currently only)
bound type for intervals.
Honest Intervals tries to be a pragmatic implementation of interval arithmetic rather than an
abstract basis for all possible implementations. Users do not have to implement any traits; they
can create a correctly rounding interval right away by calling IntervalSet::<Mpfr>::new()
.
Here is a code that creates two interval sets and adds them.
use honestintervals::IntervalSet;
use honestintervals::mpfr::Mpfr;
use std::str::FromStr;
let x = IntervalSet::<Mpfr>::from_str("{0; <1, 2>}").unwrap();
let y = IntervalSet::<Mpfr>::singleton(Mpfr::from(3.0));
assert_eq!("{3; <4, 5>}", format!("{}", x + y));
Here is a tricky case of interval division handled correctly by Honest Intervals.
let x = IntervalSet::<Mpfr>::from_str("<1, 2>").unwrap();
let y = IntervalSet::<Mpfr>::from_str("<-1, 1>").unwrap();
assert_eq!("{<-inf, -1>; <1, inf>}", format!("{}", x / y));
See the documentation for more details.
Honest Intervals is distributed under the terms of the Apache License (Version 2.0).
See LICENSE for details.