MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Interval.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGInterval_HH_
6 #define _MGInterval_HH_
7 #include "mg/EReal.h"
13 // MGInterval.h
14 // header for class MGInterval
15 // Forward Declaration
16 class MGIfstream;
17 class MGOfstream;
18 
20 
22 class MG_DLL_DECLR MGInterval{
23 
24 public:
25 
26 MG_DLL_DECLR friend bool operator>(const MGEReal&, const MGInterval&);
27 MG_DLL_DECLR friend MGInterval operator+ (double, const MGInterval& );
28 
32 MG_DLL_DECLR friend MGInterval operator* (double a, const MGInterval& );
33 
34 MG_DLL_DECLR friend bool operator<(const MGEReal&, const MGInterval&);
35 MG_DLL_DECLR friend bool operator>=(const MGEReal&, const MGInterval&);
36 MG_DLL_DECLR friend bool operator<=(const MGEReal&, const MGInterval&);
37 MG_DLL_DECLR friend bool operator>(double, const MGInterval& i);
38 MG_DLL_DECLR friend bool operator<(double, const MGInterval& i);
39 
41 MG_DLL_DECLR friend std::ostream& operator<< (std::ostream&, const MGInterval&);
42 
44 
46 MGInterval();
47 
59 explicit MGInterval(MGINTERVAL_TYPE, double=0.0);
60 
66 MGInterval(const MGEReal& t1, const MGEReal& t2);
67 
69 MGInterval(const MGInterval&, const MGEReal&);
70 
72 explicit MGInterval(double t);
73 
75 
78 const MGEReal& operator() (int i)const;
79 MGEReal& operator() (int i);
80 const MGEReal& operator[] (int i)const;
81 MGEReal& operator[] (int i);
82 
87 MGInterval operator+ (const MGInterval& ) const;
88 
91 MGInterval operator+ (double) const;
92 
96 MGInterval& operator+= (const MGInterval& );
97 
99 MGInterval& operator+= (double);
100 
103 MGInterval operator- () const;
104 
109 MGInterval operator- (const MGInterval& ) const ;
110 
113 MGInterval operator- (double) const;
114 
118 MGInterval& operator-= (const MGInterval& );
119 
121 MGInterval& operator-= (double);
122 
127 MGInterval operator* (double a) const;
128 
133 MGInterval& operator*= (double a);
134 
139 MGInterval operator/ (double a) const;
140 
145 MGInterval& operator/= (double a);
146 
151 MGInterval operator| (const MGInterval&) const ;
152 
157 MGInterval& operator|= (const MGInterval&);
158 
162 MGInterval operator& (const MGInterval&) const ;
163 
167 MGInterval& operator&= (const MGInterval&);
168 
170 
174 bool operator&& (const MGInterval&)const;
175 
182 bool operator>> (const MGInterval& intrval2) const;
183 
188 bool operator>> (const MGEReal& t) const;
189 
196 bool operator<< (const MGInterval& intrval2) const;
197 
202 bool operator<< (const MGEReal& t) const;
203 
207 bool operator== (const MGInterval&) const;
208 
212 bool operator!= (const MGInterval&) const;
213 
215 bool operator< (const MGInterval&) const;
216 bool operator> (const MGInterval&) const;
217 bool operator<= (const MGInterval&) const;
218 bool operator>= (const MGInterval&) const;
219 
220 bool operator< (const MGEReal& ) const;
221 bool operator> (const MGEReal&) const;
222 bool operator<= (const MGEReal&) const;
223 bool operator>= (const MGEReal&) const;
224 
225 //Return true if m_high<t;
226 bool operator< (double t) const;
227 
228 //Return true if m_low>t;
229 bool operator> (double t) const;
230 
232 
235 void change_range(
236  double t0,
237  double t1
238 );
239 
243 bool empty() const;
244 
246 void expand(const MGEReal& val);
247 
250 bool finite() const;
251 
254 bool finite_above() const;
255 
258 bool finite_below() const;
259 
260 const MGEReal& high() const {return m_high;};
261 MGEReal& high() {return m_high;};
262 
266 double high_point() const;
267 
271 bool includes(double t)const;
272 
275 bool infinite() const;
276 
278 bool infinite_above() const;
279 
281 bool infinite_below() const;
282 
289 double interpolate(double t) const;
290 
292 bool is_null() const{return empty();};
293 
298 MGEReal length() const;
299 
300 const MGEReal& low() const {return m_low;};
301 MGEReal& low() {return m_low;};
302 
307 double low_point() const;
308 
311 double mid_point() const;
312 
314 double relative_error() const;
315 
319 double round_into_interval(double t)const;
320 
322 void set_length(double len);
323 
325 void set_null(double t=0.);
326 void set_empty(double t=0.){set_null(t);};
327 
332 void set_high_point(const MGEReal&);
333 void set_high(const MGEReal& t){set_high_point(t);};
334 
339 void set_low_point(const MGEReal&);
340 void set_low(const MGEReal& t){set_low_point(t);};
341 
344 MGINTERVAL_TYPE type() const;
345 
348 int dump_size() const;
349 
351 int dump(MGOfstream& ) const;
352 
354 int restore(MGIfstream& );
355 
356 private:
357 
359 
361  MGEReal m_high;
362  MGEReal m_low;
363 
364 };
365  // end of BASE group
367 #endif
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
std::ostream & operator<<(std::ostream &ostrm, const MGisect &is)
Debug Function.
Definition: isect.h:95
void set_empty(double t=0.)
Definition: Interval.h:326
MG_DLL_DECLR MGVector & operator*=(MGVector &v, const MGMatrix &m)
Interval of 1 dimension, i.e. MGInterval is a real line.
Definition: Interval.h:22
MG_DLL_DECLR MGVector operator*(const MGVector &v, const MGMatrix &m)
void set_low(const MGEReal &t)
Definition: Interval.h:340
const MGEReal & low() const
Definition: Interval.h:300
MGEReal is extended real number to define infinity.
Definition: EReal.h:22
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
void set_high(const MGEReal &t)
Definition: Interval.h:333
MGEReal & low()
Definition: Interval.h:301
MGINTERVAL_TYPE
MGInterval type.
Definition: MGCL.h:117
MGEReal & high()
Definition: Interval.h:261
const MGEReal & high() const
Definition: Interval.h:260
bool is_null() const
Test if this is empty interval.
Definition: Interval.h:292