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 extern "C" {
00027 #include <math.h>
00028 #include <assert.h>
00029 }
00030
00031
00032
00033
00034 #include <iostream>
00035 #include <iomanip>
00036
00037
00038
00039
00040 #include "ProbTools/Consistency.h"
00041 using std::endl;
00042 using std::ios;
00043 using std::ostream;
00044 using std::setiosflags;
00045 using std::setprecision;
00046 using std::setw;
00047
00048
00049
00050
00051
00052
00053
00054 Consistency::Consistency()
00055 : _stat(noMeasure), _value(0), _likelihood(1.), _sign(unknown)
00056 {
00057 }
00058
00059 Consistency::Consistency(double v, double l)
00060 : _stat(OK), _value(v), _likelihood(l), _sign(unknown)
00061 {
00062 }
00063
00064 Consistency::Consistency(const Consistency& rhs)
00065 : _stat(rhs._stat), _value(rhs._value)
00066 , _likelihood(rhs._likelihood), _sign(rhs._sign)
00067 {
00068 }
00069
00070
00071 Consistency&
00072 Consistency::operator=(const Consistency& rhs)
00073 {
00074 if(this != &rhs){
00075 _stat=rhs._stat;
00076 _value=rhs._value;
00077 _likelihood=rhs._likelihood;
00078 _sign=rhs._sign;
00079 }
00080 return *this;
00081 }
00082
00083 bool
00084 Consistency::operator==(const Consistency& rhs) const
00085 {
00086 bool answer = false;
00087 if (_stat == rhs._stat &&
00088 _value == rhs._value &&
00089 _likelihood == rhs._likelihood &&
00090 _sign == rhs._sign) {
00091 answer = true;
00092 }
00093
00094 return answer;
00095 }
00096
00097 bool
00098 Consistency::operator<(const Consistency& rhs) const
00099 {
00100
00101
00102
00103
00104 bool answer = false;
00105 if (_stat == OK && rhs._stat == OK ) {
00106
00107
00108
00109
00110 if (_value < rhs._value) {
00111 answer = true;
00112 }
00113 } else {
00114 if (rhs._stat == OK) {
00115 answer = true;
00116 }
00117 }
00118
00119 return answer;
00120 }
00121
00122 bool
00123 Consistency::operator>(const Consistency& rhs) const
00124 {
00125
00126 if( *this==rhs ) return false;
00127 return( ! (*this<rhs) );
00128 }
00129
00130
00131 const ConsistencySet*
00132 Consistency::genealogy() const
00133 {
00134 return 0;
00135 }
00136
00137
00138 void
00139 Consistency::print(ostream& os) const
00140 {
00141 os << "Likelihood = ";
00142 os << setiosflags(ios::fixed) << setw(7) << setprecision(4);
00143 os << _likelihood;
00144 os << "\t SignificanceLevel = ";
00145 os << setiosflags(ios::fixed) << setw(7) << setprecision(4);
00146 os << _value;
00147 os << "\t Status ";
00148 switch( status() ) {
00149 case Consistency::OK :
00150 os << "OK";
00151 break;
00152 case Consistency::noMeasure :
00153 os << "noMeasure";
00154 break;
00155 case Consistency::underFlow :
00156 os << "underFlow";
00157 break;
00158 case Consistency::unPhysical :
00159 os << "unPhysical";
00160 break;
00161 default:
00162 os << "unknown";
00163 }
00164 os << endl;
00165 }
00166
00167
00168
00169
00170
00171 const Consistency&
00172 Consistency::badMeasurement()
00173 {
00174 static Consistency bad(1.,1.);
00175 bad.setStatus(noMeasure);
00176
00177 return bad;
00178 }