Mercurial > hg > octave-max
changeset 3993:f23bc69132cc
[project @ 2002-07-16 20:18:56 by jwe]
author | jwe |
---|---|
date | Tue, 16 Jul 2002 20:18:57 +0000 |
parents | 53b4eab68976 |
children | a41827ec5677 |
files | liboctave/ChangeLog liboctave/DAERTFunc.h liboctave/DASRT.cc liboctave/DASSL.cc src/ChangeLog src/DLD-FUNCTIONS/dasrt.cc |
diffstat | 6 files changed, 52 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -2,6 +2,7 @@ * DASRT.h (DASRT::set_ng, DASRT::get_ng): Delete * DASRT.cc (DASRT::DASRT): Set ng here. + (DASRT::integrate): Don't forget to set nn. * DAEFunc.h (DAEFunc): Jacobian function now follows format of DASSL. * DASSL.cc (ddassl_j): Make it work.
--- a/liboctave/DAERTFunc.h +++ b/liboctave/DAERTFunc.h @@ -26,7 +26,7 @@ #include "dMatrix.h" class -DAERTFunc : DAEFunc +DAERTFunc : public DAEFunc { public:
--- a/liboctave/DASRT.cc +++ b/liboctave/DASRT.cc @@ -73,6 +73,7 @@ static DAEFunc::DAERHSFunc user_fsub; static DAEFunc::DAEJacFunc user_jsub; static DAERTFunc::DAERTConstrFunc user_csub; + static int nn; static int @@ -303,6 +304,8 @@ integration_error = false; + nn = n; + user_fsub = DAEFunc::function (); user_jsub = DAEFunc::jacobian_function (); user_csub = DAERTFunc::constraint_function ();
--- a/liboctave/DASSL.cc +++ b/liboctave/DASSL.cc @@ -51,6 +51,7 @@ static DAEFunc::DAERHSFunc user_fun; static DAEFunc::DAEJacFunc user_jac; + static int nn; DASSL::DASSL (void) : DAE () @@ -215,6 +216,7 @@ double *pxdot = xdot.fortran_vec (); nn = n; + user_fun = DAEFunc::fun; user_jac = DAEFunc::jac;
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,8 @@ 2002-07-16 John W. Eaton <jwe@bevo.che.wisc.edu> * DLD-FUNCTIONS/dasrt.cc (Fdasrt): No need to find ng here. + (dasrt_user_j): New function. + (Fdasrt): Handle Jacobian function. * DLD-FUNCTIONS/dassl.cc (dassl_user_jacobian): New function. (Fdassl): Handle Jacobian function.
--- a/src/DLD-FUNCTIONS/dasrt.cc +++ b/src/DLD-FUNCTIONS/dasrt.cc @@ -54,7 +54,7 @@ static ColumnVector dasrt_user_f (const ColumnVector& x, const ColumnVector& xprime, - double t, int& ires) + double t, int& ires) { ColumnVector retval; @@ -62,24 +62,24 @@ int n = x.length (); + args(2) = t; + if (n > 1) { + args(1) = xprime; args(0) = x; - args(1) = xprime; } else if (n == 1) { + args(1) = xprime(0); args(0) = x(0); - args(1) = xprime(0); } else { + args(1) = Matrix (); args(0) = Matrix (); - args(1) = Matrix (); } - args(2) = t; - if (dasrt_f) { octave_value_list tmp = dasrt_f->do_multi_index_op (1, args); @@ -146,48 +146,48 @@ return retval; } -static ColumnVector -dasrt_dumb_cf (const ColumnVector& x, double t) -{ - ColumnVector retval (1, 1.0); - return retval; -} - -#if 0 static Matrix -dasrt_user_mf (double t, const ColumnVector& x, const ColumnVector& xprime, - const double& cj, octave_function *mf) +dasrt_user_j (const ColumnVector& x, const ColumnVector& xdot, + double t, double cj) { Matrix retval; - if (mf) - { - octave_value_list args; + int nstates = x.capacity (); + + assert (nstates == xdot.capacity ()); - int n = x.length (); + octave_value_list args; + + args(3) = cj; + args(2) = t; - if (n > 1) - { - args(0) = x; - args(1) = xprime; - args(3) = cj; - } - else if (n == 1) - { - args(0) = x(0); - args(1) = xprime(0); - args(3) = cj; - } - else - { - args(0) = Matrix (); - args(1) = Matrix (); - args(3) = Matrix (); - } + if (nstates > 1) + { + Matrix m1 (nstates, 1); + Matrix m2 (nstates, 1); + for (int i = 0; i < nstates; i++) + { + m1 (i, 0) = x (i); + m2 (i, 0) = xdot (i); + } + octave_value state (m1); + octave_value deriv (m2); + args(1) = deriv; + args(0) = state; + } + else + { + double d1 = x (0); + double d2 = xdot (0); + octave_value state (d1); + octave_value deriv (d2); + args(1) = deriv; + args(0) = state; + } - args(2) = t; - - octave_value_list tmp = mf->do_multi_index_op (1, args); + if (dasrt_j) + { + octave_value_list tmp = dasrt_j->do_multi_index_op (1, args); if (error_state) { @@ -195,7 +195,8 @@ return retval; } - if (tmp.length () > 0 && tmp(0).is_defined ()) + int tlen = tmp.length (); + if (tlen > 0 && tmp(0).is_defined ()) { retval = tmp(0).matrix_value (); @@ -209,13 +210,6 @@ return retval; } -static Matrix -dasrt_user_j (const ColumnVector& x, const ColumnVector& xprime, double t) -{ - return dasrt_user_mf (t, x, xprime, dasrt_j); -} -#endif - #define DASRT_ABORT \ do \ { \ @@ -446,10 +440,8 @@ crit_times_set = true; } -#if 0 if (dasrt_j) func.set_jacobian_function (dasrt_user_j); -#endif DASRT_result output;