MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
EReal.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGEReal_HH_
6 #define _MGEReal_HH_
7 
11 #include "mg/MGCL.h"
12 
13 // MGEReal.h
14 //
15 
16 class MGIfstream;
17 class MGOfstream;
18 
20 
22 class MG_DLL_DECLR MGEReal {
23 
24 public:
25 
26 MG_DLL_DECLR friend MGEReal operator+ (double, const MGEReal&);
27 MG_DLL_DECLR friend MGEReal operator- (double, const MGEReal&);
28 MG_DLL_DECLR friend MGEReal operator* (double, const MGEReal&);
29 MG_DLL_DECLR friend MGEReal operator/ (double, const MGEReal&);
30 MG_DLL_DECLR friend bool operator== (double, const MGEReal&);
31 MG_DLL_DECLR friend bool operator!= (double, const MGEReal&);
32 MG_DLL_DECLR friend bool operator> (double, const MGEReal&);
33 MG_DLL_DECLR friend bool operator< (double, const MGEReal&);
34 MG_DLL_DECLR friend bool operator>= (double, const MGEReal&);
35 MG_DLL_DECLR friend bool operator<= (double, const MGEReal&);
36 
38 MG_DLL_DECLR friend std::ostream& operator<< (std::ostream&, const MGEReal& );
39 
41 
43 MGEReal(double val=0.0):m_value(val){;};
44 
47 MGEReal(MGINFINITE_TYPE infinite);
48 
49 //Destructor
50 // ~MGEReal();
51 
53 
54 MGEReal operator+ (double) const;
55 MGEReal operator+ (const MGEReal&) const;
56 
57 MGEReal& operator+= (double);
58 MGEReal& operator+= (const MGEReal&);
59 
61 MGEReal operator- () const;
62 
63 MGEReal operator- (double) const;
64 MGEReal operator- (const MGEReal&) const;
65 
66 MGEReal& operator-= (double);
67 MGEReal& operator-= (const MGEReal&);
68 
69 MGEReal operator* (double) const;
70 MGEReal operator* (const MGEReal&) const;
71 
72 MGEReal& operator*= (double);
73 MGEReal& operator*= (const MGEReal&);
74 
75 MGEReal operator/ (double) const;
76 MGEReal operator/ (const MGEReal&) const;
77 
78 MGEReal& operator/= (double);
79 MGEReal& operator/= (const MGEReal&);
80 
81 bool operator== (double t) const;
82 bool operator== (const MGEReal&) const;
83 
84 bool operator!= (double t) const{return !((*this)==t);};
85 bool operator!= (const MGEReal& er2) const{return !((*this)==er2);};
86 
87 bool operator> (double t) const;
88 bool operator> (const MGEReal&) const;
89 
90 bool operator< (double t) const;
91 bool operator< (const MGEReal& er2) const{return er2>(*this);};
92 
93 bool operator>= (const MGEReal& er2)const;
94 bool operator<= (const MGEReal& er2)const{return er2>=(*this);};
95 bool operator>= (double t) const;
96 bool operator<= (double t) const;
97 
99 
101 int infinite_coef()const;
102 
103 bool equal_base(double t, double base)const;
104 bool equal_base(const MGEReal& t,double base)const;
105 bool finite()const{return infinite_coef()==0;};
106 bool infinite()const{return infinite_coef()!=0;};
107 void invert(){m_value*=-1.;};
108 bool minus_infinite()const{return (m_value<=(-mgInfiniteVal));};
109 bool plus_infinite()const{return (mgInfiniteVal<=m_value);};
110 void set_real(double val){m_value=val;};
111 void set_plus_infinite(){m_value=mgInfiniteVal+1.;};
112 void set_minus_infinite(){m_value=-mgInfiniteVal-1.;};
113 void set_zero(){m_value=0.;};
114 double value() const {return m_value;};
115 
118 int dump_size() const;
119 
121 int dump(MGOfstream& ) const;
122 
124 int restore(MGIfstream& );
125 
127 
128 private:
130  double m_value;
131 
133 friend class MGInterval;
134 
135 };
136  // end of BASE group
138 #endif
MGINFINITE_TYPE
Infinite type.
Definition: MGCL.h:110
bool plus_infinite() const
Definition: EReal.h:109
void set_plus_infinite()
Definition: EReal.h:111
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
double value() const
Definition: EReal.h:114
MG_DLL_DECLR MGVector & operator*=(MGVector &v, const MGMatrix &m)
bool infinite() const
Definition: EReal.h:106
bool finite() const
Definition: EReal.h:105
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_minus_infinite()
Definition: EReal.h:112
bool minus_infinite() const
Definition: EReal.h:108
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_real(double val)
Definition: EReal.h:110
void invert()
Definition: EReal.h:107
void set_zero()
Definition: EReal.h:113
const double mgInfiniteVal
Definition: MGCL.h:107
MGEReal(double val=0.0)
Default Constructor.
Definition: EReal.h:43