acado_utils.hpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
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 // A very ugly hack
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  *      end of file
00157  */


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:57:48