Go to the documentation of this file.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
00036 #ifndef ACADO_TOOLKIT_ACADO_UTILS_HPP
00037 #define ACADO_TOOLKIT_ACADO_UTILS_HPP
00038
00039 #include <cmath>
00040
00041 #include <acado/utils/acado_types.hpp>
00042 #include <acado/utils/acado_constants.hpp>
00043 #include <acado/utils/acado_default_options.hpp>
00044 #include <acado/utils/acado_message_handling.hpp>
00045 #include <acado/utils/acado_debugging.hpp>
00046 #include <acado/utils/acado_io_utils.hpp>
00047
00048
00049 #if (defined __MINGW32__ || defined __MINGW64__)
00050 namespace std { namespace tr1 { using namespace std; } }
00051 #endif // (defined __MINGW32__ || defined __MINGW64__)
00052
00053 #ifndef M_PI
00054 #define M_PI 3.14159265358979323846
00055 #endif
00056
00057 BEGIN_NAMESPACE_ACADO
00058
00060 BooleanType acadoIsInteger( double x );
00061
00063 double acadoDiv( double nom, double den );
00064
00066 double acadoMod( double nom, double den );
00067
00069 int acadoMax( const int x, const int y );
00070
00072 double acadoMax( const double x, const double y );
00073
00075 int acadoMin( const int x, const int y );
00076
00078 double acadoMin( const double x, const double y );
00079
00085 int acadoFactorial( int n );
00086
00088 BooleanType acadoIsEqual( double x, double y, double TOL = EQUALITY_EPS );
00089
00091 BooleanType acadoIsGreater( double x, double y, double TOL = EQUALITY_EPS );
00092
00094 BooleanType acadoIsSmaller( double x, double y, double TOL = EQUALITY_EPS );
00095
00097 BooleanType acadoIsStrictlyGreater( double x, double y, double TOL = EQUALITY_EPS );
00098
00100 BooleanType acadoIsStrictlySmaller( double x, double y, double TOL = EQUALITY_EPS );
00101
00103 BooleanType acadoIsPositive( double x, double TOL = EQUALITY_EPS );
00104
00106 BooleanType acadoIsNegative( double x, double TOL = EQUALITY_EPS );
00107
00109 BooleanType acadoIsZero( double x, double TOL = EQUALITY_EPS );
00110
00112 BooleanType acadoIsInfty( double x, double TOL = 0.1 );
00113
00115 BooleanType acadoIsFinite( double x, double TOL = 0.1 );
00116
00118 template<class T>
00119 BooleanType isFinite( const T& _value )
00120 {
00121 for (unsigned el = 0; el < _value.size(); ++el)
00122 if ( acadoIsFinite( _value[ el ] ) == BT_TRUE )
00123 return BT_TRUE;
00124 return BT_FALSE;
00125 }
00126
00128 BooleanType acadoIsNaN( double x );
00129
00131 inline BooleanType isInfty(const double x)
00132 {
00133 if (x - 10.0 < -INFTY)
00134 return BT_TRUE;
00135
00136 if (x + 10.0 > INFTY)
00137 return BT_TRUE;
00138
00139 return BT_FALSE;
00140 }
00141
00145 int acadoRound (double x);
00146
00148 int acadoRoundAway (double x);
00149
00150
00151 CLOSE_NAMESPACE_ACADO
00152
00153 #endif // ACADO_TOOLKIT_ACADO_UTILS_HPP
00154
00155
00156
00157