qpOASES_simulink_utils.cpp
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 
36 #ifndef __SINGLE_OBJECT__
37 #include <qpOASES.hpp>
38 #endif
39 
40 
42 
43 
44 /*
45  * i s N a N
46  */
48 {
49  if ( (( val <= 0.0 ) || ( val >= 0.0 )) == 0 )
50  return BT_TRUE;
51  else
52  return BT_FALSE;
53 }
54 
55 
56 /*
57  * r e m o v e N a N s
58  */
59 returnValue removeNaNs( real_t* const data, unsigned int dim )
60 {
61  unsigned int i;
62 
63  if ( data == 0 )
64  return RET_INVALID_ARGUMENTS;
65 
66  for ( i=0; i<dim; ++i )
67  if ( isNaN(data[i]) == BT_TRUE )
68  data[i] = INFTY;
69 
70  return SUCCESSFUL_RETURN;
71 }
72 
73 
74 /*
75  * r e m o v e I n f s
76  */
77 returnValue removeInfs( real_t* const data, unsigned int dim )
78 {
79  unsigned int i;
80 
81  if ( data == 0 )
82  return RET_INVALID_ARGUMENTS;
83 
84  for ( i=0; i<dim; ++i )
85  {
86  if ( data[i] < -INFTY )
87  data[i] = -INFTY;
88 
89  if ( data[i] > INFTY )
90  data[i] = INFTY;
91  }
92 
93  return SUCCESSFUL_RETURN;
94 }
95 
96 
97 
98 /*
99  * c o n v e r t F o r t r a n T o C
100  */
101 returnValue convertFortranToC( const real_t* const M_for, int nV, int nC, real_t* const M )
102 {
103  int i,j;
104 
105  if ( ( M_for == 0 ) || ( M == 0 ) )
106  return RET_INVALID_ARGUMENTS;
107 
108  if ( ( nV < 0 ) || ( nC < 0 ) )
109  return RET_INVALID_ARGUMENTS;
110 
111  for ( i=0; i<nC; ++i )
112  for ( j=0; j<nV; ++j )
113  M[i*nV + j] = M_for[j*nC + i];
114 
115  return SUCCESSFUL_RETURN;
116 }
117 
118 
119 /*
120  * end of file
121  */
const double INFTY
Allows to pass back messages to the calling function.
#define BT_TRUE
Definition: acado_types.hpp:47
#define BT_FALSE
Definition: acado_types.hpp:49
double real_t
Definition: AD_test.c:10


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