Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

Number.h

Go to the documentation of this file.
00001 
00002 //
00003 // This file is part of the MADELINE 2 program 
00004 // written by Edward H. Trager, Ritu Khanna, and Adrian Marrs
00005 // Copyright (c) 2005 by the
00006 // Regents of the University of Michigan.
00007 // All Rights Reserved.
00008 // 
00009 // The latest version of this program is available from:
00010 // 
00011 //   http://eyegene.ophthy.med.umich.edu/madeline/
00012 //   
00013 // Released under the GNU General Public License.
00014 // A copy of the GPL is included in the distribution
00015 // package of this software, or see:
00016 // 
00017 //   http://www.gnu.org/copyleft/
00018 //   
00019 // ... for licensing details.
00020 // 
00022 //
00023 // 2005.03.10.RK.ET
00024 //
00025 
00026 
00028 
00049 #ifndef NUMBER_INCLUDED
00050 #define NUMBER_INCLUDED
00051 
00052 #include <string>
00053 #include <iostream>
00054 #include <sstream>
00055 #include "Data.h"
00056 
00057 class Number : public Data{
00058 private:
00059 
00060         static std::set<std::string> _numberMissingValue;
00061         
00062         static bool _displayRangeMeans;
00063         
00064         //
00065         // Private Data:
00066         //
00067         bool _isMissing;
00068         double _value;
00069         double _highEndValue;
00070         bool _isApproximate;
00071         bool _isRange;
00072         //
00073         // Private Methods:
00074         //
00075         void _checkSwapLowAndHighValue( void );
00076         inline double _min(double a, double b, double c, double d) const;
00077         inline double _max(double a, double b, double c, double d) const;
00078         inline double _sin(double v) const;
00079         inline double _haldane_cM_To_Theta(double ) const;
00080         inline double _theta_To_Haldane_cM(double ) const;
00081         inline double _kosambi_cM_To_Theta(double ) const;
00082         inline double _theta_To_Kosambi_cM(double ) const;
00083         inline double _lod(double ) const;
00084         bool _differByLessThanMinimum(const Number &b) const;
00085         bool _intersectionIsNotNull(const Number& test) const;
00086         
00087 public:
00088         
00089         friend class Date;
00090         //
00091         // Static methods:
00092         //
00093         static void addNumberMissingValue(std::string value){ _numberMissingValue.insert(value); }
00094         static bool isMissingValue(std::string value);
00095         static void displayRangeMeans(bool);
00096         //
00097         // Public constants:
00098         //
00099         const static double PI;
00100         const static double PI_OVER_TWO;
00101         const static double THREE_PI_OVER_TWO;
00102         const static double TWO_PI;
00103         const static double E;
00104         
00105         const static double NEGATIVE_PI_OVER_TWO;
00106         const static double NEGATIVE_THREE_PI_OVER_TWO;
00107         
00108         const static double SQRT_TWO;
00109         
00110         const static Number MISSING;
00111         
00112         //
00113         // Values which differ by less than _MINIMUM_DIFFERENCE are treated as
00114         // equal:
00115         //
00116         const static double MINIMUM_DIFFERENCE;
00117         
00118         //
00119         // Constructors:
00120         //
00121         
00123         Number(){ _isMissing=true; _value=0; _highEndValue=0;_isApproximate=false; _isRange=false; }
00125         Number( double value , bool isApproximate = false ){ 
00126                 set(value); _isApproximate = isApproximate; 
00127         }
00128         // Construct from char * or std::string:
00129         Number( const char *value ){ set(value); }
00130         Number( const std::string &value ){ set(value.c_str()); }
00131         // Copy construct from a pointer to Number:
00132         Number( const Number *);
00133         
00134         //  Methods required by Data virtual base class:
00135         bool isMissing( void ) const { return _isMissing; }
00136         void setMissing( void );
00137         void set( const std::string &value);
00138         void set( const char *value );
00139         const std::string get( void ) const;
00140         
00141         //
00142         // Additional Setters not present in virtual base class:
00143         //
00144         void set( double value );
00145         bool isApproximate( void ) const { return _isApproximate; }
00146         
00147         
00148         //
00149         // Operators:
00150         // 
00151         Number operator+( const Number &b ) const;
00152         Number& operator+=( const Number &b );
00153         Number& operator++();
00154         Number operator++( int );
00155         Number operator-( const Number &b ) const;
00156         Number& operator-=( const Number &b );
00157         Number& operator--();
00158         Number operator--( int );
00159         Number operator*( const Number &b ) const;
00160         Number& operator*=( const Number &b );
00161         Number operator/( const Number &b ) const;
00162         Number& operator/=( const Number &b );
00163         //
00164         // Trigonometric Functions
00165         //
00166         Number getSin() const;
00167         Number getCos() const;
00168         Number getTan() const;
00169         Number getAsin() const;
00170         Number getAcos() const;
00171         Number getAtan() const;
00172         Number getSinh() const;
00173         Number getCosh() const;
00174         Number getTanh() const;
00175         //
00176         // Numeric functions:
00177         //
00178         Number getFloor() const;
00179         Number getCeiling() const;
00180         Number getRound() const;
00181         Number getExponent() const;
00182         Number getSquareRoot() const;
00183         Number getPower(const Number& b) const;
00184         Number getAbsoluteValue() const;
00185         Number getInverse() const;
00186         Number getLog10() const;
00187         Number getLog() const;
00188         //
00189         // Genetic functions:
00190         //
00191         Number getLod() const;
00192         Number haldaneToTheta() const;
00193         Number thetaToHaldane() const;
00194         Number kosambiToTheta() const;
00195         Number thetaToKosambi() const;
00196         //
00197         // Operators:
00198         //
00199         bool operator==(const Data& b) const; 
00200         bool operator<(const Data& b) const;
00201         bool operator<=(const Number& b) const;
00202         bool operator>=(const Number& b) const;
00203         bool operator!=(const Number& b) const;
00204         bool operator>(const Number& b) const;
00205         
00206         const DATATYPE getDataType( void ) const { return NUMBER; }
00207         virtual Number* clone() const;
00208         
00209         // Determines whether a string is a valid Number string
00210         static bool isA(const std::string& s);
00211         
00212 };
00213 
00214 // ostream insertion << operator for Numbers:
00215 std::ostream& operator<<(std::ostream& s,const Number& n);
00216 
00217 #endif
00218 

Generated on Fri Nov 18 16:24:39 2011 for MADELINE by  doxygen 1.4.4