acado_utils.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
36 #ifndef ACADO_TOOLKIT_ACADO_UTILS_HPP
37 #define ACADO_TOOLKIT_ACADO_UTILS_HPP
38 
39 #include <cmath>
40 
47 
48 // A very ugly hack
49 #if (defined __MINGW32__ || defined __MINGW64__)
50 namespace std { namespace tr1 { using namespace std; } }
51 #endif // (defined __MINGW32__ || defined __MINGW64__)
52 
53 #ifndef M_PI
54 #define M_PI 3.14159265358979323846
55 #endif
56 
58 
60 BooleanType acadoIsInteger( double x );
61 
63 double acadoDiv( double nom, double den );
64 
66 double acadoMod( double nom, double den );
67 
69 int acadoMax( const int x, const int y );
70 
72 double acadoMax( const double x, const double y );
73 
75 int acadoMin( const int x, const int y );
76 
78 double acadoMin( const double x, const double y );
79 
85 int acadoFactorial( int n );
86 
88 BooleanType acadoIsEqual( double x, double y, double TOL = EQUALITY_EPS );
89 
91 BooleanType acadoIsGreater( double x, double y, double TOL = EQUALITY_EPS );
92 
94 BooleanType acadoIsSmaller( double x, double y, double TOL = EQUALITY_EPS );
95 
97 BooleanType acadoIsStrictlyGreater( double x, double y, double TOL = EQUALITY_EPS );
98 
100 BooleanType acadoIsStrictlySmaller( double x, double y, double TOL = EQUALITY_EPS );
101 
103 BooleanType acadoIsPositive( double x, double TOL = EQUALITY_EPS );
104 
106 BooleanType acadoIsNegative( double x, double TOL = EQUALITY_EPS );
107 
109 BooleanType acadoIsZero( double x, double TOL = EQUALITY_EPS );
110 
112 BooleanType acadoIsInfty( double x, double TOL = 0.1 );
113 
115 BooleanType acadoIsFinite( double x, double TOL = 0.1 );
116 
118 template<class T>
119 BooleanType isFinite( const T& _value )
120 {
121  for (unsigned el = 0; el < _value.size(); ++el)
122  if ( acadoIsFinite( _value[ el ] ) == BT_TRUE )
123  return BT_TRUE;
124  return BT_FALSE;
125 }
126 
128 BooleanType acadoIsNaN( double x );
129 
131 inline BooleanType isInfty(const double x)
132 {
133  if (x - 10.0 < -INFTY)
134  return BT_TRUE;
135 
136  if (x + 10.0 > INFTY)
137  return BT_TRUE;
138 
139  return BT_FALSE;
140 }
141 
145 int acadoRound (double x);
146 
148 int acadoRoundAway (double x);
149 
150 
152 
153 #endif // ACADO_TOOLKIT_ACADO_UTILS_HPP
154 
155 /*
156  * end of file
157  */
BooleanType acadoIsZero(double x, double TOL=EQUALITY_EPS)
BEGIN_NAMESPACE_ACADO BooleanType acadoIsInteger(double x)
Definition: acado_utils.cpp:37
USING_NAMESPACE_ACADO typedef TaylorVariable< Interval > T
BooleanType acadoIsEqual(double x, double y, double TOL=EQUALITY_EPS)
Definition: acado_utils.cpp:88
BooleanType acadoIsFinite(double x, double TOL=0.1)
const double INFTY
int acadoRoundAway(double x)
int acadoRound(double x)
BooleanType acadoIsStrictlyGreater(double x, double y, double TOL=EQUALITY_EPS)
double acadoMod(double nom, double den)
Definition: acado_utils.cpp:55
int acadoFactorial(int n)
#define CLOSE_NAMESPACE_ACADO
int acadoMin(const int x, const int y)
Definition: acado_utils.cpp:76
BooleanType acadoIsNegative(double x, double TOL=EQUALITY_EPS)
BooleanType acadoIsGreater(double x, double y, double TOL=EQUALITY_EPS)
BooleanType acadoIsSmaller(double x, double y, double TOL=EQUALITY_EPS)
BooleanType acadoIsPositive(double x, double TOL=EQUALITY_EPS)
BooleanType acadoIsInfty(double x, double TOL=0.1)
BooleanType isInfty(const double x)
int acadoMax(const int x, const int y)
Definition: acado_utils.cpp:64
#define BT_TRUE
Definition: acado_types.hpp:47
const double EQUALITY_EPS
#define BEGIN_NAMESPACE_ACADO
BooleanType acadoIsStrictlySmaller(double x, double y, double TOL=EQUALITY_EPS)
BooleanType isFinite(const T &_value)
#define BT_FALSE
Definition: acado_types.hpp:49
double acadoDiv(double nom, double den)
Definition: acado_utils.cpp:46
BooleanType acadoIsNaN(double x)


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:27