matrix_variable.cpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00026 
00034 #include <acado/variables_grid/matrix_variable.hpp>
00035 
00036 
00037 
00038 BEGIN_NAMESPACE_ACADO
00039 
00040 
00041 
00042 //
00043 // PUBLIC MEMBER FUNCTIONS:
00044 //
00045 
00046 MatrixVariable::MatrixVariable( ) : DMatrix( ), VariableSettings( )
00047 {
00048 }
00049 
00050 
00051 MatrixVariable::MatrixVariable( uint _nRows,
00052                                                                 uint _nCols,
00053                                                                 VariableType _type,
00054                                                                 const char** const _names,
00055                                                                 const char** const _units,
00056                                                                 DVector _scaling,
00057                                                                 DVector _lb,
00058                                                                 DVector _ub,
00059                                                                 BooleanType _autoInit
00060                                                                 ) : DMatrix( _nRows,_nCols ), VariableSettings( _nRows*_nCols,_type,_names,_units,_scaling,_lb,_ub,_autoInit )
00061 {
00062 }
00063 
00064 
00065 MatrixVariable::MatrixVariable( const MatrixVariable& rhs ) : DMatrix( rhs ), VariableSettings( rhs )
00066 {
00067 }
00068 
00069 
00070 MatrixVariable::MatrixVariable( const DMatrix& _matrix,
00071                                                                 VariableType _type
00072                                                                 ) : DMatrix( _matrix ), VariableSettings( _matrix.getDim(),_type )
00073 {
00074 }
00075 
00076 
00077 MatrixVariable::~MatrixVariable( )
00078 {
00079 }
00080 
00081 
00082 MatrixVariable& MatrixVariable::operator=( const MatrixVariable& rhs )
00083 {
00084     if ( this != &rhs )
00085     {
00086                 VariableSettings::operator=( rhs );
00087                 DMatrix::operator=( rhs );
00088     }
00089 
00090     return *this;
00091 }
00092 
00093 
00094 MatrixVariable& MatrixVariable::operator=( const DMatrix& rhs )
00095 {
00096     if ( this != &rhs )
00097     {
00098                 VariableSettings::operator=( rhs.getDim() );
00099                 DMatrix::operator=( rhs );
00100     }
00101 
00102     return *this;
00103 }
00104 
00105 
00106 
00107 returnValue MatrixVariable::init(       uint _nRows,
00108                                                                         uint _nCols,
00109                                                                         VariableType _type,
00110                                                                         const char** const _names,
00111                                                                         const char** const _units,
00112                                                                         DVector _scaling,
00113                                                                         DVector _lb,
00114                                                                         DVector _ub,
00115                                                                         BooleanType _autoInit
00116                                                                         )
00117 {
00118         DMatrix::init( _nRows,_nCols );
00119 
00120         if ( VariableSettings::init( _nRows*_nCols,_type,_names,_units,_scaling,_lb,_ub,_autoInit ) != SUCCESSFUL_RETURN )
00121                 return ACADOERROR( RET_UNKNOWN_BUG );
00122 
00123         return SUCCESSFUL_RETURN;
00124 }
00125 
00126 
00127 
00128 MatrixVariable MatrixVariable::getRows( uint startIdx,
00129                                                                                 uint endIdx
00130                                                                                 ) const
00131 {
00132         MatrixVariable newMatrixVariable;
00133 
00134         if ( ( startIdx >= getNumRows( ) ) || ( endIdx >= getNumRows( ) ) )
00135                 return newMatrixVariable;
00136 
00137         if ( startIdx > endIdx )
00138                 return newMatrixVariable;
00139 
00140         newMatrixVariable.init( endIdx-startIdx+1,getNumCols() );
00141         newMatrixVariable.operator=( DMatrix::getRows( startIdx,endIdx ) );
00142         // needs to be implemented for VariableSettings!!
00143 
00144         return newMatrixVariable;
00145 }
00146 
00147 
00148 MatrixVariable MatrixVariable::getCols( uint startIdx,
00149                                                                                 uint endIdx
00150                                                                                 ) const
00151 {
00152         MatrixVariable newMatrixVariable;
00153 
00154         if ( ( startIdx >= getNumCols( ) ) || ( endIdx >= getNumCols( ) ) )
00155                 return newMatrixVariable;
00156 
00157         if ( startIdx > endIdx )
00158                 return newMatrixVariable;
00159 
00160 
00161         newMatrixVariable.init( getNumRows(),endIdx-startIdx+1 );
00162         newMatrixVariable.operator=( DMatrix::getCols( startIdx,endIdx ) );
00163         // needs to be implemented for VariableSettings!!
00164 
00165         return newMatrixVariable;
00166 }
00167 
00168 
00169 //
00170 // PROTECTED MEMBER FUNCTIONS:
00171 //
00172 
00173 
00174 
00175 CLOSE_NAMESPACE_ACADO
00176 
00177 
00178 /*
00179  *      end of file
00180  */


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:59:10