Chebyshev
Unit testing for scientific software
interval.h
Go to the documentation of this file.
1 
5 
6 #ifndef CHEBYSHEV_INTERVAL_H
7 #define CHEBYSHEV_INTERVAL_H
8 
9 
10 namespace chebyshev {
11 
12  namespace prec {
13 
16  struct interval {
17 
19  long double a;
20 
22  long double b;
23 
25  interval() : a(0), b(0) {}
26 
27 
29  interval(long double l, long double r) : a(l), b(r) {}
30 
31 
33  inline long double length() const {
34  const long double diff = b - a;
35  return diff > 0 ? diff : -diff;
36  }
37  };
38 
39  }
40 }
41 
42 
43 #endif
General namespace of the framework.
Definition: benchmark_structures.h:16
An interval on the real numbers.
Definition: interval.h:16
interval(long double l, long double r)
Construct an interval from its lower and upper bounds.
Definition: interval.h:29
long double length() const
Returns the length of the interval.
Definition: interval.h:33
long double a
Lower extreme of the interval.
Definition: interval.h:19
long double b
Upper extreme of the interval.
Definition: interval.h:22
interval()
Construct over the origin.
Definition: interval.h:25