


Used to generate CPP file
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

0001 function getInstructions(obj, cppobj, get) 0002 %Used to generate CPP file 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 if (get == 'B') 0033 0034 0035 fprintf(cppobj.fileMEX,sprintf(' double *%s_temp = NULL; \n', obj.name)); 0036 fprintf(cppobj.fileMEX,sprintf(' if( !mxIsDouble(prhs[%d]) || mxIsComplex(prhs[%d]) ) { \n', obj.counter, obj.counter)); 0037 fprintf(cppobj.fileMEX,sprintf(' mexErrMsgTxt("Input %d must be a noncomplex double vector of dimension XxY.");\n', obj.counter)); 0038 fprintf(cppobj.fileMEX,sprintf(' } \n')); 0039 fprintf(cppobj.fileMEX,sprintf(' %s_temp = mxGetPr(prhs[%d]); \n', obj.name, obj.counter)); 0040 0041 fprintf(cppobj.fileMEX,sprintf(' Matrix %s(mxGetM(prhs[%d]), mxGetN(prhs[%d]));\n', obj.name_m, obj.counter, obj.counter)); 0042 0043 % Mex stored all cols after each other. So first loop over cols, 0044 % then loop over rows. 0045 fprintf(cppobj.fileMEX,sprintf(' for( int i=0; i<mxGetN(prhs[%d]); ++i ){ \n', obj.counter)); 0046 fprintf(cppobj.fileMEX,sprintf(' for( int j=0; j<mxGetM(prhs[%d]); ++j ){ \n', obj.counter)); 0047 fprintf(cppobj.fileMEX,sprintf(' %s(j,i) = %s_temp[i*mxGetM(prhs[%d]) + j];\n', obj.name_m, obj.name, obj.counter)); 0048 fprintf(cppobj.fileMEX, ' } \n'); 0049 fprintf(cppobj.fileMEX, ' } \n'); 0050 0051 fprintf(cppobj.fileMEX,sprintf(' VariablesGrid %s(%s); \n', obj.name, obj.name_m)); 0052 0053 0054 0055 %%test 0056 % fprintf(cppobj.fileMEX, ' acadoPrintf("%%f - %%f - %%f - %%f \\n", mexinput0_temp[0], mexinput0_temp[1], mexinput0_temp[2], mexinput0_temp[3]); \n'); 0057 % fprintf(cppobj.fileMEX, ' acadoPrintf("%%f - %%f - %%f - %%f \\n", mexinput0_temp[4], mexinput0_temp[5], mexinput0_temp[6], mexinput0_temp[7]); \n'); 0058 % 0059 % fprintf(cppobj.fileMEX, ' acadoPrintf("%%f - %%f \\n", mexinput0(0,0), mexinput0(0,1)); \n'); 0060 % fprintf(cppobj.fileMEX, ' acadoPrintf("%%f - %%f \\n", mexinput0(1,0), mexinput0(1,1)); \n'); 0061 % fprintf(cppobj.fileMEX, ' acadoPrintf("%%f - %%f \\n", mexinput0(2,0), mexinput0(2,1)); \n'); 0062 % fprintf(cppobj.fileMEX, ' acadoPrintf("%%f - %%f \\n", mexinput0(3,0), mexinput0(3,1)); \n'); 0063 0064 0065 fprintf(cppobj.fileMEX,'\n'); 0066 end 0067 0068 end