00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00031 #ifndef ACADO_TOOLKIT_EXPORT_VARIABLE_HPP
00032 #define ACADO_TOOLKIT_EXPORT_VARIABLE_HPP
00033
00034 #include <acado/utils/acado_utils.hpp>
00035 #include <acado/code_generation/export_argument.hpp>
00036 #include <acado/code_generation/export_index.hpp>
00037
00038 BEGIN_NAMESPACE_ACADO
00039
00040 class ExportArithmeticStatement;
00041 class ExportVariableInternal;
00042
00058 class ExportVariable : public ExportArgument
00059 {
00060
00061
00062
00063 public:
00064
00066 ExportVariable();
00067
00078 ExportVariable( const std::string& _name,
00079 uint _nRows,
00080 uint _nCols,
00081 ExportType _type = REAL,
00082 ExportStruct _dataStruct = ACADO_LOCAL,
00083 bool _callItByValue = false,
00084 const std::string& _prefix = std::string()
00085 );
00086
00097 ExportVariable( const std::string& _name,
00098 const DMatrix& _data,
00099 ExportType _type = REAL,
00100 ExportStruct _dataStruct = ACADO_LOCAL,
00101 bool _callItByValue = false,
00102 const std::string& _prefix = std::string(),
00103 bool _isGiven = true
00104 );
00105
00116 ExportVariable( const std::string& _name,
00117 const DMatrixPtr& _data,
00118 ExportType _type = REAL,
00119 ExportStruct _dataStruct = ACADO_LOCAL,
00120 bool _callItByValue = false,
00121 const std::string& _prefix = std::string()
00122 );
00123
00133 ExportVariable( unsigned _nRows,
00134 unsigned _nCols,
00135 ExportType _type = REAL,
00136 ExportStruct _dataStruct = ACADO_LOCAL,
00137 bool _callItByValue = false,
00138 const std::string& _prefix = std::string()
00139 );
00140
00144 template<typename Derived>
00145 ExportVariable( const Eigen::MatrixBase<Derived>& _data
00146 )
00147 {
00148 simpleForward(DMatrix( _data ));
00149 }
00150
00151 ExportVariable( const double _data
00152 );
00157 virtual ~ExportVariable( );
00158
00159 ExportVariable clone() const;
00160
00161 ExportVariableInternal* operator->();
00162
00163 const ExportVariableInternal* operator->() const;
00164
00177 ExportVariable& setup( const std::string& _name,
00178 uint _nRows = 1,
00179 uint _nCols = 1,
00180 ExportType _type = REAL,
00181 ExportStruct _dataStruct = ACADO_LOCAL,
00182 bool _callItByValue = false,
00183 const std::string& _prefix = std::string()
00184 );
00185
00198 ExportVariable& setup( const std::string& _name,
00199 const DMatrix& _data,
00200 ExportType _type = REAL,
00201 ExportStruct _dataStruct = ACADO_LOCAL,
00202 bool _callItByValue = false,
00203 const std::string& _prefix = std::string(),
00204 bool _isGiven = true
00205 );
00206
00214 double operator()( uint rowIdx,
00215 uint colIdx
00216 ) const;
00217
00224 double operator()( uint totalIdx
00225 ) const;
00226
00235 bool isZero( const ExportIndex& rowIdx,
00236 const ExportIndex& colIdx
00237 ) const;
00238
00247 bool isOne( const ExportIndex& rowIdx,
00248 const ExportIndex& colIdx
00249 ) const;
00250
00259 bool isGiven( const ExportIndex& rowIdx,
00260 const ExportIndex& colIdx
00261 ) const;
00262
00268 bool isGiven( ) const;
00269
00270
00279 const std::string get( const ExportIndex& rowIdx,
00280 const ExportIndex& colIdx
00281 ) const;
00282
00287 virtual uint getNumRows( ) const;
00288
00293 virtual uint getNumCols( ) const;
00294
00299 virtual uint getDim( ) const;
00300
00301
00308 friend ExportArithmeticStatement operator+( const ExportVariable& arg1,
00309 const ExportVariable& arg2
00310 );
00311
00318 friend ExportArithmeticStatement operator-( const ExportVariable& arg1,
00319 const ExportVariable& arg2
00320 );
00321
00328 friend ExportArithmeticStatement operator+=( const ExportVariable& arg1,
00329 const ExportVariable& arg2
00330 );
00331
00338 friend ExportArithmeticStatement operator-=( const ExportVariable& arg1,
00339 const ExportVariable& arg2
00340 );
00341
00348 friend ExportArithmeticStatement operator*( const ExportVariable& arg1,
00349 const ExportVariable& arg2
00350 );
00351
00358 friend ExportArithmeticStatement operator^( const ExportVariable& arg1,
00359 const ExportVariable& arg2
00360 );
00361
00368 friend ExportArithmeticStatement operator==( const ExportVariable& arg1,
00369 const ExportVariable& arg2
00370 );
00371
00378 ExportArithmeticStatement operator==( ExportArithmeticStatement arg
00379 ) const;
00380
00387 ExportArithmeticStatement operator+( ExportArithmeticStatement arg
00388 ) const;
00389
00396 ExportArithmeticStatement operator-( ExportArithmeticStatement arg
00397 ) const;
00398
00405 ExportArithmeticStatement operator+=( ExportArithmeticStatement arg
00406 ) const;
00407
00414 ExportArithmeticStatement operator-=( ExportArithmeticStatement arg
00415 ) const;
00416
00421 ExportVariable getTranspose( ) const;
00422
00429 ExportVariable getRow( const ExportIndex& idx
00430 ) const;
00431
00438 ExportVariable getCol( const ExportIndex& idx
00439 ) const;
00440
00448 ExportVariable getRows( const ExportIndex& idx1,
00449 const ExportIndex& idx2
00450 ) const;
00451
00459 ExportVariable getCols( const ExportIndex& idx1,
00460 const ExportIndex& idx2
00461 ) const;
00462
00472 ExportVariable getSubMatrix( const ExportIndex& rowIdx1,
00473 const ExportIndex& rowIdx2,
00474 const ExportIndex& colIdx1,
00475 const ExportIndex& colIdx2
00476 ) const;
00477
00485 ExportVariable getElement( const ExportIndex& rowIdx,
00486 const ExportIndex& colIdx
00487 ) const;
00488
00493 ExportVariable makeRowVector( ) const;
00494
00499 ExportVariable makeColVector( ) const;
00500
00501
00507 bool isVector( ) const;
00508
00509
00514 const DMatrix& getGivenMatrix( ) const;
00515
00517 bool isSubMatrix() const;
00518
00520 bool isDiagonal() const;
00521
00526 returnValue print( ) const;
00527
00528 private:
00529 void simpleForward(const DMatrix& _value);
00530 };
00531
00532 static const ExportVariable emptyConstExportVariable;
00533
00534 CLOSE_NAMESPACE_ACADO
00535
00536 #endif // ACADO_TOOLKIT_EXPORT_VARIABLE_HPP