00001
00011 #ifndef __ERROR_H__
00012 #define __ERROR_H__
00013
00014 #include <gsl/gsl_errno.h>
00015 #include <string>
00016
00018 namespace error_handling{
00019
00020 using std::string;
00021
00023 class error{
00024 public:
00025 std::string reason, file;
00026 int line;
00027 error(){};
00028 error(string r, string f, int l) :
00029 reason(r), file(f), line(l) {};
00030
00031 };
00032
00033 struct noConvergence ;
00034 struct badDomain ;
00035 struct badRange ;
00036 struct badPointer ;
00037 struct badArgument ;
00038 struct failure ;
00039 struct failedFactorisation ;
00040 struct failedSanity ;
00041 struct outOfMemory ;
00042 struct badFunction ;
00043 struct runAway ;
00044 struct maxIterations ;
00045 struct divideByZero ;
00046 struct badTolerance ;
00047 struct aboveTolerance ;
00048 struct underflow ;
00049 struct overflow ;
00050 struct lossOfAccuracy ;
00051 struct roundOffError ;
00052 struct inconformantSizes ;
00053 struct matrixNotSquare ;
00054 struct singularityFound ;
00055 struct integralOrSeriesDivergent ;
00056 struct badHardware ;
00057 struct notImplemented ;
00058 struct cacheLimitExceeded ;
00059 struct tableLimitExceeded ;
00060 struct iterationNotProgressing ;
00061 struct jacobiansNotImprovingSolution ;
00062
00063 struct cannotReachToleranceInF ;
00064 struct cannotReachToleranceInX ;
00065 struct cannotReachToleranceInGradient ;
00066 struct endOfFile ;
00067
00076 void errorHandler(const char * reason, const char * file,
00077 int line, int gsl_errno);
00078 }
00079
00080
00081
00082 namespace error_handling{
00083 using std::string;
00084
00086 struct noConvergence : public error {
00087 noConvergence() {};
00088 noConvergence(string r, string f, int l) :
00089 error(r,f,l) {};
00090 };
00091
00093 struct badDomain : public error {
00094 badDomain() {};
00095 badDomain(string r, string f, int l) :
00096 error(r,f,l) {};
00097 };
00098
00100 struct badRange : public error {
00101 badRange() {};
00102 badRange(string r, string f, int l) :
00103 error(r,f,l) {};
00104 };
00105
00107 struct badPointer : public error {
00108 badPointer() {};
00109 badPointer(string r, string f, int l) :
00110 error(r,f,l) {};
00111 };
00112
00114 struct badArgument : public error {
00115 badArgument() {};
00116 badArgument(string r, string f, int l) :
00117 error(r,f,l) {};
00118 };
00119
00121 struct failure : public error {
00122 failure() {};
00123 failure(string r, string f, int l) :
00124 error(r,f,l) {};
00125 };
00126
00128 struct failedFactorisation : public error {
00129 failedFactorisation() {};
00130 failedFactorisation(string r, string f, int l) :
00131 error(r,f,l) {};
00132 };
00133
00135 struct failedSanity : public error {
00136 failedSanity() {};
00137 failedSanity(string r, string f, int l) :
00138 error(r,f,l) {};
00139 };
00140
00142 struct outOfMemory : public error {
00143 outOfMemory() {};
00144 outOfMemory(string r, string f, int l) :
00145 error(r,f,l) {};
00146 };
00147
00149 struct badFunction : public error {
00150 badFunction() {};
00151 badFunction(string r, string f, int l) :
00152 error(r,f,l) {};
00153 };
00154
00156 struct runAway : public error {
00157 runAway() {};
00158 runAway(string r, string f, int l) :
00159 error(r,f,l) {};
00160 };
00161
00163 struct maxIterations : public error {
00164 maxIterations() {};
00165 maxIterations(string r, string f, int l) :
00166 error(r,f,l) {};
00167 };
00168
00170 struct divideByZero : public error {
00171 divideByZero() {};
00172 divideByZero(string r, string f, int l) :
00173 error(r,f,l) {};
00174 };
00175
00177 struct badTolerance : public error {
00178 badTolerance() {};
00179 badTolerance(string r, string f, int l) :
00180 error(r,f,l) {};
00181 };
00182
00184 struct aboveTolerance : public error {
00185 aboveTolerance() {};
00186 aboveTolerance(string r, string f, int l) :
00187 error(r,f,l) {};
00188 };
00189
00191 struct underflow : public error {
00192 underflow() {};
00193 underflow(string r, string f, int l) :
00194 error(r,f,l) {};
00195 };
00196
00198 struct overflow : public error {
00199 overflow() {};
00200 overflow(string r, string f, int l) :
00201 error(r,f,l) {};
00202 };
00203
00205 struct lossOfAccuracy : public error {
00206 lossOfAccuracy() {};
00207 lossOfAccuracy(string r, string f, int l) :
00208 error(r,f,l) {};
00209 };
00210
00212 struct roundOffError : public error {
00213 roundOffError() {};
00214 roundOffError(string r, string f, int l) :
00215 error(r,f,l) {};
00216 };
00217
00219 struct inconformantSizes : public error {
00220 inconformantSizes() {};
00221 inconformantSizes(string r, string f, int l) :
00222 error(r,f,l) {};
00223 int n_A, m_A, n_B, m_B;
00224 };
00225
00227 struct matrixNotSquare : public error {
00228 matrixNotSquare() {};
00229 matrixNotSquare(string r, string f, int l) :
00230 error(r,f,l) {};
00231 };
00232
00234 struct singularityFound : public error {
00235 singularityFound() {};
00236 singularityFound(string r, string f, int l) :
00237 error(r,f,l) {};
00238 };
00239
00241 struct integralOrSeriesDivergent : public error {
00242 integralOrSeriesDivergent() {};
00243 integralOrSeriesDivergent(string r, string f, int l) :
00244 error(r,f,l) {};
00245 };
00246
00248 struct badHardware : public error {
00249 badHardware() {};
00250 badHardware(string r, string f, int l) :
00251 error(r,f,l) {};
00252 };
00253
00255 struct notImplemented : public error {
00256 notImplemented() {};
00257 notImplemented(string r, string f, int l) :
00258 error(r,f,l) {};
00259 };
00260
00262 struct cacheLimitExceeded : public error {
00263 cacheLimitExceeded() {};
00264 cacheLimitExceeded(string r, string f, int l) :
00265 error(r,f,l) {};
00266 };
00267
00269 struct tableLimitExceeded : public error {
00270 tableLimitExceeded() {};
00271 tableLimitExceeded(string r, string f, int l) :
00272 error(r,f,l) {};
00273 };
00274
00276 struct iterationNotProgressing : public error {
00277 iterationNotProgressing() {};
00278 iterationNotProgressing(string r, string f, int l) :
00279 error(r,f,l) {};
00280 };
00281
00283 struct jacobiansNotImprovingSolution : public error {
00284 jacobiansNotImprovingSolution() {};
00285 jacobiansNotImprovingSolution(string r, string f, int l) :
00286 error(r,f,l) {};
00287 };
00288
00290 struct cannotReachToleranceInF : public error {
00291 cannotReachToleranceInF() {};
00292 cannotReachToleranceInF(string r, string f, int l) :
00293 error(r,f,l) {};
00294 };
00295
00297 struct cannotReachToleranceInX : public error {
00298 cannotReachToleranceInX() {};
00299 cannotReachToleranceInX(string r, string f, int l) :
00300 error(r,f,l) {};
00301 };
00302
00304 struct cannotReachToleranceInGradient : public error {
00305 cannotReachToleranceInGradient() {};
00306 cannotReachToleranceInGradient(string r, string f, int l) :
00307 error(r,f,l) {};
00308 };
00309
00311 struct endOfFile : public error {
00312 endOfFile() {};
00313 endOfFile(string r, string f, int l) :
00314 error(r,f,l) {};
00315 };
00316
00318 struct indexOutOfRange : public badArgument{
00319 int i,j,m,n;
00320 indexOutOfRange() {};
00321 indexOutOfRange(string r, string f, int l) :
00322 badArgument(r,f,l) {};
00323 };
00324 }
00325
00326 #endif //__ERROR_H__