Institut de Robòtica i Informàtica Industrial
KRD Group

The CuikSuite Project

defines.h

Go to the documentation of this file.
00001 #ifndef DEFINESH
00002 #define DEFINESH
00003 
00004 #include "error.h" /*The NEW macros call error()*/
00005 #include <stdlib.h> /*The NEW macros call malloc,..*/
00006 
00007 #include <fenv.h> /*FPU control*/
00008 
00017 /************************************************************************************/
00018 /************************************************************************************/
00036 #define ZERO 1e-11
00037 
00038 #if (_SIMPLEX_ENGINE==_CLP)
00039   #include <Clp/Coin_C_defines.h>
00040   #include <float.h>
00045   #define INF COIN_DBL_MAX
00046 #else
00047 
00051   #define INF 1e4
00052 #endif
00053 
00054 #ifndef M_PI
00055 
00059   #define M_PI 3.14159265358979323846
00060 #endif
00061 
00062 
00063 #ifndef M_PI_2
00064 
00068   #define M_PI_2 1.57079632679489661923
00069 #endif
00070 
00071 #ifndef M_2PI
00072 
00076   #define M_2PI (2.0*M_PI)
00077 #endif
00078 
00079 /************************************************************************************/
00080 /************************************************************************************/
00085 #define DEG2RAD (M_PI/180.0)
00086 
00091 #define RAD2DEG (180.0/M_PI)
00092 
00093 /************************************************************************************/
00094 /************************************************************************************/
00099 #define SGN(a) (a>=0?1:-1)
00100 
00101 /************************************************************************************/
00102 /************************************************************************************/
00107 #define ROUNDUP   fesetround(FE_UPWARD)
00108 
00113 #define ROUNDDOWN fesetround(FE_DOWNWARD) 
00114 
00119 #define ROUNDNEAR fesetround(FE_TONEAREST)
00120 
00121 /************************************************************************************/
00122 /************************************************************************************/
00128 #define NEW(_var,_n,_type) {(_var)=(_type *)malloc(sizeof(_type)*(_n)); \
00129                             if (!(_var)) Error("Memory allocation error");}
00130 
00137 #define MEM_EXPAND(_var,_n,_type) {(_var)=(_type *)realloc((void *)(_var),sizeof(_type)*(_n)); \
00138                                    if (!(_var)) Error("Memory reallocation error");}
00139 
00147 #define MEM_DUP(_var,_n,_type) {(_n)*=2;MEM_EXPAND(_var,_n,_type);}
00148 
00149 /************************************************************************************/
00150 /************************************************************************************/
00160 #define PRINT_VARIABLE_NAME(f,name) if (name[0]=='_') fprintf(f,"%s",&(name[1])); else  fprintf(f,"%s",name)
00161 
00162 /************************************************************************************/
00163 /************************************************************************************/
00168 #define NO_UINT ((unsigned int)(-1))
00169 
00170 /************************************************************************************/
00171 /************************************************************************************/
00172 
00173 #endif