qpOASES 3.2.1
An Implementation of the Online Active Set Strategy
Utils.ipp
Go to the documentation of this file.
1/*
2 * This file is part of qpOASES.
3 *
4 * qpOASES -- An Implementation of the Online Active Set Strategy.
5 * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka,
6 * Christian Kirches et al. All rights reserved.
7 *
8 * qpOASES is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * qpOASES is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with qpOASES; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 */
23
24
25
36#include <math.h>
37
38
40
41
42/*
43 * i s E q u a l
44 */
46 real_t y,
47 real_t TOL
48 )
49{
50 if ( getAbs(x-y) <= TOL )
51 return BT_TRUE;
52 else
53 return BT_FALSE;
54}
55
56
57/*
58 * i s Z e r o
59 */
61 real_t TOL
62 )
63{
64 if ( getAbs(x) <= TOL )
65 return BT_TRUE;
66 else
67 return BT_FALSE;
68}
69
70
71/*
72 * g e t S i g n
73 */
75 )
76{
77 if ( arg >= 0.0 )
78 return 1.0;
79 else
80 return -1.0;
81}
82
83
84
85/*
86 * g e t M a x
87 */
88inline int_t getMax( int_t x,
89 int_t y
90 )
91{
92 return (y<x) ? x : y;
93}
94
95
96/*
97 * g e t M i n
98 */
99inline int_t getMin( int_t x,
100 int_t y
101 )
102{
103 return (y>x) ? x : y;
104}
105
106
107
108/*
109 * g e t M a x
110 */
112 real_t y
113 )
114{
115 #ifdef __NO_FMATH__
116 return (y<x) ? x : y;
117 #else
118 return (y<x) ? x : y;
119 //return fmax(x,y); /* seems to be slower */
120 #endif
121}
122
123
124/*
125 * g e t M i n
126 */
128 real_t y
129 )
130{
131 #ifdef __NO_FMATH__
132 return (y>x) ? x : y;
133 #else
134 return (y>x) ? x : y;
135 //return fmin(x,y); /* seems to be slower */
136 #endif
137}
138
139
140/*
141 * g e t A b s
142 */
144 )
145{
146 #ifdef __NO_FMATH__
147 return (x>=0.0) ? x : -x;
148 #else
149 return fabs(x);
150 #endif
151}
152
153
154/*
155 * g e t S q r t
156 */
158 )
159{
160 #ifdef __NO_FMATH__
161 return sqrt(x); /* put your custom sqrt-replacement here */
162 #else
163 return sqrt(x);
164 #endif
165}
166
167
168
170
171
172/*
173 * end of file
174 */
BooleanType
Definition Types.hpp:204
@ BT_TRUE
Definition Types.hpp:206
@ BT_FALSE
Definition Types.hpp:205
int int_t
Definition Types.hpp:180
BEGIN_NAMESPACE_QPOASES typedef double real_t
Definition Types.hpp:171
#define END_NAMESPACE_QPOASES
Definition Types.hpp:110
#define BEGIN_NAMESPACE_QPOASES
Definition Types.hpp:107
real_t getSqrt(real_t x)
Definition Utils.ipp:157
int_t getMin(int_t x, int_t y)
Definition Utils.ipp:99
real_t getSign(real_t arg)
Definition Utils.ipp:74
BEGIN_NAMESPACE_QPOASES BooleanType isEqual(real_t x, real_t y, real_t TOL)
Definition Utils.ipp:45
int_t getMax(int_t x, int_t y)
Definition Utils.ipp:88
BooleanType isZero(real_t x, real_t TOL)
Definition Utils.ipp:60
real_t getAbs(real_t x)
Definition Utils.ipp:143