Home > matlab > acado > packages > +acado > @Expression > Expression.m

Expression

PURPOSE ^

Base class for all variables within the symbolic expressions family.

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

Base class for all variables within the symbolic expressions family.
 The class Expression serves as a base class for all symbolic variables within the 
 symbolic expressions family. Moreover, the Expression class defines all kind of 
 matrix and vector operations on a symbolic level.

  Licence:
    This file is part of ACADO Toolkit  - (http://www.acadotoolkit.org/)

    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
    Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven.
    Developed within the Optimization in Engineering Center (OPTEC) under
    supervision of Moritz Diehl. All rights reserved.

    ACADO Toolkit is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 3 of the License, or (at your option) any later version.

    ACADO Toolkit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with ACADO Toolkit; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

    Author: David Ariens
    Date: 2010

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %Base class for all variables within the symbolic expressions family.
0002 % The class Expression serves as a base class for all symbolic variables within the
0003 % symbolic expressions family. Moreover, the Expression class defines all kind of
0004 % matrix and vector operations on a symbolic level.
0005 %
0006 %  Licence:
0007 %    This file is part of ACADO Toolkit  - (http://www.acadotoolkit.org/)
0008 %
0009 %    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
0010 %    Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven.
0011 %    Developed within the Optimization in Engineering Center (OPTEC) under
0012 %    supervision of Moritz Diehl. All rights reserved.
0013 %
0014 %    ACADO Toolkit is free software; you can redistribute it and/or
0015 %    modify it under the terms of the GNU Lesser General Public
0016 %    License as published by the Free Software Foundation; either
0017 %    version 3 of the License, or (at your option) any later version.
0018 %
0019 %    ACADO Toolkit is distributed in the hope that it will be useful,
0020 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
0021 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0022 %    Lesser General Public License for more details.
0023 %
0024 %    You should have received a copy of the GNU Lesser General Public
0025 %    License along with ACADO Toolkit; if not, write to the Free Software
0026 %    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0027 %
0028 %    Author: David Ariens
0029 %    Date: 2010
0030 %
0031 classdef Expression < handle   
0032     properties
0033         name;
0034     end
0035     
0036     methods
0037         function obj = Expression()
0038             
0039         end
0040         
0041         function r = dot(obj1, b, dim)
0042             r = acado.Dot(obj1);
0043         end
0044         
0045         function r = next(obj1, b, dim)
0046             r = acado.Next(obj1);
0047         end
0048         
0049         %Matlab help: "Implementing Operators for Your Class"
0050         
0051         function r = mtimes(obj1,obj2)    % *
0052             r = acado.Product(obj1,obj2);
0053         end 
0054         
0055         function r = plus(obj1,obj2)      % +
0056             r = acado.Addition(obj1,obj2);
0057         end
0058         
0059         function r = minus(obj1,obj2)     % -
0060             r = acado.Subtraction(obj1,obj2);
0061         end
0062         
0063         function r = mrdivide(obj1,obj2)  % /
0064             r = acado.Quotient(obj1,obj2);
0065         end
0066         
0067         function r = uminus(obj1)         % -
0068             r = acado.Subtraction(obj1);
0069         end
0070         
0071         function r = uplus(obj1)          % +
0072             r = acado.Addition(obj1);
0073         end
0074         
0075         function r = mpower(obj1, obj2)   % ^
0076             r = acado.Power(obj1, obj2);
0077         end
0078         
0079         function r = eq(obj1, obj2)       % ==
0080             r = acado.Equals(obj1, obj2);
0081         end
0082         
0083         function r = lt(obj1, obj2)       % <
0084             r = acado.LessThan(obj1, obj2);
0085         end
0086         
0087         function r = le(obj1, obj2)       % <=
0088             r = acado.LessThanEqual(obj1, obj2);
0089         end
0090         
0091         function r = gt(obj1, obj2)       % >
0092             r = acado.GreaterThan(obj1, obj2);
0093         end
0094         
0095         function r = ge(obj1, obj2)       % >=
0096             r = acado.GreaterThanEqual(obj1, obj2);
0097         end
0098         
0099         function r = exp(obj1)            % exp
0100             r = acado.Exp(obj1);
0101         end
0102         
0103         function r = acos(obj1)           % acos
0104             r = acado.Acos(obj1);
0105         end
0106         
0107         function r = asin(obj1)           % asin
0108             r = acado.Asin(obj1);
0109         end
0110         
0111         function r = atan(obj1)           % atan
0112             r = acado.Atan(obj1);
0113         end
0114         
0115         function r = cos(obj1)            % cos
0116             r = acado.Cos(obj1);
0117         end
0118         
0119         function r = sin(obj1)            % sin
0120             r = acado.Sin(obj1);
0121         end
0122         
0123         function r = tan(obj1)            % tan
0124             r = acado.Tan(obj1);
0125         end
0126         
0127         function r = log(obj1)            % log
0128             r = acado.Logarithm(obj1);
0129         end
0130     
0131         function s = toString(obj)
0132             s = obj.name; 
0133         end        
0134 
0135         function result = checkDoubleVectorMatrix(obj, r)
0136             
0137             if (isa(r, 'acado.MexInputVector'))
0138                 result = acado.Vector(r);
0139                 
0140             elseif(isa(r, 'acado.MexInputMatrix'))
0141                 result = acado.Matrix(r);
0142             
0143             elseif (isa(r, 'acado.MexInput'))
0144                 result = acado.DoubleConstant(r);
0145             
0146             elseif (isa(r, 'acado.Expression'))
0147                 result = r;
0148                 
0149             else
0150                 [m n] = size(r);
0151                 
0152                 if( m == 1 && n == 1)
0153                     result = acado.DoubleConstant(r);
0154                 elseif( (m == 1 && n &gt;= 1) || (m &gt;= 1 && n == 1) )
0155                     result = acado.Vector(r);
0156                 else
0157                     result = acado.Matrix(r);
0158                 end
0159             end
0160     
0161         end  
0162     end
0163 
0164     
0165 end
0166

www.acadotoolkit.org/matlab
Generated on Tue 01-Jun-2010 20:14:12 by m2html © 2005