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.47 2001/02/11 05:25:52 geraint +## Reduced number of matrix operations during .oct simulation data write +## ## Revision 1.46 2001/02/05 08:32:31 geraint ## typo ## ## Revision 1.45 2001/02/05 04:32:35 geraint ## Octave version 2.1.x compatability and #ifdef statements for standalone rep @@ -298,11 +301,11 @@ mtt_${ode} (const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par) { - octave_value_list args, f; + 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); #ifdef STANDALONE @@ -317,11 +320,11 @@ mtt_${odeo} (const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par) { - octave_value_list args, f; + 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); #ifdef STANDALONE @@ -339,11 +342,11 @@ const ColumnVector &AAx, const double &ddt, const int &nx, const ColumnVector &open_switches) { - octave_value_list args, f; + 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); args (4) = octave_value (ddt); @@ -362,11 +365,11 @@ const ColumnVector &dx, const double &ddt, const int &nx, const ColumnVector &open_switches) { - octave_value_list args, f; + 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); @@ -382,16 +385,15 @@ mtt_input (const ColumnVector &x, const ColumnVector &y, const double &t, const ColumnVector &par) { - octave_value_list args; + 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); - octave_value_list f; #ifdef STANDALONE f = F${sys}_input (args, 1); #else f = feval ("${sys}_input", args, 1); #endif @@ -399,12 +401,11 @@ } inline ColumnVector mtt_numpar (void) { - octave_value_list args; - octave_value_list f; + static octave_value_list args, f; #ifdef STANDALONE f = F${sys}_numpar (args, 1); #else f = feval ("${sys}_numpar", args, 1); #endif @@ -412,12 +413,12 @@ } inline Octave_map mtt_simpar (void) { - octave_value_list args; - Octave_map f; + static octave_value_list args; + static Octave_map f; #ifdef STANDALONE f["first"] = F${sys}_simpar (args, 1)(0).map_value ()["first"]; f["dt"] = F${sys}_simpar (args, 1)(0).map_value ()["dt"]; f["last"] = F${sys}_simpar (args, 1)(0).map_value ()["last"]; f["stepfactor"] = F${sys}_simpar (args, 1)(0).map_value ()["stepfactor"]; @@ -442,16 +443,15 @@ mtt_smxa (const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par) { - octave_value_list args; + 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); - octave_value_list f; #ifdef STANDALONE f = F${sys}_smxa (args, 1); #else f = feval ("${sys}_smxa", args, 1); #endif @@ -462,16 +462,15 @@ mtt_smxax (const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par) { - octave_value_list args; + 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); - octave_value_list f; #ifdef STANDALONE f = F${sys}_smxax (args, 1); #else f = feval ("${sys}_smxax", args, 1); #endif @@ -479,13 +478,12 @@ } inline ColumnVector mtt_state (const ColumnVector &x) { - octave_value_list args; + static octave_value_list args, f; args (0) = octave_value (x); - octave_value_list f; #ifdef STANDALONE f = F${sys}_state (args, 1); #else f = feval ("${sys}_state", args, 1); #endif @@ -496,17 +494,16 @@ mtt_logic (const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par) { - octave_value_list args; + 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); - octave_value_list f; #ifdef STANDALONE f = F${sys}_logic (args, 1); #else f = feval ("${sys}_logic", args, 1); #endif @@ -526,22 +523,22 @@ register int col = 0; if (0 == row) data = Matrix (nrows, 1+ny+1+nx, 0.0); - data (row, col) = t; + data.elem (row, col) = t; for (register int i = 0; i < ny; i++) - data (row, ++col) = y (i); - data (row, ++col) = t; + data.elem (row, ++col) = y.elem (i); + data.elem (row, ++col) = t; for (register int i = 0; i < nx; i++) - data (row, ++col) = x (i); + data.elem (row, ++col) = x.elem (i); row++; if (nrows == row) #ifdef STANDALONE - cout << data; + cout << data << endl; #else // ! STANDALONE set_global_value ("MTT_data", data); #endif } @@ -550,17 +547,17 @@ DEFUN_DLD (${sys}_ode2odes, args, , "Octave ode2odes representation of system Usage: ${sys}_ode2odes (x, par, simpar) ") { - octave_value_list retval; + static octave_value_list retval; - ColumnVector x; - ColumnVector par; - Octave_map simpar; + static ColumnVector x; + static ColumnVector par; + static Octave_map simpar; - double + static double first = 0.0, dt = 0.0, last = 0.0, stepfactor = 0.0; @@ -602,18 +599,18 @@ default: usage("${sys}_ode2odes (x par simpar)", nargin); error("aborting."); } - ColumnVector dx (MTTNX); - ColumnVector u (MTTNU); - ColumnVector y (MTTNY); - - Matrix AA (MTTNX, MTTNX); - ColumnVector AAx (MTTNX); - - ColumnVector open_switches (MTTNX); + static ColumnVector dx (MTTNX); + static ColumnVector u (MTTNU); + static ColumnVector y (MTTNY); + + static Matrix AA (MTTNX, MTTNX); + static ColumnVector AAx (MTTNX); + + static ColumnVector open_switches (MTTNX); register double t = 0.0; const double ddt = dt / stepfactor; const int ilast = static_cast (round ((last - first) / ddt)) + 1; Index: mttroot/mtt/lib/cc/mtt_implicit.cc ================================================================== --- mttroot/mtt/lib/cc/mtt_implicit.cc +++ mttroot/mtt/lib/cc/mtt_implicit.cc @@ -59,19 +59,19 @@ DEFUN_DLD (mtt_implicit, args, , "implicit integration method") { #ifdef OCTAVE_DEV - ColumnVector x = args(0).column_vector_value (); + static ColumnVector x = args(0).column_vector_value (); const ColumnVector dx = args(1).column_vector_value (); const Matrix AA = args(2).matrix_value (); const ColumnVector AAx = args(3).column_vector_value (); const double t = args(4).double_value (); const int Nx = (int) (args(5).double_value ()); const ColumnVector openx = args(6).column_vector_value (); #else - ColumnVector x = args(0).vector_value (); + static ColumnVector x = args(0).vector_value (); const ColumnVector dx = args(1).vector_value (); const Matrix AA = args(2).matrix_value (); const ColumnVector AAx = args(3).vector_value (); const double t = args(4).double_value (); const int Nx = (int) (args(5).double_value ()); @@ -89,14 +89,14 @@ { n--; } } - ColumnVector tmp_dx (n, 0.0); - ColumnVector tmp_x (n, 0.0); - ColumnVector tmp_AAx (n, 0.0); - Matrix tmp_AA (n, n, 0.0); + static ColumnVector tmp_dx (n); + static ColumnVector tmp_x (n); + static ColumnVector tmp_AAx (n); + static Matrix tmp_AA (n, n); for (row_new = row_old = 0; row_old < Nx; row_old++) { if (0 == openx (row_old)) {