export_variable.hpp
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 
31 #ifndef ACADO_TOOLKIT_EXPORT_VARIABLE_HPP
32 #define ACADO_TOOLKIT_EXPORT_VARIABLE_HPP
33 
37 
39 
42 
59 {
60  //
61  // PUBLIC MEMBER FUNCTIONS:
62  //
63  public:
64 
67 
78  ExportVariable( const std::string& _name,
79  uint _nRows,
80  uint _nCols,
81  ExportType _type = REAL,
82  ExportStruct _dataStruct = ACADO_LOCAL,
83  bool _callItByValue = false,
84  const std::string& _prefix = std::string()
85  );
86 
97  ExportVariable( const std::string& _name,
98  const DMatrix& _data,
99  ExportType _type = REAL,
100  ExportStruct _dataStruct = ACADO_LOCAL,
101  bool _callItByValue = false,
102  const std::string& _prefix = std::string(),
103  bool _isGiven = true
104  );
105 
116  ExportVariable( const std::string& _name,
117  const DMatrixPtr& _data,
118  ExportType _type = REAL,
119  ExportStruct _dataStruct = ACADO_LOCAL,
120  bool _callItByValue = false,
121  const std::string& _prefix = std::string()
122  );
123 
133  ExportVariable( unsigned _nRows,
134  unsigned _nCols,
135  ExportType _type = REAL,
136  ExportStruct _dataStruct = ACADO_LOCAL,
137  bool _callItByValue = false,
138  const std::string& _prefix = std::string()
139  );
140 
144  template<typename Derived>
146  )
147  {
148  simpleForward(DMatrix( _data ));
149  }
150 
151  ExportVariable( const double _data
152  );
157  virtual ~ExportVariable( );
158 
159  ExportVariable clone() const;
160 
162 
163  const ExportVariableInternal* operator->() const;
164 
177  ExportVariable& setup( const std::string& _name,
178  uint _nRows = 1,
179  uint _nCols = 1,
180  ExportType _type = REAL,
181  ExportStruct _dataStruct = ACADO_LOCAL,
182  bool _callItByValue = false,
183  const std::string& _prefix = std::string()
184  );
185 
198  ExportVariable& setup( const std::string& _name,
199  const DMatrix& _data,
200  ExportType _type = REAL,
201  ExportStruct _dataStruct = ACADO_LOCAL,
202  bool _callItByValue = false,
203  const std::string& _prefix = std::string(),
204  bool _isGiven = true
205  );
206 
214  double operator()( uint rowIdx,
215  uint colIdx
216  ) const;
217 
224  double operator()( uint totalIdx
225  ) const;
226 
235  bool isZero( const ExportIndex& rowIdx,
236  const ExportIndex& colIdx
237  ) const;
238 
247  bool isOne( const ExportIndex& rowIdx,
248  const ExportIndex& colIdx
249  ) const;
250 
259  bool isGiven( const ExportIndex& rowIdx,
260  const ExportIndex& colIdx
261  ) const;
262 
268  bool isGiven( ) const;
269 
270 
279  const std::string get( const ExportIndex& rowIdx,
280  const ExportIndex& colIdx
281  ) const;
282 
287  virtual uint getNumRows( ) const;
288 
293  virtual uint getNumCols( ) const;
294 
299  virtual uint getDim( ) const;
300 
301 
309  const ExportVariable& arg2
310  );
311 
319  const ExportVariable& arg2
320  );
321 
329  const ExportVariable& arg2
330  );
331 
339  const ExportVariable& arg2
340  );
341 
349  const ExportVariable& arg2
350  );
351 
359  const ExportVariable& arg2
360  );
361 
369  const ExportVariable& arg2
370  );
371 
379  ) const;
380 
388  ) const;
389 
397  ) const;
398 
406  ) const;
407 
415  ) const;
416 
421  ExportVariable getTranspose( ) const;
422 
429  ExportVariable getRow( const ExportIndex& idx
430  ) const;
431 
438  ExportVariable getCol( const ExportIndex& idx
439  ) const;
440 
448  ExportVariable getRows( const ExportIndex& idx1,
449  const ExportIndex& idx2
450  ) const;
451 
459  ExportVariable getCols( const ExportIndex& idx1,
460  const ExportIndex& idx2
461  ) const;
462 
472  ExportVariable getSubMatrix( const ExportIndex& rowIdx1,
473  const ExportIndex& rowIdx2,
474  const ExportIndex& colIdx1,
475  const ExportIndex& colIdx2
476  ) const;
477 
485  ExportVariable getElement( const ExportIndex& rowIdx,
486  const ExportIndex& colIdx
487  ) const;
488 
493  ExportVariable makeRowVector( ) const;
494 
499  ExportVariable makeColVector( ) const;
500 
501 
507  bool isVector( ) const;
508 
509 
514  const DMatrix& getGivenMatrix( ) const;
515 
517  bool isSubMatrix() const;
518 
520  bool isDiagonal() const;
521 
526  returnValue print( ) const;
527 
528  private:
529  void simpleForward(const DMatrix& _value);
530 };
531 
533 
535 
536 #endif // ACADO_TOOLKIT_EXPORT_VARIABLE_HPP
bool isDiagonal() const
bool isSubMatrix() const
ExportVariable getRow(const ExportIndex &idx) const
ExportVariableInternal * operator->()
ExportVariable clone() const
ExportVariable getTranspose() const
ExportVariable & setup(const std::string &_name, uint _nRows=1, uint _nCols=1, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callItByValue=false, const std::string &_prefix=std::string())
bool isOne(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
Allows to pass back messages to the calling function.
std::shared_ptr< GenericMatrix< double > > DMatrixPtr
Definition: matrix.hpp:463
friend ExportArithmeticStatement operator+=(const ExportVariable &arg1, const ExportVariable &arg2)
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
const DMatrix & getGivenMatrix() const
ExportVariable getElement(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
Defines a matrix-valued variable to be used for exporting code.
#define CLOSE_NAMESPACE_ACADO
void simpleForward(const DMatrix &_value)
ExportVariable getSubMatrix(const ExportIndex &rowIdx1, const ExportIndex &rowIdx2, const ExportIndex &colIdx1, const ExportIndex &colIdx2) const
GenericMatrix< double > DMatrix
Definition: matrix.hpp:457
Defines a scalar-valued index variable to be used for exporting code.
Defines a matrix-valued variable that can be passed as argument to exported functions.
Allows to export code of different arithmetic statements.
virtual ~ExportVariable()
friend ExportArithmeticStatement operator-=(const ExportVariable &arg1, const ExportVariable &arg2)
friend ExportArithmeticStatement operator^(const ExportVariable &arg1, const ExportVariable &arg2)
ExportStruct
static const ExportVariable emptyConstExportVariable
double operator()(uint rowIdx, uint colIdx) const
ExportVariable getCols(const ExportIndex &idx1, const ExportIndex &idx2) const
friend ExportArithmeticStatement operator+(const ExportVariable &arg1, const ExportVariable &arg2)
ExportVariable makeRowVector() const
ExportVariable(const Eigen::MatrixBase< Derived > &_data)
ExportType
friend ExportArithmeticStatement operator==(const ExportVariable &arg1, const ExportVariable &arg2)
virtual uint getDim() const
bool isZero(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
bool isVector() const
bool isGiven() const
virtual uint getNumCols() const
ExportVariable getRows(const ExportIndex &idx1, const ExportIndex &idx2) const
#define BEGIN_NAMESPACE_ACADO
friend ExportArithmeticStatement operator-(const ExportVariable &arg1, const ExportVariable &arg2)
returnValue print() const
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
friend ExportArithmeticStatement operator*(const ExportVariable &arg1, const ExportVariable &arg2)
ExportVariable getCol(const ExportIndex &idx) const
Defines a matrix-valued variable to be used for exporting code.
ExportVariable makeColVector() const
virtual uint getNumRows() const


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