evaluation_template.hpp
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 
00027 
00034 #ifndef ACADO_TOOLKIT_EVALUATION_TEMPLATE_HPP
00035 #define ACADO_TOOLKIT_EVALUATION_TEMPLATE_HPP
00036 
00037 #include <acado/symbolic_operator/symbolic_operator_fwd.hpp>
00038 #include <acado/symbolic_operator/evaluation_base.hpp>
00039 
00040 
00041 BEGIN_NAMESPACE_ACADO
00042 
00051 template <typename T>
00052 class EvaluationTemplate : public EvaluationBase{
00053 
00054 public:
00055 
00057         EvaluationTemplate();
00058         EvaluationTemplate( Tmatrix<T> *_val );
00059         
00060         virtual ~EvaluationTemplate();
00061 
00062         virtual void addition   ( Operator &arg1, Operator &arg2 );
00063         virtual void subtraction( Operator &arg1, Operator &arg2 );
00064         virtual void product    ( Operator &arg1, Operator &arg2 );
00065         virtual void quotient   ( Operator &arg1, Operator &arg2 );
00066         virtual void power      ( Operator &arg1, Operator &arg2 );
00067         virtual void powerInt   ( Operator &arg1, int      &arg2 );
00068 
00069         virtual void project    ( int      &idx );
00070         virtual void set        ( double   &arg );
00071         virtual void Acos       ( Operator &arg );
00072         virtual void Asin       ( Operator &arg );
00073         virtual void Atan       ( Operator &arg );
00074         virtual void Cos        ( Operator &arg );
00075         virtual void Exp        ( Operator &arg );
00076         virtual void Log        ( Operator &arg );
00077         virtual void Sin        ( Operator &arg );
00078         virtual void Tan        ( Operator &arg );
00079         
00080         Tmatrix<T> *val;
00081         T           res;
00082         
00083 };
00084 
00085 
00086 
00087 CLOSE_NAMESPACE_ACADO
00088 
00089 #include <acado/symbolic_operator/operator.hpp>
00090 
00091 BEGIN_NAMESPACE_ACADO
00092 
00093 
00094 
00095 template <typename T> EvaluationTemplate<T>::EvaluationTemplate():EvaluationBase(){ val = 0; }
00096 template <typename T> EvaluationTemplate<T>::EvaluationTemplate( Tmatrix<T> *_val ):EvaluationBase()
00097 { val = _val; }
00098 template <typename T> EvaluationTemplate<T>::~EvaluationTemplate(){}
00099 
00100 template <typename T> void EvaluationTemplate<T>::addition( Operator &arg1, Operator &arg2 ){
00101         
00102         EvaluationTemplate<T> r(val);
00103         arg1.evaluate( this );
00104         arg2.evaluate( &r );
00105         res += r.res;
00106 }
00107 
00108 template <typename T> void EvaluationTemplate<T>::subtraction( Operator &arg1, Operator &arg2 ){
00109  
00110         EvaluationTemplate<T> r(val);
00111         arg1.evaluate( this );
00112         arg2.evaluate( &r );
00113         res -= r.res;
00114 }
00115 
00116 template <typename T> void EvaluationTemplate<T>::product( Operator &arg1, Operator &arg2 ){
00117  
00118         EvaluationTemplate<T> r(val);
00119         arg1.evaluate( this );
00120         arg2.evaluate( &r );
00121         res *= r.res;
00122 }
00123 
00124 template <typename T> void EvaluationTemplate<T>::quotient( Operator &arg1, Operator &arg2 ){
00125 
00126         EvaluationTemplate<T> r(val);
00127         arg1.evaluate( this );
00128         arg2.evaluate( &r );
00129         res /= r.res;
00130 }
00131 
00132 template <typename T> void EvaluationTemplate<T>::power( Operator &arg1, Operator &arg2 ){
00133  
00134         EvaluationTemplate<T> r(val);
00135         arg1.evaluate( this );
00136         arg2.evaluate( &r );
00137         res = pow(res,r.res);
00138 }
00139 
00140 template <typename T> void EvaluationTemplate<T>::powerInt( Operator &arg1, int &arg2 ){
00141  
00142         arg1.evaluate( this );
00143         res = pow( res, arg2 );
00144 }
00145 
00146 
00147 template <typename T> void EvaluationTemplate<T>::project( int &idx ){
00148 
00149         res = val->operator()(idx);
00150 }
00151 
00152 
00153 template <typename T> void EvaluationTemplate<T>::set( double &arg ){
00154 
00155         res = arg;
00156 }
00157 
00158 
00159 template <typename T> void EvaluationTemplate<T>::Acos( Operator &arg ){
00160 
00161         arg.evaluate( this );
00162         res = acos( res );
00163 }
00164 
00165 template <typename T> void EvaluationTemplate<T>::Asin( Operator &arg ){
00166 
00167         arg.evaluate( this );
00168         res = asin( res );
00169 }
00170 
00171 template <typename T> void EvaluationTemplate<T>::Atan( Operator &arg ){
00172 
00173         arg.evaluate( this );
00174         res = atan( res );
00175 }
00176 
00177 template <typename T> void EvaluationTemplate<T>::Cos( Operator &arg ){
00178 
00179         arg.evaluate( this );
00180         res = cos( res );
00181 }
00182 
00183 template <typename T> void EvaluationTemplate<T>::Exp( Operator &arg ){
00184 
00185         arg.evaluate( this );
00186         res = exp( res );
00187 }
00188 
00189 template <typename T> void EvaluationTemplate<T>::Log( Operator &arg ){
00190 
00191         arg.evaluate( this );
00192         res = log( res );
00193 }
00194 
00195 template <typename T> void EvaluationTemplate<T>::Sin( Operator &arg ){
00196 
00197         arg.evaluate( this );
00198         res = sin( res );
00199 }
00200 
00201 template <typename T> void EvaluationTemplate<T>::Tan( Operator &arg ){
00202 
00203         arg.evaluate( this );
00204         res = tan( res );
00205 }
00206 
00207 CLOSE_NAMESPACE_ACADO
00208 
00209 #endif


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