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.49 2001/02/14 06:06:34 geraint +## Removed octave_value_list wrappers from standalone.exe - speed improvements +## ## Revision 1.48 2001/02/11 07:08:59 geraint ## Static declarations of octave_value_lists: small .exe speed improvement ## ## Revision 1.47 2001/02/11 05:25:52 geraint ## Reduced number of matrix operations during .oct simulation data write @@ -286,59 +289,70 @@ #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, - const ColumnVector &dx, - const Matrix &AA, - const ColumnVector &AAx, - const double &ddt, - const int &nx, - const ColumnVector &open_switches); - -extern ColumnVector F${sys}_${ode} ( ColumnVector &x, - ColumnVector &u, - const double &t, - ColumnVector &par); - -extern ColumnVector F${sys}_${odeo} ( ColumnVector &x, - ColumnVector &u, - const double &t, - ColumnVector &par); - -extern ColumnVector F${sys}_input ( ColumnVector &x, - ColumnVector &y, - const double &t, - ColumnVector &par); - -extern ColumnVector F${sys}_numpar ( void); - -extern Octave_map F${sys}_simpar ( void); - -extern Matrix F${sys}_smxa ( ColumnVector &x, - ColumnVector &u, - const double &t, - ColumnVector &par); - -extern ColumnVector F${sys}_smxax ( 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); +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, + const ColumnVector &AAx, + const double &ddt, + const int &nx, + const ColumnVector &open_switches); + +extern ColumnVector F${sys}_${ode} ( + ColumnVector &x, + ColumnVector &u, + const double &t, + ColumnVector &par); + +extern ColumnVector F${sys}_${odeo} ( + ColumnVector &x, + ColumnVector &u, + const double &t, + ColumnVector &par); + +extern ColumnVector F${sys}_input ( + ColumnVector &x, + ColumnVector &y, + const double &t, + ColumnVector &par); + +extern ColumnVector F${sys}_numpar ( + void); + +extern Octave_map F${sys}_simpar ( + void); + +extern Matrix F${sys}_smxa ( + ColumnVector &x, + ColumnVector &u, + const double &t, + ColumnVector &par); + +extern ColumnVector F${sys}_smxax ( + 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); #endif // STANDALONE inline ColumnVector mtt_${ode} (ColumnVector &x, @@ -378,12 +392,12 @@ #endif } inline ColumnVector mtt_implicit (ColumnVector &x, - const ColumnVector &dx, - const Matrix &AA, + ColumnVector &dx, + Matrix &AA, const ColumnVector &AAx, const double &ddt, const int &nx, const ColumnVector &open_switches) { Index: mttroot/mtt/lib/cc/mtt_implicit.cc ================================================================== --- mttroot/mtt/lib/cc/mtt_implicit.cc +++ mttroot/mtt/lib/cc/mtt_implicit.cc @@ -1,12 +1,12 @@ #include #include #ifdef STANDALONE ColumnVector Fmtt_implicit ( ColumnVector &x, - const ColumnVector &dx, - const Matrix &AA, + ColumnVector &dx, + Matrix &AA, const ColumnVector &AAx, const double &t, const int &Nx, const ColumnVector &openx) { @@ -31,64 +31,35 @@ const int Nx = (int) (args(5).double_value ()); const ColumnVector openx = args(6).vector_value (); #endif // OCTAVE_DEV #endif // STANDALONE - register int i, n; - register int col_old, col_new; - register int row_old, row_new; - - n = Nx; - for (i = 0; i < Nx; i++) - { - if (0 != openx (i)) - { - n--; - } - } - - static Matrix tmp_dx (n,1); - static Matrix tmp_x (n,1); - static Matrix tmp_AAx (n,1); - static Matrix tmp_AA (n,n); - - for (row_new = row_old = 0; row_old < Nx; row_old++) - { - if (0 == openx (row_old)) - { - tmp_dx (row_new,0) = dx (row_old); - tmp_AAx (row_new,0) = AAx (row_old); - for (col_new = col_old = 0; col_old < Nx; col_old++) - { - if (0 == openx (col_old)) - { - // xxx: this can be improved by symmetry - tmp_AA (row_new,col_new) = AA (row_old,col_old); - col_new++; - } - } - row_new++; - } - } - - tmp_x = xleftdiv (tmp_AA, (tmp_AAx + tmp_dx * t)); - - row_new = 0; - for (row_old = 0; row_old < Nx; row_old++) - { - if (0 == openx (row_old)) - { - x (row_old) = tmp_x (row_new,0); - row_new++; - } - else - { - x (row_old) = 0.0; + register int row, col; + + for (row = 0; row < Nx; row++) + { + if (0 != openx (row)) + { + dx (row) = 0.0; + for (col = 0; col < Nx; col++) + { + AA (row,col) = AA (col,row) = 0.0; + } + } + } + + x = static_cast (xleftdiv (AA, static_cast(AAx + dx * t))); + + for (row = 0; row < Nx; row++) + { + if (0 != openx (row)) + { + x (row) = 0.0; } } #ifdef STANDALONE return x; #else // !STANDALONE return octave_value (x); #endif // STANDALONE }