Mercurial > hg > octave-nkf
comparison liboctave/DASPK.cc @ 3995:ee0304212be0
[project @ 2002-07-17 04:32:42 by jwe]
author | jwe |
---|---|
date | Wed, 17 Jul 2002 04:32:42 +0000 |
parents | 48d2bc4a3729 |
children | 98107d72871c |
comparison
equal
deleted
inserted
replaced
3994:a41827ec5677 | 3995:ee0304212be0 |
---|---|
62 static DAEFunc::DAEJacFunc user_jac; | 62 static DAEFunc::DAEJacFunc user_jac; |
63 static int nn; | 63 static int nn; |
64 | 64 |
65 DASPK::DASPK (void) : DAE () | 65 DASPK::DASPK (void) : DAE () |
66 { | 66 { |
67 stop_time_set = 0; | |
68 stop_time = 0.0; | |
69 | |
70 sanity_checked = 0; | 67 sanity_checked = 0; |
71 | 68 |
72 info.resize (15); | 69 info.resize (15); |
73 | 70 |
74 for (int i = 0; i < 15; i++) | 71 for (int i = 0; i < 15; i++) |
77 | 74 |
78 DASPK::DASPK (const ColumnVector& state, double time, DAEFunc& f) | 75 DASPK::DASPK (const ColumnVector& state, double time, DAEFunc& f) |
79 : DAE (state, time, f) | 76 : DAE (state, time, f) |
80 { | 77 { |
81 n = size (); | 78 n = size (); |
82 | |
83 stop_time_set = 0; | |
84 stop_time = 0.0; | |
85 | 79 |
86 sanity_checked = 0; | 80 sanity_checked = 0; |
87 | 81 |
88 info.resize (20); | 82 info.resize (20); |
89 | 83 |
95 double time, DAEFunc& f) | 89 double time, DAEFunc& f) |
96 : DAE (state, deriv, time, f) | 90 : DAE (state, deriv, time, f) |
97 { | 91 { |
98 n = size (); | 92 n = size (); |
99 | 93 |
100 stop_time_set = 0; | |
101 stop_time = 0.0; | |
102 | |
103 DAEFunc::set_function (f.function ()); | 94 DAEFunc::set_function (f.function ()); |
104 DAEFunc::set_jacobian_function (f.jacobian_function ()); | 95 DAEFunc::set_jacobian_function (f.jacobian_function ()); |
105 | 96 |
106 sanity_checked = 0; | 97 sanity_checked = 0; |
107 | 98 |
108 info.resize (20); | 99 info.resize (20); |
109 | 100 |
110 for (int i = 0; i < 20; i++) | 101 for (int i = 0; i < 20; i++) |
111 info.elem (i) = 0; | 102 info.elem (i) = 0; |
112 } | |
113 | |
114 void | |
115 DASPK::force_restart (void) | |
116 { | |
117 restart = 1; | |
118 integration_error = 0; | |
119 } | |
120 | |
121 void | |
122 DASPK::set_stop_time (double tt) | |
123 { | |
124 stop_time_set = 1; | |
125 stop_time = tt; | |
126 } | |
127 | |
128 void | |
129 DASPK::clear_stop_time (void) | |
130 { | |
131 stop_time_set = 0; | |
132 } | 103 } |
133 | 104 |
134 int | 105 int |
135 ddaspk_f (const double& time, const double *state, const double *deriv, | 106 ddaspk_f (const double& time, const double *state, const double *deriv, |
136 const double&, double *delta, int& ires, double *, int *) | 107 const double&, double *delta, int& ires, double *, int *) |
205 { | 176 { |
206 ColumnVector retval; | 177 ColumnVector retval; |
207 | 178 |
208 if (restart) | 179 if (restart) |
209 { | 180 { |
210 restart = 0; | 181 restart = false; |
211 info.elem (0) = 0; | 182 info.elem (0) = 0; |
212 } | 183 } |
213 | 184 |
214 liw = 40 + n; | 185 liw = 40 + n; |
215 if (info(9) == 1 || info(9) == 3) | 186 if (info(9) == 1 || info(9) == 3) |
227 iwork.resize (liw); | 198 iwork.resize (liw); |
228 | 199 |
229 if (rwork.length () != lrw) | 200 if (rwork.length () != lrw) |
230 rwork.resize (lrw); | 201 rwork.resize (lrw); |
231 | 202 |
232 integration_error = 0; | 203 integration_error = false; |
233 | 204 |
234 if (DAEFunc::jacobian_function ()) | 205 if (DAEFunc::jacobian_function ()) |
235 info.elem (4) = 1; | 206 info.elem (4) = 1; |
236 else | 207 else |
237 info.elem (4) = 0; | 208 info.elem (4) = 0; |
252 if (res.length () != x.length ()) | 223 if (res.length () != x.length ()) |
253 { | 224 { |
254 (*current_liboctave_error_handler) | 225 (*current_liboctave_error_handler) |
255 ("daspk: inconsistent sizes for state and residual vectors"); | 226 ("daspk: inconsistent sizes for state and residual vectors"); |
256 | 227 |
257 integration_error = 1; | 228 integration_error = true; |
258 return retval; | 229 return retval; |
259 } | 230 } |
260 | 231 |
261 sanity_checked = 1; | 232 sanity_checked = 1; |
262 } | 233 } |
302 piwork, liw, dummy, idummy, ddaspk_j, | 273 piwork, liw, dummy, idummy, ddaspk_j, |
303 ddaspk_psol)); | 274 ddaspk_psol)); |
304 | 275 |
305 if (f77_exception_encountered) | 276 if (f77_exception_encountered) |
306 { | 277 { |
307 integration_error = 1; | 278 integration_error = true; |
308 (*current_liboctave_error_handler) ("unrecoverable error in daspk"); | 279 (*current_liboctave_error_handler) ("unrecoverable error in daspk"); |
309 } | 280 } |
310 else | 281 else |
311 { | 282 { |
312 switch (idid) | 283 switch (idid) |
344 case -33: // The code has encountered trouble from which it cannot | 315 case -33: // The code has encountered trouble from which it cannot |
345 // recover. A message is printed explaining the trouble | 316 // recover. A message is printed explaining the trouble |
346 // and control is returned to the calling program. For | 317 // and control is returned to the calling program. For |
347 // example, this occurs when invalid input is detected. | 318 // example, this occurs when invalid input is detected. |
348 default: | 319 default: |
349 integration_error = 1; | 320 integration_error = true; |
350 break; | 321 break; |
351 } | 322 } |
352 } | 323 } |
353 | 324 |
354 return retval; | 325 return retval; |
503 } | 474 } |
504 | 475 |
505 return retval; | 476 return retval; |
506 } | 477 } |
507 | 478 |
479 std::string | |
480 DASPK::error_message (void) const | |
481 { | |
482 std::string retval; | |
483 | |
484 switch (idid) | |
485 { | |
486 default: | |
487 retval = "unknown error state"; | |
488 break; | |
489 } | |
490 | |
491 return retval; | |
492 } | |
493 | |
508 /* | 494 /* |
509 ;;; Local Variables: *** | 495 ;;; Local Variables: *** |
510 ;;; mode: C++ *** | 496 ;;; mode: C++ *** |
511 ;;; End: *** | 497 ;;; End: *** |
512 */ | 498 */ |