matrix_variable.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
35 
36 
37 
39 
40 
41 
42 //
43 // PUBLIC MEMBER FUNCTIONS:
44 //
45 
47 {
48 }
49 
50 
52  uint _nCols,
53  VariableType _type,
54  const char** const _names,
55  const char** const _units,
56  DVector _scaling,
57  DVector _lb,
58  DVector _ub,
59  BooleanType _autoInit
60  ) : DMatrix( _nRows,_nCols ), VariableSettings( _nRows*_nCols,_type,_names,_units,_scaling,_lb,_ub,_autoInit )
61 {
62 }
63 
64 
66 {
67 }
68 
69 
71  VariableType _type
72  ) : DMatrix( _matrix ), VariableSettings( _matrix.getDim(),_type )
73 {
74 }
75 
76 
78 {
79 }
80 
81 
83 {
84  if ( this != &rhs )
85  {
87  DMatrix::operator=( rhs );
88  }
89 
90  return *this;
91 }
92 
93 
95 {
96  if ( this != &rhs )
97  {
99  DMatrix::operator=( rhs );
100  }
101 
102  return *this;
103 }
104 
105 
106 
108  uint _nCols,
109  VariableType _type,
110  const char** const _names,
111  const char** const _units,
112  DVector _scaling,
113  DVector _lb,
114  DVector _ub,
115  BooleanType _autoInit
116  )
117 {
118  DMatrix::init( _nRows,_nCols );
119 
120  if ( VariableSettings::init( _nRows*_nCols,_type,_names,_units,_scaling,_lb,_ub,_autoInit ) != SUCCESSFUL_RETURN )
121  return ACADOERROR( RET_UNKNOWN_BUG );
122 
123  return SUCCESSFUL_RETURN;
124 }
125 
126 
127 
129  uint endIdx
130  ) const
131 {
132  MatrixVariable newMatrixVariable;
133 
134  if ( ( startIdx >= getNumRows( ) ) || ( endIdx >= getNumRows( ) ) )
135  return newMatrixVariable;
136 
137  if ( startIdx > endIdx )
138  return newMatrixVariable;
139 
140  newMatrixVariable.init( endIdx-startIdx+1,getNumCols() );
141  newMatrixVariable.operator=( DMatrix::getRows( startIdx,endIdx ) );
142  // needs to be implemented for VariableSettings!!
143 
144  return newMatrixVariable;
145 }
146 
147 
149  uint endIdx
150  ) const
151 {
152  MatrixVariable newMatrixVariable;
153 
154  if ( ( startIdx >= getNumCols( ) ) || ( endIdx >= getNumCols( ) ) )
155  return newMatrixVariable;
156 
157  if ( startIdx > endIdx )
158  return newMatrixVariable;
159 
160 
161  newMatrixVariable.init( getNumRows(),endIdx-startIdx+1 );
162  newMatrixVariable.operator=( DMatrix::getCols( startIdx,endIdx ) );
163  // needs to be implemented for VariableSettings!!
164 
165  return newMatrixVariable;
166 }
167 
168 
169 //
170 // PROTECTED MEMBER FUNCTIONS:
171 //
172 
173 
174 
176 
177 
178 /*
179  * end of file
180  */
void init(unsigned _nRows=0, unsigned _nCols=0)
Definition: matrix.hpp:135
MatrixVariable getCols(uint startIdx, uint endIdx) const
Allows to pass back messages to the calling function.
MatrixVariable & operator=(const MatrixVariable &rhs)
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
#define CLOSE_NAMESPACE_ACADO
VariableType
Definition: acado_types.hpp:95
GenericMatrix getCols(unsigned _start, unsigned _end) const
Definition: matrix.hpp:246
VariableSettings & operator=(const VariableSettings &rhs)
returnValue init(uint _nRows, uint _nCols, VariableType _type=VT_UNKNOWN, const char **const _names=0, const char **const _units=0, DVector _scaling=emptyVector, DVector _lb=emptyVector, DVector _ub=emptyVector, BooleanType _autoInit=defaultAutoInit)
unsigned getDim() const
Definition: matrix.hpp:181
Provides matrix-valued optimization variables.
Provides variable-specific settings for vector- or matrix-valued optimization variables (for internal...
void rhs(const real_t *x, real_t *f)
unsigned getNumRows() const
Definition: matrix.hpp:185
MatrixVariable getRows(uint startIdx, uint endIdx) const
EIGEN_STRONG_INLINE Matrix & operator=(const Matrix &other)
Assigns matrices to each other.
Definition: Matrix.h:154
unsigned getNumCols() const
Definition: matrix.hpp:189
#define BEGIN_NAMESPACE_ACADO
GenericMatrix getRows(unsigned _start, unsigned _end) const
Definition: matrix.hpp:235
#define ACADOERROR(retval)


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