00001 /** 00002 * @file MVTools.h 00003 * Contains helper functions for Vector_n and Matrix_nxn 00004 * 00005 * @author <a href="mailto:stefanuhrig@gmx.net">Stefan Uhrig</a> 00006 */ 00007 //------------------------------------------------------------------------------ 00008 #ifndef MVTOOLS_H_INCLUDED 00009 #define MVTOOLS_H_INCLUDED 00010 //------------------------------------------------------------------------------ 00011 /** 00012 * @class MVException 00013 * Contains information about an excpetion that occured during calculations 00014 */ 00015 class MVException 00016 { 00017 public: 00018 /// type of exception 00019 enum ExceptionType 00020 { 00021 Unknown, 00022 DivByPosZero, 00023 DivByNegZero, 00024 PosInfValue, 00025 NegInfValue, 00026 DetNegative, 00027 DetCloseToZero 00028 }; 00029 00030 MVException() : type(Unknown) {} 00031 MVException(ExceptionType t) : type(t) {} 00032 00033 public: 00034 /** 00035 * Returns a description of the exception 00036 * @return description of exception 00037 */ 00038 const char* getDescription() const; 00039 00040 public: 00041 /// type of exception 00042 ExceptionType type; 00043 }; 00044 //------------------------------------------------------------------------------ 00045 /** 00046 * Several helper functions that returns minimal and maximal values 00047 * of data types. If you want to use Matrix_nxn and Vector_n with your own 00048 * types you have to add the appropriate overloaded functions here. 00049 * The maximal and minimal values should be set to values so that multiplication 00050 * and division of values in the range [minValue;maxValue] can be represented 00051 * by the datatype. 00052 * If you don't care for under/overflows and under/overflows don't cause a crash 00053 * you can set the maximal and minimal values available for the datatype. 00054 */ 00055 namespace MVTools 00056 { 00057 bool isNearZero(double value); 00058 bool isNearPosZero(double value); 00059 bool isNearNegZero(double value); 00060 00061 bool isNearInf(double value); 00062 bool isNearPosInf(double value); 00063 bool isNearNegInf(double value); 00064 00065 double getMaxExpDouble(); 00066 double getMaxPosDouble(); 00067 double getMinPosDouble(); 00068 00069 bool isNearZero(float value); 00070 bool isNearPosZero(float value); 00071 bool isNearNegZero(float value); 00072 00073 bool isNearInf(float value); 00074 bool isNearPosInf(float value); 00075 bool isNearNegInf(float value); 00076 00077 float getMaxExpFloat(); 00078 float getMaxPosFloat(); 00079 float getMinPosFloat(); 00080 00081 bool isNearZero(int value); 00082 bool isNearPosZero(int value); 00083 bool isNearNegZero(int value); 00084 00085 bool isNearInf(int value); 00086 bool isNearPosInf(int value); 00087 bool isNearNegInf(int value); 00088 00089 }; // namespace MVTools 00090 //------------------------------------------------------------------------------ 00091 #endif 00092 //------------------------------------------------------------------------------ 00093 00094 /* 00095 * Change log : 00096 * $Log: MVTools.h,v $ 00097 * Revision 1.2 2004/06/16 17:57:00 nistico 00098 * Speed covariance submatrix dynamically calculated 00099 * based on distance from ball 00100 * More detailed identification of exception 00101 * Bug fixes 00102 * 00103 * Revision 1.1.1.1 2004/05/22 17:37:12 cvsadm 00104 * created new repository GT2004_WM 00105 * 00106 * Revision 1.3 2004/03/15 12:28:52 risler 00107 * change log added 00108 * 00109 * 00110 */