00001 #ifndef SIMMATH_COMMON_H_
00002 #define SIMMATH_COMMON_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00032 #include "SimTKcommon.h"
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifdef WIN32
00054 #if defined(SimTK_SIMMATH_BUILDING_SHARED_LIBRARY)
00055 #define SimTK_SIMMATH_EXPORT __declspec(dllexport)
00056 #elif defined(SimTK_SIMMATH_BUILDING_STATIC_LIBRARY) || defined(SimTK_USE_STATIC_LIBRARIES)
00057 #define SimTK_SIMMATH_EXPORT
00058 #else
00059
00060 #define SimTK_SIMMATH_EXPORT __declspec(dllimport)
00061 #endif
00062 #else
00063
00064 #define SimTK_SIMMATH_EXPORT
00065 #endif
00066
00067
00068
00069
00070 extern "C" {
00071 SimTK_SIMMATH_EXPORT void SimTK_version_simmath(int* major, int* minor, int* build);
00072 SimTK_SIMMATH_EXPORT void SimTK_about_simmath(const char* key, int maxlen, char* value);
00073 }
00074
00075
00076
00077 const static double POSITIVE_INF = 2e19;
00078 const static double NEGATIVE_INF = -2e19;
00079
00080 namespace SimTK {
00081
00082
00083 namespace Exception {
00084
00085 class OptimizerFailed : public Base {
00086 public:
00087 OptimizerFailed( const char * fn, int ln, String msg) : Base(fn, ln)
00088 {
00089 setMessage("Optimizer failed: " + msg );
00090 }
00091 private:
00092 };
00093
00094 class UnrecognizedParameter : public Base {
00095 public:
00096 UnrecognizedParameter( const char * fn, int ln, String msg) : Base(fn, ln)
00097 {
00098 setMessage("Unrecognized Parameter: " + msg );
00099 }
00100 private:
00101 };
00102
00103 class IllegalLapackArg : public Base {
00104 public:
00105 IllegalLapackArg( const char *fn, int ln, const char *lapackRoutine,
00106 int argNum ) : Base(fn, ln)
00107 {
00108 char buf[1024];
00109
00110 sprintf(buf, "SimTK internal error: %s called with an illegal value to arguement #%d \n Please report this to SimTK",
00111 lapackRoutine, argNum );
00112 setMessage(String(buf));
00113
00114 }
00115 private:
00116 };
00117 class IncorrectArrayLength : public Base {
00118 public:
00119 IncorrectArrayLength( const char *fn, int ln, const char *valueName, int length,
00120 const char *paramName, int paramValue, const char *where) : Base(fn, ln)
00121 {
00122 char buf[1024];
00123
00124 sprintf(buf, "Incorrect array length in %s : %s is %d and must equal %s which is %d",
00125 where, valueName, length, paramName, paramValue );
00126 setMessage(String(buf));
00127
00128 }
00129 private:
00130 };
00131
00132 class SingularMatrix : public Base {
00133 public:
00134 SingularMatrix( const char *fn, int ln, int index,
00135 const char *where) : Base(fn, ln)
00136 {
00137 char buf[1024];
00138
00139 sprintf(buf, "%s failed because index %d in matrix was singular and factorization failed",
00140 where, index );
00141 setMessage(String(buf));
00142
00143 }
00144 private:
00145 };
00146
00147 class ConvergedFailed : public Base {
00148 public:
00149 ConvergedFailed( const char *fn, int ln, const char *algorithm,
00150 const char *where) : Base(fn, ln)
00151 {
00152 char buf[1024];
00153
00154 sprintf(buf, "%s failed because %s failed to converge", where, algorithm );
00155 setMessage(String(buf));
00156
00157 }
00158 private:
00159 };
00160
00161 class NotPositiveDefinite : public Base {
00162 public:
00163 NotPositiveDefinite( const char *fn, int ln, int index,
00164 const char *where) : Base(fn, ln)
00165 {
00166 char buf[1024];
00167
00168 sprintf(buf, "%s failed because index %d in matrix was not positive definite and factorization failed ",
00169 where, index );
00170 setMessage(String(buf));
00171
00172 }
00173 private:
00174 };
00175 }
00176
00177 }
00178
00179 #endif // SIMMATH_COMMON_H_