Bayeux  3.4.1
Core Foundation library for SuperNEMO
interval.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2009-10-02
4  * Last modified: 2013-04-11
5  *
6  * License:
7  *
8  *
9  * Description:
10  *
11  * A simple interval [min:max] for double precision values
12  *
13  * Supported bounds schemes are :
14  * [0:1]
15  * (0:1]
16  * [0:1)
17  * ( :1]
18  * [0: )
19  * [0: )
20  * ( : )
21  * [!]
22  *
23  * History:
24  *
25  *
26  *
27  */
28 
29 #ifndef MYGSL_INTERVAL_H
30 #define MYGSL_INTERVAL_H 1
31 
32 // Standard library:
33 #include <iostream>
34 
35 // Third party:
36 // - Bayeux/datatools :
38 
39 namespace mygsl {
40 
43  {
44  public:
45 
46  static const double NO_MIN_VALUE;
47  static const double NO_MAX_VALUE;
48  static const double NO_VALUE;
49  static const double DEFAULT_EPS;
50  static const double AUTO_EPS;
51  static const double auto_eps;
52 
53  static const char IO_SEP;
54  static const char IO_EMPTY;
55  static const char IO_OPEN_INCL;
56  static const char IO_OPEN_EXCL;
57  static const char IO_CLOSE_INCL;
58  static const char IO_CLOSE_EXCL;
59 
60  static const bool included;
61  static const bool excluded;
62 
63  public:
64 
66  interval ();
67 
69  interval (double min_, double max_, double eps_ = AUTO_EPS);
70 
72  interval (double min_, bool min_include_,
73  double max_, bool max_include_,
74  double eps_ = AUTO_EPS);
75 
77  virtual ~interval ();
78 
79  void remove_min ();
80 
81  void remove_max ();
82 
83  void reset ();
84 
85  void set_min_included (bool inc_);
86 
87  void set_max_included (bool inc_);
88 
89  bool is_min_included () const;
90 
91  bool is_max_included () const;
92 
93  bool is_valid () const;
94 
95  bool has_min () const;
96 
97  bool has_max () const;
98 
99  double get_min () const;
100 
101  double get_max () const;
102 
103  double get_eps () const;
104 
105  bool union_with (const interval &);
106 
107  bool intercept_with (const interval &);
108 
109  bool is_in (double x_) const;
110 
111  bool is_in_safe (double x_) const;
112 
113  bool is_in_min_unsafe (double x_) const;
114 
115  bool is_in_max_unsafe (double x_) const;
116 
117  interval get_safe_interval (double eps_ = AUTO_EPS) const;
118 
119  void set_eps (double eps_);
120 
121  void set (double min_, double max_, double eps_ = AUTO_EPS);
122 
123  bool is_no_limit () const;
124 
125  bool is_empty () const;
126 
127  void open ();
128 
129  void close ();
130 
131  bool intersection_with (const interval & i_) const;
132 
133  static interval make_empty ();
134 
135  static interval make_no_limit (double eps_ = AUTO_EPS);
136 
137  static interval make_neighbourhood (double value_, double delta_, bool included_ = excluded);
138 
139  static interval make_min (double min_, bool min_include_ = excluded,
140  double eps_ = AUTO_EPS);
141 
142  static interval make_max (double max_, bool max_include_ = excluded,
143  double eps_ = AUTO_EPS);
144 
145  static interval make_min_max_included (double min_,
146  double max_,
147  double eps_ = AUTO_EPS);
148 
149  static interval make_min_max_excluded (double min_,
150  double max_,
151  double eps_ = AUTO_EPS);
152 
153  static interval make_min_max (double min_, bool min_include_,
154  double max_, bool max_include_,
155  double eps_ = AUTO_EPS);
156 
157  friend std::ostream & operator<< (std::ostream & out_, const interval & i_);
158 
159  friend std::istream & operator>> (std::istream & in_, interval & i_);
160 
161  private:
162 
163  bool _min_included_;
164  bool _max_included_;
165  double _min_;
166  double _max_;
167  double _eps_;
168 
170 
171  };
172 
173 } // end of namespace mygsl
174 
175 #endif // MYGSL_INTERVAL_H
176 
177 /* Local Variables: */
178 /* mode: c++ */
179 /* coding: utf-8 */
180 /* End: */
friend std::ostream & operator<<(std::ostream &out_, const interval &i_)
Base abstract class of all serializable (and possibly introspectable) classes.
Definition: i_serializable.h:51
double get_min() const
bool has_min() const
static const double DEFAULT_EPS
Definition: interval.h:49
static const double NO_VALUE
Definition: interval.h:48
static interval make_min(double min_, bool min_include_=excluded, double eps_=AUTO_EPS)
static const bool included
Definition: interval.h:60
static const char IO_EMPTY
Definition: interval.h:54
void set_min_included(bool inc_)
bool is_no_limit() const
bool is_in_max_unsafe(double x_) const
double get_eps() const
bool is_valid() const
interval get_safe_interval(double eps_=AUTO_EPS) const
static const char IO_CLOSE_INCL
Definition: interval.h:57
void set(double min_, double max_, double eps_=AUTO_EPS)
bool is_min_included() const
static const char IO_OPEN_INCL
Definition: interval.h:55
bool is_max_included() const
double get_max() const
static const char IO_SEP
Definition: interval.h:53
static const double auto_eps
Definition: interval.h:51
#define DATATOOLS_SERIALIZATION_DECLARATION()
Definition: i_serializable.h:266
bool intercept_with(const interval &)
static interval make_min_max(double min_, bool min_include_, double max_, bool max_include_, double eps_=AUTO_EPS)
bool intersection_with(const interval &i_) const
static const double AUTO_EPS
Definition: interval.h:50
static const char IO_OPEN_EXCL
Definition: interval.h:56
virtual ~interval()
Destructor.
void set_max_included(bool inc_)
bool is_in_safe(double x_) const
bool union_with(const interval &)
static interval make_max(double max_, bool max_include_=excluded, double eps_=AUTO_EPS)
static interval make_min_max_excluded(double min_, double max_, double eps_=AUTO_EPS)
static interval make_neighbourhood(double value_, double delta_, bool included_=excluded)
bool is_in_min_unsafe(double x_) const
bool is_in(double x_) const
static const char IO_CLOSE_EXCL
Definition: interval.h:58
static const double NO_MAX_VALUE
Definition: interval.h:47
bool has_max() const
static interval make_empty()
friend std::istream & operator>>(std::istream &in_, interval &i_)
bool is_empty() const
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
interval()
Default constructor.
void set_eps(double eps_)
static const bool excluded
Definition: interval.h:61
static interval make_min_max_included(double min_, double max_, double eps_=AUTO_EPS)
static interval make_no_limit(double eps_=AUTO_EPS)
An interval with real bounds.
Definition: interval.h:42
static const double NO_MIN_VALUE
Definition: interval.h:46