Index: mttroot/mtt/bin/mtt ================================================================== --- mttroot/mtt/bin/mtt +++ mttroot/mtt/bin/mtt @@ -13,10 +13,13 @@ ############################################################### ## Version control history ############################################################### ## $Header$ ## $Log$ +## Revision 1.293.2.3 2001/03/01 05:05:53 geraint +## Minor revisions. +## ## Revision 1.293.2.2 2001/02/23 03:53:53 geraint ## Minor revisions. (ode2odes.exe works on GNU/Linux and ~GNU/Irix) ## ## Revision 1.293.2.1 2001/02/22 06:41:40 geraint ## Initial merge of ode2odes.exe into main mtt. @@ -1845,10 +1848,11 @@ .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 +.PRECIOUS: mtt_%.o mtt_%.o: mtt_%.cc echo Compiling mtt_\$*.cc ${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DSTANDALONE $define_octave_dev # Generates code to write reduce code @@ -2074,33 +2078,38 @@ endif # Dummy target FORCE: -ode2odes_common.m : $1_input.m $1_logic.m $1_numpar.m $1_simpar.m $1_state.m - @echo > /dev/null -ode2odes_common.cc : $1_input.cc $1_logic.cc $1_numpar.cc $1_simpar.cc $1_state.cc - @echo > /dev/null -ode2odes_common.o : $1_input.o $1_logic.o $1_numpar.o $1_simpar.o $1_state.o mtt_euler.o mtt_implicit.o - @echo > /dev/null -ode2odes_common.oct : $1_input.oct $1_logic.oct $1_numpar.oct $1_simpar.oct $1_state.oct mtt_euler.oct mtt_implicit.oct - @echo > /dev/null -ode2odes_euler.m : $1_ode.m $1_odeo.m - @echo > /dev/null -ode2odes_euler.cc : $1_ode.cc $1_odeo.cc - @echo > /dev/null -ode2odes_euler.o : $1_ode.o $1_odeo.o - @echo > /dev/null -ode2odes_euler.oct : $1_ode.oct $1_odeo.oct - @echo > /dev/null -ode2odes_implicit.m : $1_cseo.m $1_csex.m $1_smxa.m $1_smxax.m - @echo > /dev/null -ode2odes_implicit.cc : $1_cseo.cc $1_csex.cc $1_smxa.cc $1_smxax.cc - @echo > /dev/null -ode2odes_implicit.o : $1_cseo.o $1_csex.o $1_smxa.o $1_smxax.o - @echo > /dev/null -ode2odes_implicit.oct: $1_cseo.oct $1_csex.oct $1_smxa.oct $1_smxax.oct +$1_ode2odes_common.m : $1_input.m $1_logic.m $1_numpar.m $1_simpar.m $1_state.m + @echo > /dev/null +$1_ode2odes_common.cc : $1_input.cc $1_logic.cc $1_numpar.cc $1_simpar.cc $1_state.cc + @echo > /dev/null +$1_ode2odes_common.o : $1_input.o $1_logic.o $1_numpar.o $1_simpar.o $1_state.o + @echo "Creating $1_ode2odes_common.o" + ar -c -r \$@ \$^ +$1_ode2odes_common.oct : $1_input.oct $1_logic.oct $1_numpar.oct $1_simpar.oct $1_state.oct + @echo > /dev/null + +$1_ode2odes_euler.m : $1_ode.m $1_odeo.m + @echo > /dev/null +$1_ode2odes_euler.cc : $1_ode.cc $1_odeo.cc + @echo > /dev/null +$1_ode2odes_euler.o : $1_ode.o $1_odeo.o mtt_euler.o + @echo "Creating $1_ode2odes_euler.o" + ar -c -r \$@ \$^ +$1_ode2odes_euler.oct : $1_ode.oct $1_odeo.oct mtt_euler.oct + @echo > /dev/null + +$1_ode2odes_implicit.m : $1_cseo.m $1_csex.m $1_smxa.m $1_smxax.m + @echo > /dev/null +$1_ode2odes_implicit.cc : $1_cseo.cc $1_csex.cc $1_smxa.cc $1_smxax.cc + @echo > /dev/null +$1_ode2odes_implicit.o : $1_cseo.o $1_csex.o $1_smxa.o $1_smxax.o mtt_implicit.o + @echo "Creating $1_ode2odes_implicit.o" + ar -c -r \$@ \$^ +$1_ode2odes_implicit.oct: $1_cseo.oct $1_csex.oct $1_smxa.oct $1_smxax.oct mtt_implicit.oct @echo > /dev/null #SUMMARY numpar numerical parameter declaration (m) $1_numpar.m: $1_numpar.txt $1_sympars.txt @@ -2413,26 +2422,28 @@ endif endif $1_ode2odes.exe: $1_def.h $1_sympar.h\ - $1_ode2odes.o ode2odes_common.o ode2odes_${integration_method}.o + $1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o echo Creating $1_ode2odes.exe - ${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_LDFLAGS} *.o ${MTT_CXXLIBS} -o $1_ode2odes.exe + ${MTT_CXX} ${MTT_CXXFLAGS} -o $1_ode2odes.exe\ + $1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o\ + ${MTT_LDFLAGS} ${MTT_CXXLIBS} -$1_ode2odes.o: $1_ode2odes.cc ode2odes_common.o ode2odes_${integration_method}.o +$1_ode2odes.o: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o echo Creating $1_ode2odes.o ${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DSTANDALONE -$1_ode2odes.oct: $1_ode2odes.cc ode2odes_common.oct ode2odes_${integration_method}.oct +$1_ode2odes.oct: $1_ode2odes.cc $1_ode2odes_common.oct $1_ode2odes_${integration_method}.oct touch $1_ode2odes.m echo Creating $1_ode2odes.oct $MKOCTFILE $1_ode2odes.cc $1_ode2odes.cc: $1_def.r $1_sympars.txt\ - ode2odes_common.m ode2odes_common.cc\ - ode2odes_${integration_method}.m ode2odes_${integration_method}.cc + $1_ode2odes_common.m $1_ode2odes_common.cc\ + $1_ode2odes_${integration_method}.m $1_ode2odes_${integration_method}.cc touch $1_ode2odes.m make_ode2odes $1 cc $integration_method #Conversion of m to p to c #SUMMARY ode ordinary differential equations (c) 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.51.2.1 2001/03/01 05:05:53 geraint +## Minor revisions. +## ## Revision 1.51 2001/02/19 06:33:19 geraint ## Removed operation form loop. ## ## Revision 1.50 2001/02/18 09:18:49 geraint ## Removed temporary Matrices from mtt_implicit.cc @@ -295,25 +298,30 @@ #include "${sys}_def.h" #include "${sys}_sympar.h" #ifdef STANDALONE -extern ColumnVector Fmtt_euler ( - ColumnVector &x, - const ColumnVector &dx, - const double &ddt, - const int &nx, - const ColumnVector &open_switches); - -extern ColumnVector Fmtt_implicit ( - ColumnVector &x, - ColumnVector &dx, - Matrix &AA, - ColumnVector &AAx, - const double &ddt, - const int &nx, - const ColumnVector &open_switches); +extern ColumnVector F${sys}_input ( + ColumnVector &x, + ColumnVector &y, + const double &t, + ColumnVector &par); + +extern ColumnVector F${sys}_logic ( + ColumnVector &x, + ColumnVector &u, + const double &t, + ColumnVector &par); + +extern ColumnVector F${sys}_numpar ( + void); + +extern Octave_map F${sys}_simpar ( + void); + +extern ColumnVector F${sys}_state ( + ColumnVector &x); extern ColumnVector F${sys}_${ode} ( ColumnVector &x, ColumnVector &u, const double &t, @@ -323,21 +331,31 @@ ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par); -extern ColumnVector F${sys}_input ( +EOF +if [ "$method" != "implicit" ]; then +cat <> $filename +extern ColumnVector Fmtt_euler ( + ColumnVector &x, + const ColumnVector &dx, + const double &ddt, + const int &nx, + const ColumnVector &open_switches); + +EOF +else +cat <> $filename +extern ColumnVector Fmtt_implicit ( ColumnVector &x, - ColumnVector &y, - const double &t, - ColumnVector &par); - -extern ColumnVector F${sys}_numpar ( - void); - -extern Octave_map F${sys}_simpar ( - void); + ColumnVector &dx, + Matrix &AA, + ColumnVector &AAx, + const double &ddt, + const int &nx, + const ColumnVector &open_switches); extern Matrix F${sys}_smxa ( ColumnVector &x, ColumnVector &u, const double &t, @@ -347,20 +365,98 @@ ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par); -extern ColumnVector F${sys}_state ( - ColumnVector &x); - -extern ColumnVector F${sys}_logic ( - ColumnVector &x, - ColumnVector &u, - const double &t, - ColumnVector &par); +EOF +fi +cat <> $filename #endif // STANDALONE + +inline ColumnVector +mtt_input (ColumnVector &x, + ColumnVector &y, + const double &t, + ColumnVector &par) +{ +#ifdef STANDALONE + return F${sys}_input (x, y, t, par); +#else + 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); + return f(0).${vector_value} (); +#endif +} + +inline ColumnVector +mtt_logic (ColumnVector &x, + ColumnVector &u, + const double &t, + ColumnVector &par) +{ +#ifdef STANDALONE + return F${sys}_logic (x, u, t, par); +#else + 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 +} + +inline ColumnVector +mtt_numpar (void) +{ +#ifdef STANDALONE + return F${sys}_numpar (); +#else + static octave_value_list args, f; + f = feval ("${sys}_numpar", args, 1); + return f(0).${vector_value} (); +#endif +} + +inline Octave_map +mtt_simpar (void) +{ +#ifdef STANDALONE + return F${sys}_simpar (); +#else + static octave_value_list args; + static Octave_map f; + f["first"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["first"]; + f["dt"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["dt"]; + f["last"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["last"]; + f["stepfactor"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["stepfactor"]; + f["wmin"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["wmin"]; + f["wmax"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["wmax"]; + f["wsteps"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["wsteps"]; + f["input"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["input"]; + return (f); +#endif +} + +inline ColumnVector +mtt_state (ColumnVector &x) +{ +#ifdef STANDALONE + return F${sys}_state (x); +#else + static octave_value_list args, f; + args (0) = octave_value (x); + f = feval ("${sys}_state", args, 1); + return f(0).${vector_value} (); +#endif +} inline ColumnVector mtt_${ode} (ColumnVector &x, ColumnVector &u, const double &t, @@ -396,10 +492,37 @@ f = feval ("${sys}_${odeo}", args, 1); return f(0).${vector_value} (); #endif } +EOF +if [ "$method" != "implicit" ];then +cat <> $filename +inline ColumnVector +mtt_euler (ColumnVector &x, + const ColumnVector &dx, + const double &ddt, + const int &nx, + const ColumnVector &open_switches) +{ +#ifdef STANDALONE + return Fmtt_euler (x, dx, ddt, nx, open_switches); +#else + 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 +} + +EOF +else +cat <> $filename inline ColumnVector mtt_implicit (ColumnVector &x, ColumnVector &dx, Matrix &AA, ColumnVector &AAx, @@ -421,82 +544,10 @@ f = feval ("mtt_implicit", args, 1); return f(0).${vector_value} (); #endif } -inline ColumnVector -mtt_euler (ColumnVector &x, - const ColumnVector &dx, - const double &ddt, - const int &nx, - const ColumnVector &open_switches) -{ -#ifdef STANDALONE - return Fmtt_euler (x, dx, ddt, nx, open_switches); -#else - 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 -} - -inline ColumnVector -mtt_input (ColumnVector &x, - ColumnVector &y, - const double &t, - ColumnVector &par) -{ -#ifdef STANDALONE - return F${sys}_input (x, y, t, par); -#else - 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); - return f(0).${vector_value} (); -#endif -} - -inline ColumnVector -mtt_numpar (void) -{ -#ifdef STANDALONE - return F${sys}_numpar (); -#else - static octave_value_list args, f; - f = feval ("${sys}_numpar", args, 1); - return f(0).${vector_value} (); -#endif -} - -inline Octave_map -mtt_simpar (void) -{ -#ifdef STANDALONE - return F${sys}_simpar (); -#else - static octave_value_list args; - static Octave_map f; - f["first"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["first"]; - f["dt"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["dt"]; - f["last"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["last"]; - f["stepfactor"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["stepfactor"]; - f["wmin"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["wmin"]; - f["wmax"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["wmax"]; - f["wsteps"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["wsteps"]; - f["input"] = feval ("${sys}_simpar", args, 1)(0).map_value ()["input"]; - return (f); -#endif -} - inline Matrix mtt_smxa (ColumnVector &x, ColumnVector &u, const double &t, ColumnVector &par) @@ -531,42 +582,13 @@ f = feval ("${sys}_smxax", args, 1); return f(0).${vector_value} (); #endif } -inline ColumnVector -mtt_state (ColumnVector &x) -{ -#ifdef STANDALONE - return F${sys}_state (x); -#else - static octave_value_list args, f; - args (0) = octave_value (x); - f = feval ("${sys}_state", args, 1); - return f(0).${vector_value} (); -#endif -} - -inline ColumnVector -mtt_logic (ColumnVector &x, - ColumnVector &u, - const double &t, - ColumnVector &par) -{ -#ifdef STANDALONE - return F${sys}_logic (x, u, t, par); -#else - 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 -} - +EOF +fi +cat <> $filename inline void mtt_write (const double &t, ColumnVector &x, ColumnVector &y, @@ -602,11 +624,11 @@ #ifdef STANDALONE int main (void) { #else DEFUN_DLD (${sys}_ode2odes, args, , -"Octave ode2odes representation of system +"Octave ode2odes representation of system with $method integration method Usage: ${sys}_ode2odes (x, par, simpar) ") { static octave_value_list retval; #endif // STANDALONE