Index: mttroot/mtt/bin/mtt ================================================================== --- mttroot/mtt/bin/mtt +++ mttroot/mtt/bin/mtt @@ -15,10 +15,13 @@ ############################################################### ## Version control history ############################################################### ## $Header$ ## $Log$ +## Revision 1.334 2002/05/01 14:10:22 gawthrop +## Added -dr foo (reads from dir foo) option +## ## Revision 1.333 2002/04/28 18:41:26 geraint ## Fixed [ 549658 ] awk should be gawk. ## Replaced calls to awk with call to gawk. ## ## Revision 1.332 2002/04/26 23:19:00 geraint @@ -2087,16 +2090,16 @@ %.dvi: %.tex # MTT implicit rules ## .oct files $1_%.oct: $1_%.cc $1_def.h $1_sympar.h $1_cr.h - echo Creating $1_\$*.oct; $MKOCTFILE $1_\$*.cc + echo Creating $1_\$*.oct; $MKOCTFILE -DCODEGENTARGET=OCTAVEDLD $1_\$*.cc .PRECIOUS: mtt_%.oct mtt_%.oct: mtt_%.cc echo Compiling \$< - ${MKOCTFILE} $define_octave_dev \$< + ${MKOCTFILE} -DCODEGENTARGET=OCTAVEDLD $define_octave_dev \$< ## .cc files .PRECIOUS: %.cc # Don't let mtt delete them $1_%.cc: $1_%.m mtt_m2cc.sh $1 \$* cat @@ -2109,16 +2112,16 @@ ## .o files .PRECIOUS: $1_%.o $1_%.o: $1_%.cc $1_def.h $1_sympar.h $1_cr.h echo Compiling $1_\$*.cc - ${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DSTANDALONE + ${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DCODEGENTARGET=STANDALONE .PRECIOUS: mtt_%.o mtt_%.o: mtt_%.cc echo Compiling mtt_\$*.cc - ${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DSTANDALONE $define_octave_dev + ${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DCODEGENTARGET=STANDALONE $define_octave_dev # Generates code to write reduce code $1_ode_write.r: $1_def.m def2write_r $1 $2 $computation @@ -2762,16 +2765,16 @@ $1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o mtt_kpathsea.o\ ${MTT_LDFLAGS} ${MTT_CXXLIBS} $1_ode2odes.o: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o echo Creating $1_ode2odes.o - ${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DSTANDALONE + ${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DCODEGENTARGET=STANDALONE $1_ode2odes.oct: $1_ode2odes.cc $1_ode2odes_common.oct $1_ode2odes_${integration_method}.oct $1_ode2odes_${algebraic_solver}.o touch $1_ode2odes.m echo Creating $1_ode2odes.oct - $MKOCTFILE $1_ode2odes.cc mtt_${algebraic_solver}.cc mtt_Solver.cc mtt_AlgebraicSolver.cc + $MKOCTFILE -DCODEGENTARGET=OCTAVEDLD $1_ode2odes.cc mtt_${algebraic_solver}.cc mtt_Solver.cc mtt_AlgebraicSolver.cc $1_ode2odes.cc: $1_def.r $1_sympars.txt\ $1_ode2odes_common.m $1_ode2odes_common.cc\ $1_ode2odes_${integration_method}.m $1_ode2odes_${integration_method}.cc\ mtt_Solver.cc mtt_AlgebraicSolver.cc mtt_${algebraic_solver}.cc mtt_${algebraic_solver}.hh Index: mttroot/mtt/bin/trans/make_ode2odes ================================================================== --- mttroot/mtt/bin/trans/make_ode2odes +++ mttroot/mtt/bin/trans/make_ode2odes @@ -7,10 +7,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## 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 ## - eliminates dependence on liboctinterp (and libncurses) for .cc. ## ## Revision 1.71 2002/04/30 23:27:00 geraint @@ -425,25 +428,33 @@ feval_header=parse.h ;; esac cat < $filename + +// Code generation directives +#define STANDALONE 0 +#define OCTAVEDLD 1 +#if (! defined (CODEGENTARGET)) +#define CODEGENTARGET STANDALONE +#endif // (! defined (CODEGENTARGET)) + #include #include #include -#ifndef STANDALONE +#if (CODEGENTARGET == OCTAVEDLD) #include -#endif +#endif // (CODEGENTARGET == OCTAVEDLD) #include "${sys}_def.h" #include "${sys}_sympar.h" #include "mtt_${algebraic_solver}.hh" #include -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) #include extern ColumnVector F${sys}_ae ( ColumnVector &x, ColumnVector &u, @@ -539,29 +550,29 @@ esac cat <> $filename void set_signal_handlers (void); -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) ColumnVector mtt_ae (ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return F${sys}_ae(x,u,t,par); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); f = feval ("${sys}_ae", args, 1); return f(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } inline ColumnVector mtt_input (ColumnVector &x, ColumnVector &y, @@ -569,21 +580,21 @@ ColumnVector &par) { static MTT::${algebraic_solver} ae(MTTNPAR,MTTNU,MTTNX,MTTNY,MTTNYZ); static ColumnVector u (MTTNU); -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) u = F${sys}_input (x, y, t, par); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (y); args (2) = octave_value (t); args (3) = octave_value (par); f = feval ("${sys}_input", args, 1); u = f(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) if (MTTNYZ == 0) { return u; } else @@ -596,96 +607,96 @@ mtt_logic (ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return F${sys}_logic (x, u, t, par); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); f = feval ("${sys}_logic", args, 1); return f(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } inline ColumnVector mtt_numpar (void) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return F${sys}_numpar (); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; f = feval ("${sys}_numpar", args, 1); return f(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } inline ColumnVector mtt_simpar (void) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return F${sys}_simpar (); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; f = feval ("${sys}_simpar", args, 1); return f(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } inline ColumnVector mtt_state (ColumnVector &par) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return F${sys}_state (par); -#else +#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} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } inline ColumnVector mtt_rate (ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return F${sys}_${ode} (x, u, t, par); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); f = feval ("${sys}_${ode}", args, 1); return f(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } inline ColumnVector mtt_output (ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return F${sys}_${odeo} (x, u, t, par); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); f = feval ("${sys}_${odeo}", args, 1); return f(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } EOF case "$method" in "implicit") @@ -697,13 +708,13 @@ ColumnVector &AAx, const double &ddt, const int &nx, const ColumnVector &open_switches) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return Fmtt_implicit (x, dx, AA, AAx, ddt, nx, open_switches); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (dx); args (2) = octave_value (AA); args (3) = octave_value (AAx); @@ -710,49 +721,49 @@ args (4) = octave_value (ddt); args (5) = octave_value ((double)nx); args (6) = octave_value (open_switches); f = feval ("mtt_implicit", args, 1); return f(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } inline Matrix mtt_smxa (ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return F${sys}_smxa (x, u, t, par); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); f = feval ("${sys}_smxa", args, 1); return f(0).matrix_value (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } inline ColumnVector mtt_smxax (ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return F${sys}_smxax (x, u, t, par); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); f = feval ("${sys}_smxax", args, 1); return f(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } EOF ;; "dassl") @@ -766,13 +777,13 @@ const double &ddt, const int &nx, const int &nyz, const ColumnVector &open_switches) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return Fmtt_dassl (x, u, t, par, dx, ddt, nx, nyz, open_switches); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); @@ -781,21 +792,21 @@ args (6) = octave_value (static_cast (nx)); args (7) = octave_value (static_cast (nyz)); args (8) = octave_value (open_switches); f = feval ("mtt_dassl", args, 1); return f(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) ColumnVector Fmtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires) { -#else // !STANDALONE +#elif (CODEGENTARGET == OCTAVEDLD) DEFUN_DLD (mtt_residual, args, , "mtt_residual") { static ColumnVector X (MTTNX+MTTNYZ); static ColumnVector DX (MTTNX+MTTNYZ); static double t; @@ -803,11 +814,11 @@ X = args(0).${vector_value} (); DX = args(1).${vector_value} (); t = args(2).double_value (); ires = static_cast(args(3).double_value ()); -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) static ColumnVector residual (MTTNX+MTTNYZ); static ColumnVector U (MTTNU+MTTNYZ); static ColumnVector u (MTTNU); static ColumnVector y (MTTNY,0.0); @@ -822,34 +833,34 @@ x = X.extract (0,MTTNX-1); if (MTTNYZ > 0) ui = X.extract (MTTNX,MTTNX+MTTNYZ-1); -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) par = F${sys}_numpar(); u = F${sys}_input(x,y,t,par); -#else +#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); new_args(3) = octave_value (par); u = feval ("${sys}_input", new_args, 1)(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) U.insert (u,0); if (MTTNYZ > 0) U.insert (ui,MTTNU); -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) dx = F${sys}_${ode} (x,U,t,par); yz = F${sys}_ae (x,U,t,par); -#else +#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 +#endif // (CODEGENTARGET == STANDALONE) for (register int i = 0; i < MTTNX; i++) residual (i) = dx(i) - DX(i); if (MTTNYZ > 0) @@ -871,15 +882,15 @@ step = t; for (register int i = MTTNX; i < MTTNX+MTTNYZ; i++) residual(i) += X(i) - DX(i)*step; } -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return residual; -#else // !STANDALONE +#elif (CODEGENTARGET == OCTAVEDLD) return octave_value (residual); -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) } EOF ;; "euler" | "rk4" | *) @@ -889,22 +900,22 @@ const ColumnVector &dx, const double &ddt, const int &nx, const ColumnVector &open_switches) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return Fmtt_euler (x, dx, ddt, nx, open_switches); -#else +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (dx); args (2) = octave_value (ddt); args (3) = octave_value ((double)nx); args (4) = octave_value (open_switches); f = feval ("mtt_euler", args, 1); return f(0).${vector_value} (); -#endif +#endif // (CODEGENTARGET == STANDALONE) } EOF ;; esac @@ -960,26 +971,26 @@ << static_cast (cputime - cputime1) / CLOCKS_PER_SEC << std::endl; cputime1 = cputime; if (nrows == row) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) file << "# name: mtt_dump" << std::endl << "# type: matrix" << std::endl << "# rows: " << data.rows () << std::endl << "# columns: " << data.columns () << std::endl << data; file.flush (); -#else // ! STANDALONE +#elif (CODEGENTARGET == OCTAVEDLD) set_global_value ("MTT_data", data); -#endif +#endif // (CODEGENTARGET == STANDALONE) row = 0; fcputime.close(); } } -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) void dump_data (std::ostream &file) { ColumnVector null (0); mtt_write (0.0, null, null, 0, true, file); } @@ -1019,26 +1030,26 @@ signal (SIGQUIT, handle_signal); } int main (void) { set_signal_handlers (); -#else +#elif (CODEGENTARGET == OCTAVEDLD) DEFUN_DLD (${sys}_ode2odes, args, , "Octave ode2odes representation of system with $method integration method\nUsage: mtt_data = ${sys}_ode2odes (x0, par, simpar)\n") { static octave_value_list retval; -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) static ColumnVector x0; static ColumnVector par; static ColumnVector simpar; static double first = 0.0, dt = 0.0, last = 0.0, stepfactor = 0.0; -#ifndef STANDALONE +#if (CODEGENTARGET == OCTAVEDLD) int nargin = args.length (); switch (nargin) { case 3: first = args (2).${vector_value} ()(0); @@ -1063,24 +1074,24 @@ stepfactor = mtt_simpar ()(3); par = mtt_numpar (); x0 = args (0).${vector_value} (); break; case 0: -#endif // ! STANDALONE +#endif // (CODEGENTARGET == OCTAVEDLD) first = mtt_simpar ()(0); dt = mtt_simpar ()(1); last = mtt_simpar ()(2); stepfactor = mtt_simpar ()(3); par = mtt_numpar (); x0 = mtt_state (par); -#ifndef STANDALONE +#if (CODEGENTARGET == OCTAVEDLD) break; default: usage("${sys}_ode2odes (x par simpar)", nargin); error("aborting."); } -#endif // STANDALONE +#endif // (CODEGENTARGET == OCTAVEDLD) static ColumnVector dx (MTTNX, 0.0); static ColumnVector x (MTTNX, 0.0); static ColumnVector u (MTTNU, 0.0); static ColumnVector y (MTTNY, 0.0); @@ -1164,21 +1175,21 @@ t += ddt; j++; j = (j == static_cast (stepfactor)) ? 0 : j; } -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return 0; -#else +#elif (CODEGENTARGET == OCTAVEDLD) /* retval (0) = octave_value (y); retval (1) = octave_value (x); retval (2) = octave_value (t); */ retval = octave_value (get_global_value ("MTT_data")); return (retval); -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) } EOF } case ${lang} in Index: mttroot/mtt/bin/trans/make_stdin ================================================================== --- mttroot/mtt/bin/trans/make_stdin +++ mttroot/mtt/bin/trans/make_stdin @@ -71,11 +71,18 @@ // // System ${Sys}, representation input, language oct; // File ${Sys}_input.oct; // Generated by MTT on `date`; -#ifdef STANDALONE +// Code generation directives +#define STANDALONE 0 +#define OCTAVEDLD 1 +#if (! defined (CODEGENTARGET)) +#define CODEGENTARGET STANDALONE +#endif // (! defined (CODEGENTARGET)) + +#if (CODEGENTARGET == STANDALONE) #include #include "${Sys}_def.h" void strip_comments (istream &str) { @@ -98,12 +105,11 @@ ColumnVector &mtty, const double &mttt, ColumnVector &mttpar ) { -#endif // STANDALONE -#ifndef STANDALONE +#elif (CODEGENTARGET == OCTAVEDLD) #include #include #include "${Sys}_def.h" DEFUN_DLD (${Sys}_input, args, , @@ -111,16 +117,16 @@ Octave input (-stdin) representation of system ${Sys} Generated by MTT on `date`") { octave_value_list retval; -#endif // ! STANDALONE +#endif // (CODEGENTARGET == STANDALONE) ColumnVector mttu (MTTNU); // Set up the mttu vector -#ifndef STANDALONE +#if (CODEGENTARGET == OCTAVEDLD) int MTT_input_index = static_cast(get_global_value ("MTT_input_index").double_value ()); int MTT_input_last = static_cast(get_global_value ("MTT_input_last").double_value ()); Matrix MTT_input = get_global_value ("MTT_input").matrix_value(); mttu = MTT_input.row (MTT_input_index); @@ -128,31 +134,30 @@ if (MTT_input_index < (MTT_input_last - 1)) { set_global_value ("MTT_input_index", static_cast(++MTT_input_index)); } -#else +#elif (CODEGENTARGET == STANDALONE) double t, u; strip_comments (cin); cin >> t; for (register int i = 0; i < MTTNU; i++) { cin >> u; mttu(i) = u; } -#endif +#endif // (CODEGENTARGET == OCTAVEDLD) -#ifndef STANDALONE +#if (CODEGENTARGET == OCTAVEDLD) retval (0) = octave_value (mttu); return (retval); } -#endif // ! STANDALONE -#ifdef STANDALONE +#elif (CODEGENTARGET == STANDALONE) return mttu; } -#endif // STANDALONE +#endif // (CODEGENTARGET == OCTAVEDLD) EOF } case $lang in p) Index: mttroot/mtt/bin/trans/mtt_header ================================================================== --- mttroot/mtt/bin/trans/mtt_header +++ mttroot/mtt/bin/trans/mtt_header @@ -10,10 +10,15 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.43 2002/04/30 23:27:00 geraint +## Replaced octave_map with columnvector in simpar.cc. Not quite as descriptive but +## standardises the interfaces somewhat and reduces the dependency on liboctinterp +## (and thus libreadline, libkpathsea, libncurses, etc). +## ## Revision 1.42 2002/04/28 18:41:27 geraint ## Fixed [ 549658 ] awk should be gawk. ## Replaced calls to awk with call to gawk. ## ## Revision 1.41 2002/04/23 17:46:05 gawthrop @@ -727,11 +732,11 @@ write_DLD_header() { cat < #include #include #include "useful-functions.hh" #include "${system}_cr.h" @@ -741,21 +746,21 @@ 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 // ! STANDALONE +#endif // (CODEGENTARGET == OCTAVEDLD) EOF } map_DLD_inputs () { s=${1:-""} # comma separated input list if [ -z ${s:-""} ];then return; fi - printf "#ifndef STANDALONE\n" + 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} @@ -769,11 +774,11 @@ ColumnVector | Matrix | *) printf " ${arg_type}\t${w}\t= args(${j}).%s ();\n" ${vector_value} ;; esac done - printf "#endif // ! STANDALONE\n\n" + printf "#endif // (CODEGENTARGET == OCTAVEDLD)\n\n" } declare_DLD_outputs () { @@ -796,11 +801,11 @@ i=0 cat < #include "useful-functions.hh" #include "${system}_cr.h" #include "${system}_def.h" #include "${system}_sympar.h" @@ -845,21 +857,21 @@ done fi cat < #define VECTOR_VALUE vector_value #endif // OCTAVE_DEV +// Code generation directives +#define STANDALONE 0 +#define OCTAVEDLD 1 +#if (! defined (CODEGENTARGET)) +#define CODEGENTARGET STANDALONE +#endif // (! defined (CODEGENTARGET)) -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) extern ColumnVector Fmtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires); -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) ColumnVector mtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires) { -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return Fmtt_residual (X, DX, t, ires); -#else // !STANDALONE +#elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args(0) = octave_value (X); args(1) = octave_value (DX); args(2) = octave_value (t); args(3) = octave_value (ires); f = feval ("mtt_residual", args, 1); return f(0).VECTOR_VALUE (); -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) } -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) ColumnVector Fmtt_dassl ( ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par, @@ -45,11 +51,11 @@ const double &ddt, const int Nx, const int Nyz, const ColumnVector &openx) { -#else // !STANDALONE +#elif (CODEGENTARGET == OCTAVEDLD) DEFUN_DLD (mtt_dassl, args, , "dassl integration method") { ColumnVector x = args(0).VECTOR_VALUE(); const ColumnVector u = args(1).VECTOR_VALUE(); @@ -58,11 +64,11 @@ const ColumnVector dx = args(4).VECTOR_VALUE(); const double ddt = args(5).double_value(); const int Nx = static_cast (args(6).double_value()); const int Nyz = static_cast (args(7).double_value()); const ColumnVector openx = args(8).VECTOR_VALUE(); -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) static DAEFunc fdae(mtt_residual); static ColumnVector XX (Nx+Nyz); XX.insert (x,0); @@ -77,11 +83,11 @@ for (register int i = 0; i < Nx; i++) if (openx (i) > 0.5) x (i) = 0.0; -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return x; -#else +#elif (CODEGENTARGET == OCTAVEDLD) return octave_value (x); -#endif +#endif // (CODEGENTARGET == STANDALONE) } Index: mttroot/mtt/lib/cc/mtt_euler.cc ================================================================== --- mttroot/mtt/lib/cc/mtt_euler.cc +++ mttroot/mtt/lib/cc/mtt_euler.cc @@ -4,27 +4,34 @@ #define VECTOR_VALUE column_vector_value #else // !OCTAVE_DEV #define VECTOR_VALUE vector_value #endif // OCTAVE_DEV -#ifdef STANDALONE +// Code generation directives +#define STANDALONE 0 +#define OCTAVEDLD 1 +#if (! defined (CODEGENTARGET)) +#define CODEGENTARGET STANDALONE +#endif // (! defined (CODEGENTARGET)) + +#if (CODEGENTARGET == STANDALONE) ColumnVector Fmtt_euler ( ColumnVector &x, const ColumnVector &dx, const double &ddt, const int &Nx, const ColumnVector &openx) { -#else // !STANDALONE +#elif (CODEGENTARGET == OCTAVEDLD) DEFUN_DLD (mtt_euler, args, , "euler integration method") { ColumnVector x = args(0).VECTOR_VALUE (); const ColumnVector dx = args(1).VECTOR_VALUE (); const double ddt = args(2).double_value (); const int Nx = static_cast (args(3).double_value ()); const ColumnVector openx = args(4).VECTOR_VALUE (); -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) register int i, n; n = Nx; for (i = 0; i < Nx; i++) @@ -36,11 +43,11 @@ else { x (i) += dx (i) * ddt; } } -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return x; -#else // !STANDALONE +#elif (CODEGENTARGET == OCTAVEDLD) return octave_value (x); -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) } Index: mttroot/mtt/lib/cc/mtt_implicit.cc ================================================================== --- mttroot/mtt/lib/cc/mtt_implicit.cc +++ mttroot/mtt/lib/cc/mtt_implicit.cc @@ -5,20 +5,27 @@ #define VECTOR_VALUE column_vector_value #else // !OCTAVE_DEV #define VECTOR_VALUE vector_value #endif // OCTAVE_DEV -#ifdef STANDALONE +// Code generation directives +#define STANDALONE 0 +#define OCTAVEDLD 1 +#if (! defined (CODEGENTARGET)) +#define CODEGENTARGET STANDALONE +#endif // (! defined (CODEGENTARGET)) + +#if (CODEGENTARGET == STANDALONE) ColumnVector Fmtt_implicit ( ColumnVector &x, ColumnVector &dx, Matrix &AA, ColumnVector &AAx, const double &t, const int &Nx, const ColumnVector &openx) { -#else // !STANDALONE +#elif (CODEGENTARGET == OCTAVEDLD) DEFUN_DLD (mtt_implicit, args, , "implicit integration method") { ColumnVector x = args(0).VECTOR_VALUE (); ColumnVector dx = args(1).VECTOR_VALUE (); @@ -25,11 +32,11 @@ Matrix AA = args(2).matrix_value (); ColumnVector AAx = args(3).VECTOR_VALUE (); const double t = args(4).double_value (); const int Nx = (int) (args(5).double_value ()); const ColumnVector openx = args(6).VECTOR_VALUE (); -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) register int row, col; for (row = 0; row < Nx; row++) { @@ -61,11 +68,11 @@ { x (row) = 0.0; } } -#ifdef STANDALONE +#if (CODEGENTARGET == STANDALONE) return x; -#else // !STANDALONE +#elif (CODEGENTARGET == OCTAVEDLD) return octave_value (x); -#endif // STANDALONE +#endif // (CODEGENTARGET == STANDALONE) }