Interval
template implements interval arithmetic,
template<class C, int r > struct Interval;
The class Interval
is parameterised by
C
of the coefficients,int
r
corresponding to the rounding policies used, the possibles values are:0
corresponding to an unsafe use of interval arithmetic,1
safe arithmetic assuming downward rounding mode turned on,2
safe arithmetic assuming upward rounding mode turned on,
3
context free safe arithmetic.Interval<C>
corresponds to r=3
.#include <synaps/init.h> #include <synaps/arithm/gmp.h> #include <synaps/arithm/Interval.h> #include <synaps/upol/UPolDse.h> typedef Interval<double> interval; int main() { Interval<double> a(0,1.25); Interval<ZZ,0> b(1,2); Interval<QQ,0> c(2,3); c = a; std::cout << c << std::endl; //| [ 0,5/4 ] (conversion to rational type) c += a/b; std::cout << c << std::endl; //| [ 0,5/2 ] (conversion to rational type) return 0; };
synaps/arithm/Interval.h