Index: mttroot/mtt/bin/trans/make_ode2odes ================================================================== --- mttroot/mtt/bin/trans/make_ode2odes +++ mttroot/mtt/bin/trans/make_ode2odes @@ -7,10 +7,14 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.74 2002/05/01 17:30:56 geraint +## Improved pre-processor directives to better accommodate future alternatives (matlab) +## if necessary. +## ## Revision 1.73 2002/05/01 12:24:41 geraint ## Removed unnecessary inclusion of load-save.h. ## ## Revision 1.72 2002/05/01 12:21:29 geraint ## No longer uses save_ascii_data_for_plotting function to write data @@ -453,44 +457,44 @@ #include #if (CODEGENTARGET == STANDALONE) #include -extern ColumnVector F${sys}_ae ( +extern ColumnVector ${sys}_ae ( ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par); -extern ColumnVector F${sys}_input ( +extern ColumnVector ${sys}_input ( ColumnVector &x, ColumnVector &y, const double &t, ColumnVector &par); -extern ColumnVector F${sys}_logic ( +extern ColumnVector ${sys}_logic ( ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par); -extern ColumnVector F${sys}_numpar ( +extern ColumnVector ${sys}_numpar ( void); -extern ColumnVector F${sys}_simpar ( +extern ColumnVector ${sys}_simpar ( void); -extern ColumnVector F${sys}_state ( +extern ColumnVector ${sys}_state ( ColumnVector &par); -extern ColumnVector F${sys}_${ode} ( +extern ColumnVector ${sys}_${ode} ( ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par); -extern ColumnVector F${sys}_${odeo} ( +extern ColumnVector ${sys}_${odeo} ( ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par); @@ -505,17 +509,17 @@ ColumnVector &AAx, const double &ddt, const int &nx, const ColumnVector &open_switches); -extern Matrix F${sys}_smxa ( +extern Matrix ${sys}_smxa ( ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par); -extern ColumnVector F${sys}_smxax ( +extern ColumnVector ${sys}_smxax ( ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par); @@ -559,11 +563,11 @@ ColumnVector &u, const double &t, ColumnVector &par) { #if (CODEGENTARGET == STANDALONE) - return F${sys}_ae(x,u,t,par); + return ${sys}_ae(x,u,t,par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); @@ -581,11 +585,11 @@ { static MTT::${algebraic_solver} ae(MTTNPAR,MTTNU,MTTNX,MTTNY,MTTNYZ); static ColumnVector u (MTTNU); #if (CODEGENTARGET == STANDALONE) - u = F${sys}_input (x, y, t, par); + u = ${sys}_input (x, y, t, par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (y); args (2) = octave_value (t); @@ -608,11 +612,11 @@ ColumnVector &u, const double &t, ColumnVector &par) { #if (CODEGENTARGET == STANDALONE) - return F${sys}_logic (x, u, t, par); + return ${sys}_logic (x, u, t, par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); @@ -624,11 +628,11 @@ inline ColumnVector mtt_numpar (void) { #if (CODEGENTARGET == STANDALONE) - return F${sys}_numpar (); + return ${sys}_numpar (); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; f = feval ("${sys}_numpar", args, 1); return f(0).${vector_value} (); #endif // (CODEGENTARGET == STANDALONE) @@ -636,11 +640,11 @@ inline ColumnVector mtt_simpar (void) { #if (CODEGENTARGET == STANDALONE) - return F${sys}_simpar (); + return ${sys}_simpar (); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; f = feval ("${sys}_simpar", args, 1); return f(0).${vector_value} (); #endif // (CODEGENTARGET == STANDALONE) @@ -648,11 +652,11 @@ inline ColumnVector mtt_state (ColumnVector &par) { #if (CODEGENTARGET == STANDALONE) - return F${sys}_state (par); + return ${sys}_state (par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (par); f = feval ("${sys}_state", args, 1); return f(0).${vector_value} (); @@ -664,11 +668,11 @@ ColumnVector &u, const double &t, ColumnVector &par) { #if (CODEGENTARGET == STANDALONE) - return F${sys}_${ode} (x, u, t, par); + return ${sys}_${ode} (x, u, t, par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); @@ -683,11 +687,11 @@ ColumnVector &u, const double &t, ColumnVector &par) { #if (CODEGENTARGET == STANDALONE) - return F${sys}_${odeo} (x, u, t, par); + return ${sys}_${odeo} (x, u, t, par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); @@ -731,11 +735,11 @@ ColumnVector &u, const double &t, ColumnVector &par) { #if (CODEGENTARGET == STANDALONE) - return F${sys}_smxa (x, u, t, par); + return ${sys}_smxa (x, u, t, par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); @@ -750,11 +754,11 @@ ColumnVector &u, const double &t, ColumnVector &par) { #if (CODEGENTARGET == STANDALONE) - return F${sys}_smxax (x, u, t, par); + return ${sys}_smxax (x, u, t, par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); @@ -797,11 +801,11 @@ #endif // (CODEGENTARGET == STANDALONE) } #if (CODEGENTARGET == STANDALONE) ColumnVector -Fmtt_residual (const ColumnVector &X, +mtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires) { #elif (CODEGENTARGET == OCTAVEDLD) @@ -834,12 +838,12 @@ x = X.extract (0,MTTNX-1); if (MTTNYZ > 0) ui = X.extract (MTTNX,MTTNX+MTTNYZ-1); #if (CODEGENTARGET == STANDALONE) - par = F${sys}_numpar(); - u = F${sys}_input(x,y,t,par); + par = ${sys}_numpar(); + u = ${sys}_input(x,y,t,par); #elif (CODEGENTARGET == OCTAVEDLD) par = feval ("${sys}_numpar", new_args, 1)(0).${vector_value} (); new_args(0) = octave_value (x); new_args(1) = octave_value (u); new_args(2) = octave_value (t); @@ -850,12 +854,12 @@ U.insert (u,0); if (MTTNYZ > 0) U.insert (ui,MTTNU); #if (CODEGENTARGET == STANDALONE) - dx = F${sys}_${ode} (x,U,t,par); - yz = F${sys}_ae (x,U,t,par); + dx = ${sys}_${ode} (x,U,t,par); + yz = ${sys}_ae (x,U,t,par); #elif (CODEGENTARGET == OCTAVEDLD) new_args(1) = octave_value (U); dx = feval ("${sys}_${ode}", new_args, 1)(0).${vector_value} (); yz = feval ("${sys}_ae", new_args, 1)(0).${vector_value} (); #endif // (CODEGENTARGET == STANDALONE) Index: mttroot/mtt/bin/trans/make_stdin ================================================================== --- mttroot/mtt/bin/trans/make_stdin +++ mttroot/mtt/bin/trans/make_stdin @@ -98,11 +98,11 @@ str.setf(ios::skipws); c = str.peek (); } } -ColumnVector F${Sys}_input ( +ColumnVector ${Sys}_input ( ColumnVector &mttx, ColumnVector &mtty, const double &mttt, ColumnVector &mttpar ) Index: mttroot/mtt/bin/trans/mtt_header ================================================================== --- mttroot/mtt/bin/trans/mtt_header +++ mttroot/mtt/bin/trans/mtt_header @@ -10,10 +10,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.45 2002/05/02 09:30:22 gawthrop +## _ssim.m now returns t as 4th arg +## ## Revision 1.44 2002/05/01 17:30:56 geraint ## Improved pre-processor directives to better accommodate future alternatives (matlab) ## if necessary. ## ## Revision 1.43 2002/04/30 23:27:00 geraint @@ -733,117 +736,30 @@ done echo ${ans} } -write_DLD_header() -{ - cat < -#include -#include -#include "useful-functions.hh" -#include "${system}_cr.h" -#include "${system}_def.h" -#include "${system}_sympar.h" - -DEFUN_DLD (${system}_${rep}, args, , -"Usage: [$output] = ${system}_${rep}($args)\nOctave ${rep} representation of system ${system}\nGenerated by MTT on `date`") -{ - - octave_value_list retval; -#endif // (CODEGENTARGET == OCTAVEDLD) - -EOF -} - - -map_DLD_inputs () -{ - s=${1:-""} # comma separated input list - if [ -z ${s:-""} ];then return; fi - printf "#if (CODEGENTARGET == OCTAVEDLD)\n" - c=`get_field ${s} 0` # count of inputs - i=0 - printf " if (${c} != args.length ()) usage (\"${fun_name} expected ${c} argument(s): ${s}\");\n\n" - while [ ${i} -lt ${c} ]; do - j=${i} - i=`expr ${i} + 1` - w=`get_field ${s} ${i}` # argument name - get_arg_specific_stuff ${w} - case ${arg_type} in - "const double") - printf " ${arg_type}\t${w}\t= args(${j}).double_value ();\n" - ;; - ColumnVector | Matrix | *) - printf " ${arg_type}\t${w}\t= args(${j}).%s ();\n" ${vector_value} - ;; - esac - done - printf "#endif // (CODEGENTARGET == OCTAVEDLD)\n\n" -} - - -declare_DLD_outputs () -{ - s=${1:-""} # comma separated output list - c=`get_field ${s} 0` # count of outputs - i=0 - while [ ${i} -lt ${c} ]; do - i=`expr ${i} + 1` - w=`get_field ${s} ${i}` # argument name - get_arg_specific_stuff ${w} - printf " static ${arg_type}\t${w}\t${arg_init};\n" - done -} - - -return_DLD_outputs () -{ - s=${1:-""} # comma separated output list - c=`get_field ${s} 0` # count of outputs - i=0 - cat < #include "useful-functions.hh" #include "${system}_cr.h" #include "${system}_def.h" #include "${system}_sympar.h" -${arg_type} F${system}_${rep} ( +// Code generation directives +#define STANDALONE 0 +#define OCTAVEDLD 1 +#define MATLABMEX 2 +#ifndef CODEGENTARGET +#define CODEGENTARGET STANDALONE +#endif // CODEGENTARGET + +${arg_type} ${system}_${rep} ( EOF if [ -z ${args:-""} ]; then printf "\tvoid" else c=`get_field ${args:-""} 0` @@ -858,26 +774,77 @@ w=`get_field ${args} ${i}` get_arg_specific_stuff ${w} printf "\t${arg_type}\t&${w}${comma}\n" done fi + get_arg_specific_stuff ${output} cat <"} + args=${2:-""} + cat <