Utils.h
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-2015 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 
35 #ifndef QPOASES_UTILS_H
36 #define QPOASES_UTILS_H
37 
39 
40 
42 
43 
46 returnValue qpOASES_printV( const real_t* const v,
47  int n
48  );
49 
52 returnValue qpOASES_printPV( const real_t* const v,
53  int n,
54  const int* const V_idx
55  );
56 
59 returnValue qpOASES_printNV( const real_t* const v,
60  int n,
61  const char* name
62  );
63 
66 returnValue qpOASES_printM( const real_t* const M,
67  int nrow,
68  int ncol
69  );
70 
73 returnValue qpOASES_printPM( const real_t* const M,
74  int nrow,
75  int ncol ,
76  const int* const ROW_idx,
77  const int* const COL_idx
78  );
79 
82 returnValue qpOASES_printNM( const real_t* const M,
83  int nrow,
84  int ncol,
85  const char* name
86  );
87 
90 returnValue qpOASES_printI( const int* const _index,
91  int n
92  );
93 
96 returnValue qpOASES_printNI( const int* const _index,
97  int n,
98  const char* name
99  );
100 
101 
104 returnValue qpOASES_myPrintf( const char* s
105  );
106 
107 
111 
112 
118  int nrow,
119  int ncol,
120  const char* datafilename
121  );
122 
128  int n,
129  const char* datafilename
130  );
131 
137  int n,
138  const char* datafilename
139  );
140 
141 
145 returnValue qpOASES_writeIntoFileM( const real_t* const data,
146  int nrow,
147  int ncol,
148  const char* datafilename,
149  BooleanType append
150  );
151 
155 returnValue qpOASES_writeIntoFileV( const real_t* const data,
156  int n,
157  const char* datafilename,
158  BooleanType append
159  );
160 
164 returnValue qpOASES_writeIntoFileI( const int* const integer,
165  int n,
166  const char* datafilename,
167  BooleanType append
168  );
169 
174 returnValue qpOASES_writeIntoMatFile( FILE* const matFile,
175  const real_t* const data,
176  int nRows,
177  int nCols,
178  const char* name
179  );
180 
185 returnValue qpOASES_writeIntoMatFileI( FILE* const matFile,
186  const int* const data,
187  int nRows,
188  int nCols,
189  const char* name
190  );
191 
192 
196 
197 
200 real_t qpOASES_getNorm( const real_t* const v,
201  int n,
202  int type
203  );
204 
208 static inline BooleanType qpOASES_isEqual( real_t x,
209  real_t y,
210  real_t TOL
211  );
212 
213 
217 static inline BooleanType qpOASES_isZero( real_t x,
218  real_t TOL
219  );
220 
221 
225 static inline real_t qpOASES_getSign( real_t arg
226  );
227 
228 
231 static inline int qpOASES_getMaxI( int x,
232  int y
233  );
234 
235 
238 static inline int qpOASES_getMinI( int x,
239  int y
240  );
241 
242 
245 static inline real_t qpOASES_getMax( real_t x,
246  real_t y
247  );
248 
249 
252 static inline real_t qpOASES_getMin( real_t x,
253  real_t y
254  );
255 
256 
259 static inline real_t qpOASES_getAbs( real_t x
260  );
261 
264 static inline real_t qpOASES_getSqrt( real_t x
265  );
266 
267 
271  int nC,
272  const real_t* const H,
273  const real_t* const g,
274  const real_t* const A,
275  const real_t* const lb,
276  const real_t* const ub,
277  const real_t* const lbA,
278  const real_t* const ubA,
279  const real_t* const x,
280  const real_t* const y,
281  real_t* const _stat,
282  real_t* const feas,
283  real_t* const cmpl
284  );
285 
289  const real_t* const H,
290  const real_t* const g,
291  const real_t* const lb,
292  const real_t* const ub,
293  const real_t* const x,
294  const real_t* const y,
295  real_t* const _stat,
296  real_t* const feas,
297  real_t* const cmpl
298  );
299 
300 
304  char* const string
306  );
307 
311  char* const string
313  );
314 
318  char* const string
320  );
321 
322 
332 int qpOASES_getSimpleStatus( returnValue returnvalue,
333  BooleanType doPrintStatus
334  );
335 
340  int nC,
341  real_t* A,
343  real_t* lbA,
345  real_t* ubA,
347  int type
348  );
349 
350 
351 #ifdef __DEBUG__
352 
353 void gdb_printmat( const char *fname,
354  real_t *M,
355  int n,
356  int m,
357  int ldim
358  );
359 #endif /* __DEBUG__ */
360 
361 
362 #if defined(__DSPACE__) || defined(__XPCTARGET__)
363 void __cxa_pure_virtual( void );
364 #endif /* __DSPACE__ || __XPCTARGET__*/
365 
366 
367 
368 /*
369  * i s E q u a l
370  */
372  real_t y,
373  real_t TOL
374  )
375 {
376  if ( qpOASES_getAbs(x-y) <= TOL )
377  return BT_TRUE;
378  else
379  return BT_FALSE;
380 }
381 
382 
383 /*
384  * i s Z e r o
385  */
387  real_t TOL
388  )
389 {
390  if ( qpOASES_getAbs(x) <= TOL )
391  return BT_TRUE;
392  else
393  return BT_FALSE;
394 }
395 
396 
397 /*
398  * g e t S i g n
399  */
400 static inline real_t qpOASES_getSign( real_t arg
401  )
402 {
403  if ( arg >= 0.0 )
404  return 1.0;
405  else
406  return -1.0;
407 }
408 
409 
410 
411 /*
412  * g e t M a x
413  */
414 static inline int qpOASES_getMaxI( int x,
415  int y
416  )
417 {
418  return (y<x) ? x : y;
419 }
420 
421 
422 /*
423  * g e t M i n
424  */
425 static inline int qpOASES_getMinI( int x,
426  int y
427  )
428 {
429  return (y>x) ? x : y;
430 }
431 
432 
433 /*
434  * g e t M a x
435  */
436 static inline real_t qpOASES_getMax( real_t x,
437  real_t y
438  )
439 {
440  #ifdef __NO_FMATH__
441  return (y<x) ? x : y;
442  #else
443  return (y<x) ? x : y;
444  /*return fmax(x,y); seems to be slower */
445  #endif
446 }
447 
448 
449 /*
450  * g e t M i n
451  */
452 static inline real_t qpOASES_getMin( real_t x,
453  real_t y
454  )
455 {
456  #ifdef __NO_FMATH__
457  return (y>x) ? x : y;
458  #else
459  return (y>x) ? x : y;
460  /*return fmin(x,y); seems to be slower */
461  #endif
462 }
463 
464 
465 /*
466  * g e t A b s
467  */
468 static inline real_t qpOASES_getAbs( real_t x
469  )
470 {
471  #ifdef __NO_FMATH__
472  return (x>=0.0) ? x : -x;
473  #else
474  return fabs(x);
475  #endif
476 }
477 
478 /*
479  * g e t S q r t
480  */
481 static inline real_t qpOASES_getSqrt( real_t x
482  )
483 {
484  #ifdef __NO_FMATH__
485  return sqrt(x); /* put your custom sqrt-replacement here */
486  #else
487  return sqrt(x);
488  #endif
489 }
490 
491 
493 
494 
495 #endif /* QPOASES_UTILS_H */
496 
497 
498 /*
499  * end of file
500  */
static real_t qpOASES_getSign(real_t arg)
Definition: Utils.h:400
IntermediateState sqrt(const Expression &arg)
static BooleanType qpOASES_isEqual(real_t x, real_t y, real_t TOL)
Definition: Utils.h:371
returnValue qpOASES_printNV(const real_t *const v, int n, const char *name)
Definition: Utils.c:123
returnValue qpOASES_normaliseConstraints(int nV, int nC, real_t *A, real_t *lbA, real_t *ubA, int type)
returnValue qpOASES_getKktViolation(int nV, int nC, const real_t *const H, const real_t *const g, const real_t *const A, const real_t *const lb, const real_t *const ub, const real_t *const lbA, const real_t *const ubA, const real_t *const x, const real_t *const y, real_t *const _stat, real_t *const feas, real_t *const cmpl)
Definition: Utils.c:658
returnValue qpOASES_writeIntoFileV(const real_t *const data, int n, const char *datafilename, BooleanType append)
Definition: Utils.c:478
BEGIN_NAMESPACE_QPOASES returnValue qpOASES_printV(const real_t *const v, int n)
Definition: Utils.c:70
static real_t qpOASES_getMin(real_t x, real_t y)
Definition: Utils.h:452
returnValue qpOASES_printI(const int *const _index, int n)
Definition: Utils.c:217
int qpOASES_getSimpleStatus(returnValue returnvalue, BooleanType doPrintStatus)
Definition: Utils.c:882
Allows to pass back messages to the calling function.
returnValue qpOASES_printM(const real_t *const M, int nrow, int ncol)
Definition: Utils.c:147
real_t qpOASES_getCPUtime()
Definition: Utils.c:606
returnValue qpOASES_readFromFileV(real_t *data, int n, const char *datafilename)
Definition: Utils.c:367
static BooleanType qpOASES_isZero(real_t x, real_t TOL)
Definition: Utils.h:386
returnValue qpOASES_readFromFileM(real_t *data, int nrow, int ncol, const char *datafilename)
Definition: Utils.c:314
returnValue qpOASES_writeIntoFileI(const int *const integer, int n, const char *datafilename, BooleanType append)
Definition: Utils.c:489
static real_t qpOASES_getAbs(real_t x)
Definition: Utils.h:468
returnValue qpOASES_writeIntoMatFileI(FILE *const matFile, const int *const data, int nRows, int nCols, const char *name)
Definition: Utils.c:587
static int qpOASES_getMinI(int x, int y)
Definition: Utils.h:425
returnValue qpOASES_getKktViolationSB(int nV, const real_t *const H, const real_t *const g, const real_t *const lb, const real_t *const ub, const real_t *const x, const real_t *const y, real_t *const _stat, real_t *const feas, real_t *const cmpl)
Definition: Utils.c:764
static real_t qpOASES_getMax(real_t x, real_t y)
Definition: Utils.h:436
returnValue qpOASES_myPrintf(const char *s)
Definition: Utils.c:269
static real_t qpOASES_getSqrt(real_t x)
Definition: Utils.h:481
returnValue qpOASES_writeIntoFileM(const real_t *const data, int nrow, int ncol, const char *datafilename, BooleanType append)
Definition: Utils.c:423
real_t qpOASES_getNorm(const real_t *const v, int n, int type)
Definition: Utils.c:629
returnValue qpOASES_writeIntoMatFile(FILE *const matFile, const real_t *const data, int nRows, int nCols, const char *name)
Definition: Utils.c:540
#define v
PrintLevel
returnValue qpOASES_printPM(const real_t *const M, int nrow, int ncol, const int *const ROW_idx, const int *const COL_idx)
Definition: Utils.c:170
#define BT_TRUE
Definition: acado_types.hpp:47
returnValue qpOASES_printNM(const real_t *const M, int nrow, int ncol, const char *name)
Definition: Utils.c:192
returnValue qpOASES_printNI(const int *const _index, int n, const char *name)
Definition: Utils.c:244
static int qpOASES_getMaxI(int x, int y)
Definition: Utils.h:414
#define BT_FALSE
Definition: acado_types.hpp:49
returnValue qpOASES_convertPrintLevelToString(PrintLevel value, char *const string)
Definition: Utils.c:840
double real_t
Definition: AD_test.c:10
returnValue qpOASES_readFromFileI(int *data, int n, const char *datafilename)
Definition: Utils.c:379
returnValue qpOASES_printCopyrightNotice()
Definition: Utils.c:296
returnValue qpOASES_convertSubjectToStatusToString(SubjectToStatus value, char *const string)
Definition: Utils.c:798
returnValue qpOASES_convertBooleanTypeToString(BooleanType value, char *const string)
Definition: Utils.c:782
returnValue qpOASES_printPV(const real_t *const v, int n, const int *const V_idx)
Definition: Utils.c:96


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