Interval arithmetic

The Interval template implements interval arithmetic,

template<class C, int r >   struct Interval;

The class Interval is parameterised by

The default Interval<C> corresponds to r=3.

Example

o+

#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;
};

Implementation

See also:
synaps/arithm/Interval.h

SYNAPS DOCUMENTATION
logo