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