Home > matlab > acado > packages > +acado > @AcadoMatlab > getCPPlefthandout.m

getCPPlefthandout

PURPOSE ^

Generate CPP code for a left hand out matrix

SYNOPSIS ^

function getCPPlefthandout(obj, nameB, name, out)

DESCRIPTION ^

Generate CPP code for a left hand out matrix

  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:

SOURCE CODE ^

0001 function getCPPlefthandout(obj, nameB, name, out)
0002 %Generate CPP code for a left hand out matrix
0003 %
0004 %  Licence:
0005 %    This file is part of ACADO Toolkit  - (http://www.acadotoolkit.org/)
0006 %
0007 %    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
0008 %    Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven.
0009 %    Developed within the Optimization in Engineering Center (OPTEC) under
0010 %    supervision of Moritz Diehl. All rights reserved.
0011 %
0012 %    ACADO Toolkit is free software; you can redistribute it and/or
0013 %    modify it under the terms of the GNU Lesser General Public
0014 %    License as published by the Free Software Foundation; either
0015 %    version 3 of the License, or (at your option) any later version.
0016 %
0017 %    ACADO Toolkit is distributed in the hope that it will be useful,
0018 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
0019 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0020 %    Lesser General Public License for more details.
0021 %
0022 %    You should have received a copy of the GNU Lesser General Public
0023 %    License along with ACADO Toolkit; if not, write to the Free Software
0024 %    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0025 %
0026 %    Author: David Ariens
0027 %    Date: 2010
0028 %
0029 
0030 
0031 
0032     fprintf(obj.fileMEX,sprintf('    mxArray *%s = NULL;\n', nameB));
0033     fprintf(obj.fileMEX,sprintf('    double  *%s = NULL;\n', name));
0034     fprintf(obj.fileMEX,sprintf('    %s = mxCreateDoubleMatrix( %s.getNumPoints(),1+%s.getNumValues(),mxREAL ); \n', nameB, out, out));
0035     fprintf(obj.fileMEX,sprintf('    %s = mxGetPr( %s );\n', name, nameB));
0036 
0037     fprintf(obj.fileMEX,sprintf('    for( int i=0; i<%s.getNumPoints(); ++i ){ \n', out));
0038     fprintf(obj.fileMEX,sprintf('      %s[0*%s.getNumPoints() + i] = %s.getTime(i); \n', name, out, out));
0039     fprintf(obj.fileMEX,sprintf('      for( int j=0; j<%s.getNumValues(); ++j ){ \n', out));
0040     fprintf(obj.fileMEX,sprintf('        %s[(1+j)*%s.getNumPoints() + i] = %s(i, j); \n', name, out, out));
0041     fprintf(obj.fileMEX,'       } \n');
0042     fprintf(obj.fileMEX,'    } \n\n');
0043     
0044 end

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