Developer documentation

Interval_glue.hpp
Go to the documentation of this file.
1 #ifndef realroot_interval_glue_hpp
2 #define realroot_interval_glue_hpp
3 /******************************************************************************/
4 #include <basix/list.hpp>
5 #include <numerix/interval.hpp>
6 
7 #define FORALL(X) template<class X>
8 #define Interval interval<C>
9 
10 namespace mmx
11 {
12  FORALL(C) inline mmx::nat hash(const Interval& p){ return 1;}
13 // FORALL(C) inline mmx::nat soft_hash(const Interval& p){ return 1;}
14 // FORALL(C) inline bool eq(const Interval& p, const Interval& q){ return p==q;}
15 
16 
17  FORALL(C) syntactic flatten(const Interval & x)
18  {
19  return flatten(cons(as<generic>(lower(x)), list<generic>(as<generic>(upper(x)))));
20  }
21 
22 
23  FORALL(C) Interval
24  interval_from_pair (const C& a, const C& b)
25  {
26  return Interval(a,b);
27  }
28 
29  FORALL(C) inline C interval_lower (const Interval& I) {return lower(I);}
30  FORALL(C) inline C interval_upper (const Interval& I) {return upper(I);}
31 
32 
33  template<typename T, typename F>
34  struct as_helper< interval<T>,interval<F> >
35  {
36  static inline
37  interval<T> cv (const interval<F>& x)
38  {
39  return interval<T>(as<T>(lower(x)),as<T>(upper(x)));
40  }
41  };
42 
43  //--------------------------------------------------------------------
44  FORALL(C) Interval operator+( const Interval& I, const C& c)
45  {
46  return I+ Interval(c,c);
47  }
48  FORALL(C) Interval operator+( const C& c, const Interval& I)
49  {
50  return Interval(c,c)+I;
51  }
52 
53  FORALL(C) Interval operator-( const Interval& I, const C& c)
54  {
55  return I- Interval(c,c);
56  }
57  FORALL(C) Interval operator-( const C& c, const Interval& I)
58  {
59  return Interval(c,c)-I;
60  }
61 
62  FORALL(C) Interval operator*( const Interval& I, const C& c)
63  {
64  return I* Interval(c,c);
65  }
66  FORALL(C) Interval operator*( const C& c, const Interval& I)
67  {
68  return Interval(c,c)*I;
69  }
70 
71  //--------------------------------------------------------------------
72  FORALL(C) C interval_size (const Interval& p)
73  {
74  return upper(p)-lower(p);
75  }
76 
77 } // namespace mmx
78 //--------------------------------------------------------------------
79 #undef Interval
80 #undef FORALL
81 
82 #endif //realroot_interval_glue_hpp
const C & b
Definition: Interval_glue.hpp:25
const Interval & I
Definition: Interval_glue.hpp:49
Definition: assign.hpp:48
T upper(const Interval< T, r > &x)
Definition: Interval_fcts.hpp:89
TMPL unsigned hash(const Monomial &v)
Definition: monomial_glue.hpp:26
#define Interval
Definition: Interval_glue.hpp:8
TMPL syntactic flatten(const MONOMIAL &v)
Definition: monomial_glue.hpp:36
T lower(const Interval< T, r > &x)
Definition: Interval_fcts.hpp:87
Generic class for intervals.
Definition: Interval.hpp:44
const C & c
Definition: Interval_glue.hpp:45
double C
Definition: solver_mv_fatarcs.cpp:16
Definition: array.hpp:12
static interval< T > cv(const interval< F > &x)
Definition: Interval_glue.hpp:37
FORALL(C) inline mmx
Definition: Interval_glue.hpp:12
Home