qpOASES-3.2.0/src/Flipper.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 #include <qpOASES/Flipper.hpp>
37 
38 
40 
41 
42 /*****************************************************************************
43  * P U B L I C *
44  *****************************************************************************/
45 
46 
47 /*
48  * F l i p p e r
49  */
51 {
52  R = 0;
53  Q = 0;
54  T = 0;
55 
56  init( );
57 }
58 
59 
60 /*
61  * F l i p p e r
62  */
64  uint_t _nC
65  )
66 {
67  R = 0;
68  Q = 0;
69  T = 0;
70 
71  init( _nV,_nC );
72 }
73 
74 
75 /*
76  * F l i p p e r
77  */
79 {
80  R = 0;
81  Q = 0;
82  T = 0;
83 
84  copy( rhs );
85 }
86 
87 
88 /*
89  * ~ F l i p p e r
90  */
92 {
93  clear( );
94 }
95 
96 
97 /*
98  * o p e r a t o r =
99  */
100 Flipper& Flipper::operator=( const Flipper& rhs )
101 {
102  if ( this != &rhs )
103  {
104  clear( );
105  copy( rhs );
106  }
107 
108  return *this;
109 }
110 
111 
112 
113 /*
114  * i n i t
115  */
117  uint_t _nC
118  )
119 {
120  clear( );
121 
122  nV = _nV;
123  nC = _nC;
124 
125  return SUCCESSFUL_RETURN;
126 }
127 
128 
129 
130 /*
131  * g e t
132  */
133 returnValue Flipper::get( Bounds* const _bounds,
134  real_t* const _R,
135  Constraints* const _constraints,
136  real_t* const _Q,
137  real_t* const _T
138  ) const
139 {
140  if ( _bounds != 0 )
141  *_bounds = bounds;
142 
143  if ( _constraints != 0 )
144  *_constraints = constraints;
145 
146  if ( ( _R != 0 ) && ( R != 0 ) )
147  memcpy( _R,R, nV*nV*sizeof(real_t) );
148 
149  if ( ( _Q != 0 ) && ( Q != 0 ) )
150  memcpy( _Q,Q, nV*nV*sizeof(real_t) );
151 
152  if ( ( _T != 0 ) && ( T != 0 ) )
153  memcpy( _T,T, getDimT()*sizeof(real_t) );
154 
155  return SUCCESSFUL_RETURN;
156 }
157 
158 
159 /*
160  * s e t
161  */
162 returnValue Flipper::set( const Bounds* const _bounds,
163  const real_t* const _R,
164  const Constraints* const _constraints,
165  const real_t* const _Q,
166  const real_t* const _T
167  )
168 {
169  if ( _bounds != 0 )
170  bounds = *_bounds;
171 
172  if ( _constraints != 0 )
173  constraints = *_constraints;
174 
175  if ( _R != 0 )
176  {
177  if ( R == 0 )
178  R = new real_t[nV*nV];
179 
180  memcpy( R,_R, nV*nV*sizeof(real_t) );
181  }
182 
183  if ( _Q != 0 )
184  {
185  if ( Q == 0 )
186  Q = new real_t[nV*nV];
187 
188  memcpy( Q,_Q, nV*nV*sizeof(real_t) );
189  }
190 
191  if ( _T != 0 )
192  {
193  if ( T == 0 )
194  T = new real_t[getDimT()];
195 
196  memcpy( T,_T, getDimT()*sizeof(real_t) );
197  }
198 
199  return SUCCESSFUL_RETURN;
200 }
201 
202 
203 
204 /*****************************************************************************
205  * P R O T E C T E D *
206  *****************************************************************************/
207 
208 /*
209  * c l e a r
210  */
212 {
213  if ( R != 0 )
214  {
215  delete[] R;
216  R = 0;
217  }
218 
219  if ( Q != 0 )
220  {
221  delete[] Q;
222  Q = 0;
223  }
224 
225  if ( T != 0 )
226  {
227  delete[] T;
228  T = 0;
229  }
230 
231  return SUCCESSFUL_RETURN;
232 }
233 
234 
235 /*
236  * c o p y
237  */
239  )
240 {
241  return set( &(rhs.bounds),rhs.R, &(rhs.constraints),rhs.Q,rhs.T );
242 }
243 
244 
245 uint_t Flipper::getDimT( ) const
246 {
247  if ( nV > nC )
248  return nC*nC;
249  else
250  return nV*nV;
251 }
252 
253 
255 
256 
257 /*
258  * end of file
259  */
Allows to pass back messages to the calling function.
returnValue copy(const Flipper &rhs)
Auxiliary class for storing a copy of the current matrix factorisations.
returnValue set(const Bounds *const _bounds, const double *const _R, const Constraints *const _constraints=0, const double *const _Q=0, const double *const _T=0)
void rhs(const real_t *x, real_t *f)
Flipper & operator=(const Flipper &rhs)
Manages working sets of bounds (= box constraints).
double real_t
Definition: AD_test.c:10
returnValue init(int _nV=0, int _nC=0)
returnValue get(Bounds *const _bounds, double *const R, Constraints *const _constraints=0, double *const _Q=0, double *const _T=0) const


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