00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef ___phiutility__
00030 #define ___phiutility__
00031
00032 #include <iostream>
00033 #include <cmath>
00034
00039 class Phi {
00040
00041 private:
00042
00043 double m_val ;
00044
00045 void reduce() {
00046 while( m_val > UPPER_LIMIT ) { m_val -= RANGE ; }
00047 while( m_val <= LOWER_LIMIT ) { m_val += RANGE ; }
00048 }
00049
00050
00051 public:
00052
00053 static const double UPPER_LIMIT;
00054 static const double LOWER_LIMIT;
00055 static const double RANGE;
00056
00057
00058 Phi() { this->m_val = 0. ; }
00059 Phi( const double init ) { this->m_val = init ; this->reduce() ; }
00060 Phi( Phi& src ) { this->m_val = src.m_val ; }
00061
00062
00063
00064 Phi& operator= ( const Phi& rhs ) {
00065 this->m_val = rhs.m_val;
00066 return *this;
00067 }
00068
00069 Phi& operator+= ( Phi& rhs ) {
00070 this->m_val += rhs.m_val ;
00071 reduce() ;
00072 return *this;
00073 }
00074
00075 Phi& operator-= ( Phi& in ) {
00076 this->m_val -= in.m_val;
00077 reduce() ;
00078 return *this;
00079 }
00080
00081 Phi operator+ ( Phi& in ) const {
00082 Phi result( this->m_val + in.m_val ) ;
00083 return result ;
00084 }
00085
00086 Phi operator- ( Phi& in ) const {
00087 Phi result(this->m_val - in.m_val ) ;
00088 return result ;
00089 }
00090
00091
00092 bool operator< ( Phi& in ) const { return this->m_val < in.m_val ; }
00093 bool operator> ( Phi& in ) const { return this->m_val > in.m_val ; }
00094
00095
00096 operator double() const { return this->m_val ; }
00097
00098 };
00099
00100 #endif
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128