annotate liboctave/DASPK.cc @ 11502:4638800cd660

delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
author John W. Eaton <jwe@octave.org>
date Thu, 13 Jan 2011 03:16:40 -0500
parents 8a5e980da6aa
children fd0a3ac60b0e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
1 /*
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
2
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 7482
diff changeset
3 Copyright (C) 1996, 1997, 2002, 2003, 2004, 2005, 2006, 2007, 2008
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 John W. Eaton
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
5
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
7
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
11 option) any later version.
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
12
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
16 for more details.
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
17
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
20 <http://www.gnu.org/licenses/>.
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
21
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
22 */
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
23
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
25 #include <config.h>
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
26 #endif
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
27
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
28 #include <cfloat>
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
29
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5307
diff changeset
30 #include <sstream>
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5307
diff changeset
31
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
32 #include "DASPK.h"
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
33 #include "f77-fcn.h"
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
34 #include "lo-error.h"
7231
2eb392d058bb [project @ 2007-11-30 18:53:29 by jwe]
jwe
parents: 7017
diff changeset
35 #include "lo-math.h"
4155
61fba034b13b [project @ 2002-11-07 18:46:13 by jwe]
jwe
parents: 4144
diff changeset
36 #include "quit.h"
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
37
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
38 typedef octave_idx_type (*daspk_fcn_ptr) (const double&, const double*,
11495
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
39 const double*, const double&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
40 double*, octave_idx_type&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
41 double*, octave_idx_type*);
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
42
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
43 typedef octave_idx_type (*daspk_jac_ptr) (const double&, const double*,
11495
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
44 const double*, double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
45 const double&, double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
46 octave_idx_type*);
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
47
11495
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
48 typedef octave_idx_type (*daspk_psol_ptr) (const octave_idx_type&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
49 const double&, const double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
50 const double*, const double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
51 const double&, const double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
52 double*, octave_idx_type*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
53 double*, const double&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
54 octave_idx_type&, double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
55 octave_idx_type*);
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
56
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
57 extern "C"
4552
6f3382e08a52 [project @ 2003-10-27 20:38:02 by jwe]
jwe
parents: 4192
diff changeset
58 {
6f3382e08a52 [project @ 2003-10-27 20:38:02 by jwe]
jwe
parents: 4192
diff changeset
59 F77_RET_T
11495
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
60 F77_FUNC (ddaspk, DDASPK) (daspk_fcn_ptr, const octave_idx_type&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
61 double&, double*, double*, double&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
62 const octave_idx_type*, const double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
63 const double*, octave_idx_type&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
64 double*, const octave_idx_type&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
65 octave_idx_type*, const octave_idx_type&,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
66 const double*, const octave_idx_type*,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
67 daspk_jac_ptr, daspk_psol_ptr);
4552
6f3382e08a52 [project @ 2003-10-27 20:38:02 by jwe]
jwe
parents: 4192
diff changeset
68 }
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
69
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
70 static DAEFunc::DAERHSFunc user_fun;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
71 static DAEFunc::DAEJacFunc user_jac;
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
72 static octave_idx_type nn;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
73
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
74 static octave_idx_type
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
75 ddaspk_f (const double& time, const double *state, const double *deriv,
11502
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
76 const double&, double *delta, octave_idx_type& ires, double *,
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
77 octave_idx_type *)
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
78 {
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
79 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
80
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
81 ColumnVector tmp_deriv (nn);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
82 ColumnVector tmp_state (nn);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
83 ColumnVector tmp_delta (nn);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
84
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
85 for (octave_idx_type i = 0; i < nn; i++)
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
86 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
87 tmp_deriv.elem (i) = deriv [i];
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
88 tmp_state.elem (i) = state [i];
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
89 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
90
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
91 tmp_delta = user_fun (tmp_state, tmp_deriv, time, ires);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
92
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
93 if (ires >= 0)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
94 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
95 if (tmp_delta.length () == 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
96 ires = -2;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
97 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
98 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
99 for (octave_idx_type i = 0; i < nn; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
100 delta [i] = tmp_delta.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
101 }
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
102 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
103
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
104 END_INTERRUPT_WITH_EXCEPTIONS;
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
105
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
106 return 0;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
107 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
108
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
109 //NEQ, T, Y, YPRIME, SAVR, WK, CJ, WGHT,
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
110 //C WP, IWP, B, EPLIN, IER, RPAR, IPAR)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
111
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
112 static octave_idx_type
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
113 ddaspk_psol (const octave_idx_type&, const double&, const double *,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
114 const double *, const double *, const double&,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
115 const double *, double *, octave_idx_type *, double *,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
116 const double&, octave_idx_type&, double *, octave_idx_type*)
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
117 {
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
118 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
119
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
120 abort ();
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
121
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
122 END_INTERRUPT_WITH_EXCEPTIONS;
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
123
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3912
diff changeset
124 return 0;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
125 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
126
3991
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
127
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
128 static octave_idx_type
3991
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
129 ddaspk_j (const double& time, const double *state, const double *deriv,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
130 double *pd, const double& cj, double *, octave_idx_type *)
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
131 {
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
132 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
133
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5765
diff changeset
134 // FIXME -- would be nice to avoid copying the data.
3991
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
135
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
136 ColumnVector tmp_state (nn);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
137 ColumnVector tmp_deriv (nn);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
138
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
139 for (octave_idx_type i = 0; i < nn; i++)
3991
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
140 {
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
141 tmp_deriv.elem (i) = deriv [i];
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
142 tmp_state.elem (i) = state [i];
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
143 }
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
144
3991
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
145 Matrix tmp_pd = user_jac (tmp_state, tmp_deriv, time, cj);
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
146
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
147 for (octave_idx_type j = 0; j < nn; j++)
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
148 for (octave_idx_type i = 0; i < nn; i++)
3991
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
149 pd [nn * j + i] = tmp_pd.elem (i, j);
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
150
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
151 END_INTERRUPT_WITH_EXCEPTIONS;
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4155
diff changeset
152
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
153 return 0;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
154 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
155
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
156 ColumnVector
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
157 DASPK::do_integrate (double tout)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
158 {
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5765
diff changeset
159 // FIXME -- should handle all this option stuff just once
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
160 // for each new problem.
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
161
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
162 ColumnVector retval;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
163
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
164 if (! initialized || restart || DAEFunc::reset|| DASPK_options::reset)
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
165 {
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
166 integration_error = false;
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
167
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
168 initialized = true;
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
169
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
170 info.resize (20, 1);
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
171
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
172 for (octave_idx_type i = 0; i < 20; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
173 info(i) = 0;
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
174
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
175 octave_idx_type n = size ();
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
176
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
177 nn = n;
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
178
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
179 info(0) = 0;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
180
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
181 if (stop_time_set)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
182 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
183 rwork(0) = stop_time;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
184 info(3) = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
185 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
186 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
187 info(3) = 0;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
188
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
189 // DAEFunc
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
190
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
191 user_fun = DAEFunc::function ();
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
192 user_jac = DAEFunc::jacobian_function ();
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
193
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
194 if (user_fun)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
195 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
196 octave_idx_type ires = 0;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
197
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
198 ColumnVector res = (*user_fun) (x, xdot, t, ires);
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
199
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
200 if (res.length () != x.length ())
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
201 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
202 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
203 ("daspk: inconsistent sizes for state and residual vectors");
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
204
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
205 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
206 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
207 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
208 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
209 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
210 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
211 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
212 ("daspk: no user supplied RHS subroutine!");
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
213
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
214 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
215 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
216 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
217
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
218 info(4) = user_jac ? 1 : 0;
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
219
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
220 DAEFunc::reset = false;
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
221
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
222 octave_idx_type eiq = enforce_inequality_constraints ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
223 octave_idx_type ccic = compute_consistent_initial_condition ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
224 octave_idx_type eavfet = exclude_algebraic_variables_from_error_test ();
4144
b02ada83de67 [project @ 2002-11-01 18:03:56 by jwe]
jwe
parents: 4066
diff changeset
225
b02ada83de67 [project @ 2002-11-01 18:03:56 by jwe]
jwe
parents: 4066
diff changeset
226 liw = 40 + n;
b02ada83de67 [project @ 2002-11-01 18:03:56 by jwe]
jwe
parents: 4066
diff changeset
227 if (eiq == 1 || eiq == 3)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
228 liw += n;
4144
b02ada83de67 [project @ 2002-11-01 18:03:56 by jwe]
jwe
parents: 4066
diff changeset
229 if (ccic == 1 || eavfet == 1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
230 liw += n;
4144
b02ada83de67 [project @ 2002-11-01 18:03:56 by jwe]
jwe
parents: 4066
diff changeset
231
4842
fafc79eeaebb [project @ 2004-03-19 22:31:25 by jwe]
jwe
parents: 4662
diff changeset
232 lrw = 50 + 9*n + n*n;
4144
b02ada83de67 [project @ 2002-11-01 18:03:56 by jwe]
jwe
parents: 4066
diff changeset
233 if (eavfet == 1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
234 lrw += n;
4144
b02ada83de67 [project @ 2002-11-01 18:03:56 by jwe]
jwe
parents: 4066
diff changeset
235
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
236 iwork.resize (liw, 1);
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
237 rwork.resize (lrw, 1);
4144
b02ada83de67 [project @ 2002-11-01 18:03:56 by jwe]
jwe
parents: 4066
diff changeset
238
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
239 // DASPK_options
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
240
4144
b02ada83de67 [project @ 2002-11-01 18:03:56 by jwe]
jwe
parents: 4066
diff changeset
241 abs_tol = absolute_tolerance ();
b02ada83de67 [project @ 2002-11-01 18:03:56 by jwe]
jwe
parents: 4066
diff changeset
242 rel_tol = relative_tolerance ();
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
243
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
244 octave_idx_type abs_tol_len = abs_tol.length ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
245 octave_idx_type rel_tol_len = rel_tol.length ();
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
246
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
247 if (abs_tol_len == 1 && rel_tol_len == 1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
248 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
249 info(1) = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
250 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
251 else if (abs_tol_len == n && rel_tol_len == n)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
252 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
253 info(1) = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
254 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
255 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
256 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
257 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
258 ("daspk: inconsistent sizes for tolerance arrays");
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
259
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
260 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
261 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
262 }
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
263
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
264 double hmax = maximum_step_size ();
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
265 if (hmax >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
266 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
267 rwork(1) = hmax;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
268 info(6) = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
269 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
270 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
271 info(6) = 0;
3998
f6df65db67f9 [project @ 2002-07-24 18:10:39 by jwe]
jwe
parents: 3997
diff changeset
272
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
273 double h0 = initial_step_size ();
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
274 if (h0 >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
275 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
276 rwork(2) = h0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
277 info(7) = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
278 }
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
279 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
280 info(7) = 0;
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
281
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
282 octave_idx_type maxord = maximum_order ();
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
283 if (maxord >= 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
284 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
285 if (maxord > 0 && maxord < 6)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
286 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
287 info(8) = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
288 iwork(2) = maxord;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
289 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
290 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
291 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
292 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
293 ("daspk: invalid value for maximum order");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
294 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
295 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
296 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
297 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
298
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
299 switch (eiq)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
300 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
301 case 1:
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
302 case 3:
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
303 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
304 Array<octave_idx_type> ict = inequality_constraint_types ();
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
305
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
306 if (ict.length () == n)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
307 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
308 for (octave_idx_type i = 0; i < n; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
309 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
310 octave_idx_type val = ict(i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
311 if (val < -2 || val > 2)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
312 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
313 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
314 ("daspk: invalid value for inequality constraint type");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
315 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
316 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
317 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
318 iwork(40+i) = val;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
319 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
320 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
321 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
322 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
323 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
324 ("daspk: inequality constraint types size mismatch");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
325 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
326 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
327 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
328 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
329 // Fall through...
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
330
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
331 case 0:
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
332 case 2:
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
333 info(9) = eiq;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
334 break;
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
335
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
336 default:
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
337 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
338 ("daspk: invalid value for enforce inequality constraints option");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
339 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
340 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
341 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
342
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
343 if (ccic)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
344 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
345 if (ccic == 1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
346 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
347 // FIXME -- this code is duplicated below.
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
348
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
349 Array<octave_idx_type> av = algebraic_variables ();
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
350
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
351 if (av.length () == n)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
352 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
353 octave_idx_type lid;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
354 if (eiq == 0 || eiq == 2)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
355 lid = 40;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
356 else if (eiq == 1 || eiq == 3)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
357 lid = 40 + n;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
358 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
359 abort ();
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
360
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
361 for (octave_idx_type i = 0; i < n; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
362 iwork(lid+i) = av(i) ? -1 : 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
363 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
364 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
365 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
366 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
367 ("daspk: algebraic variables size mismatch");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
368 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
369 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
370 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
371 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
372 else if (ccic != 2)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
373 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
374 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
375 ("daspk: invalid value for compute consistent initial condition option");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
376 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
377 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
378 }
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
379
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
380 info(10) = ccic;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
381 }
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
382
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
383 if (eavfet)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
384 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
385 info(15) = 1;
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
386
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
387 // FIXME -- this code is duplicated above.
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
388
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
389 Array<octave_idx_type> av = algebraic_variables ();
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
390
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
391 if (av.length () == n)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
392 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
393 octave_idx_type lid;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
394 if (eiq == 0 || eiq == 2)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
395 lid = 40;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
396 else if (eiq == 1 || eiq == 3)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
397 lid = 40 + n;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
398 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
399 abort ();
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
400
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
401 for (octave_idx_type i = 0; i < n; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
402 iwork(lid+i) = av(i) ? -1 : 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
403 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
404 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
405
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
406 if (use_initial_condition_heuristics ())
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
407 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
408 Array<double> ich = initial_condition_heuristics ();
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
409
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
410 if (ich.length () == 6)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
411 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
412 iwork(31) = NINTbig (ich(0));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
413 iwork(32) = NINTbig (ich(1));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
414 iwork(33) = NINTbig (ich(2));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
415 iwork(34) = NINTbig (ich(3));
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
416
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
417 rwork(13) = ich(4);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
418 rwork(14) = ich(5);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
419 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
420 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
421 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
422 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
423 ("daspk: invalid initial condition heuristics option");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
424 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
425 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
426 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
427
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
428 info(16) = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
429 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
430
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
431 octave_idx_type pici = print_initial_condition_info ();
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
432 switch (pici)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
433 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
434 case 0:
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
435 case 1:
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
436 case 2:
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
437 info(17) = pici;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
438 break;
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
439
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
440 default:
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
441 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
442 ("daspk: invalid value for print initial condition info option");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
443 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
444 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
445 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
446 }
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
447
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
448 DASPK_options::reset = false;
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
449
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
450 restart = false;
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
451 }
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
452
11502
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
453 double *px = x.fortran_vec ();
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
454 double *pxdot = xdot.fortran_vec ();
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
455
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
456 octave_idx_type *pinfo = info.fortran_vec ();
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
457
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
458 double *prel_tol = rel_tol.fortran_vec ();
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
459 double *pabs_tol = abs_tol.fortran_vec ();
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
460
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
461 double *prwork = rwork.fortran_vec ();
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
462 octave_idx_type *piwork = iwork.fortran_vec ();
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
463
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
464 double *dummy = 0;
4638800cd660 delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
465 octave_idx_type *idummy = 0;
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
466
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
467 F77_XFCN (ddaspk, DDASPK, (ddaspk_f, nn, t, px, pxdot, tout, pinfo,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
468 prel_tol, pabs_tol, istate, prwork, lrw,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
469 piwork, liw, dummy, idummy, ddaspk_j,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
470 ddaspk_psol));
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
471
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
472 switch (istate)
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
473 {
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
474 case 1: // A step was successfully taken in intermediate-output
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
475 // mode. The code has not yet reached TOUT.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
476 case 2: // The integration to TSTOP was successfully completed
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
477 // (T=TSTOP) by stepping exactly to TSTOP.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
478 case 3: // The integration to TOUT was successfully completed
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
479 // (T=TOUT) by stepping past TOUT. Y(*) is obtained by
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
480 // interpolation. YPRIME(*) is obtained by interpolation.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
481 case 4: // The initial condition calculation, with
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
482 // INFO(11) > 0, was successful, and INFO(14) = 1.
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
483 // No integration steps were taken, and the solution
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
484 // is not considered to have been started.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
485 retval = x;
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
486 t = tout;
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
487 break;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
488
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
489 case -1: // A large amount of work has been expended. (~500 steps).
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
490 case -2: // The error tolerances are too stringent.
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
491 case -3: // The local error test cannot be satisfied because you
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
492 // specified a zero component in ATOL and the
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
493 // corresponding computed solution component is zero.
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
494 // Thus, a pure relative error test is impossible for
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
495 // this component.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
496 case -6: // DDASPK had repeated error test failures on the last
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
497 // attempted step.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
498 case -7: // The corrector could not converge.
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
499 case -8: // The matrix of partial derivatives is singular.
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
500 case -9: // The corrector could not converge. There were repeated
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
501 // error test failures in this step.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
502 case -10: // The corrector could not converge because IRES was
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
503 // equal to minus one.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
504 case -11: // IRES equal to -2 was encountered and control is being
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
505 // returned to the calling program.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
506 case -12: // DDASPK failed to compute the initial YPRIME.
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
507 case -13: // Unrecoverable error encountered inside user's
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
508 // PSOL routine, and control is being returned to
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
509 // the calling program.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
510 case -14: // The Krylov linear system solver could not
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
511 // achieve convergence.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
512 case -33: // The code has encountered trouble from which it cannot
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
513 // recover. A message is printed explaining the trouble
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
514 // and control is returned to the calling program. For
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
515 // example, this occurs when invalid input is detected.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
516 integration_error = true;
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
517 break;
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
518
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
519 default:
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
520 integration_error = true;
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
521 (*current_liboctave_error_handler)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
522 ("unrecognized value of istate (= %d) returned from ddaspk",
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
523 istate);
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
524 break;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
525 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
526
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
527 return retval;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
528 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
529
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
530 Matrix
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
531 DASPK::do_integrate (const ColumnVector& tout)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
532 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
533 Matrix dummy;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
534 return integrate (tout, dummy);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
535 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
536
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
537 Matrix
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
538 DASPK::integrate (const ColumnVector& tout, Matrix& xdot_out)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
539 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
540 Matrix retval;
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
541
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
542 octave_idx_type n_out = tout.capacity ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
543 octave_idx_type n = size ();
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
544
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
545 if (n_out > 0 && n > 0)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
546 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
547 retval.resize (n_out, n);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
548 xdot_out.resize (n_out, n);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
549
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
550 for (octave_idx_type i = 0; i < n; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
551 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
552 retval.elem (0, i) = x.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
553 xdot_out.elem (0, i) = xdot.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
554 }
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
555
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
556 for (octave_idx_type j = 1; j < n_out; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
557 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
558 ColumnVector x_next = do_integrate (tout.elem (j));
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
559
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
560 if (integration_error)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
561 return retval;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
562
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
563 for (octave_idx_type i = 0; i < n; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
564 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
565 retval.elem (j, i) = x_next.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
566 xdot_out.elem (j, i) = xdot.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
567 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
568 }
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
569 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
570
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
571 return retval;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
572 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
573
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
574 Matrix
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
575 DASPK::do_integrate (const ColumnVector& tout, const ColumnVector& tcrit)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
576 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
577 Matrix dummy;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
578 return integrate (tout, dummy, tcrit);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
579 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
580
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
581 Matrix
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
582 DASPK::integrate (const ColumnVector& tout, Matrix& xdot_out,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
583 const ColumnVector& tcrit)
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
584 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
585 Matrix retval;
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
586
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
587 octave_idx_type n_out = tout.capacity ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
588 octave_idx_type n = size ();
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
589
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
590 if (n_out > 0 && n > 0)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
591 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
592 retval.resize (n_out, n);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
593 xdot_out.resize (n_out, n);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
594
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
595 for (octave_idx_type i = 0; i < n; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
596 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
597 retval.elem (0, i) = x.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
598 xdot_out.elem (0, i) = xdot.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
599 }
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
600
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
601 octave_idx_type n_crit = tcrit.capacity ();
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
602
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
603 if (n_crit > 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
604 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
605 octave_idx_type i_crit = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
606 octave_idx_type i_out = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
607 double next_crit = tcrit.elem (0);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
608 double next_out;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
609 while (i_out < n_out)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
610 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
611 bool do_restart = false;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
612
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
613 next_out = tout.elem (i_out);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
614 if (i_crit < n_crit)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
615 next_crit = tcrit.elem (i_crit);
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
616
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
617 bool save_output;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
618 double t_out;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
619
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
620 if (next_crit == next_out)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
621 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
622 set_stop_time (next_crit);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
623 t_out = next_out;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
624 save_output = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
625 i_out++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
626 i_crit++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
627 do_restart = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
628 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
629 else if (next_crit < next_out)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
630 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
631 if (i_crit < n_crit)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
632 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
633 set_stop_time (next_crit);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
634 t_out = next_crit;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
635 save_output = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
636 i_crit++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
637 do_restart = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
638 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
639 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
640 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
641 clear_stop_time ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
642 t_out = next_out;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
643 save_output = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
644 i_out++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
645 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
646 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
647 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
648 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
649 set_stop_time (next_crit);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
650 t_out = next_out;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
651 save_output = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
652 i_out++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
653 }
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
654
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
655 ColumnVector x_next = do_integrate (t_out);
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
656
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
657 if (integration_error)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
658 return retval;
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
659
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
660 if (save_output)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
661 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
662 for (octave_idx_type i = 0; i < n; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
663 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
664 retval.elem (i_out-1, i) = x_next.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
665 xdot_out.elem (i_out-1, i) = xdot.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
666 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
667 }
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
668
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
669 if (do_restart)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
670 force_restart ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
671 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
672 }
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
673 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
674 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
675 retval = integrate (tout, xdot_out);
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
676
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
677 if (integration_error)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
678 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
679 }
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
680 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
681
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
682 return retval;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
683 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
684
3995
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
685 std::string
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
686 DASPK::error_message (void) const
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
687 {
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
688 std::string retval;
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
689
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5307
diff changeset
690 std::ostringstream buf;
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5307
diff changeset
691 buf << t;
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5307
diff changeset
692 std::string t_curr = buf.str ();
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
693
3997
d4091aff6468 [project @ 2002-07-17 18:00:06 by jwe]
jwe
parents: 3996
diff changeset
694 switch (istate)
3995
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
695 {
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
696 case 1:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
697 retval = "a step was successfully taken in intermediate-output mode.";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
698 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
699
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
700 case 2:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
701 retval = "integration completed by stepping exactly to TOUT";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
702 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
703
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
704 case 3:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
705 retval = "integration to tout completed by stepping past TOUT";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
706 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
707
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
708 case 4:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
709 retval = "initial condition calculation completed successfully";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
710 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
711
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
712 case -1:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
713 retval = std::string ("a large amount of work has been expended (t =")
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
714 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
715 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
716
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
717 case -2:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
718 retval = "the error tolerances are too stringent";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
719 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
720
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
721 case -3:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
722 retval = std::string ("error weight became zero during problem. (t = ")
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
723 + t_curr
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
724 + "; solution component i vanished, and atol or atol(i) == 0)";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
725 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
726
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
727 case -6:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
728 retval = std::string ("repeated error test failures on the last attempted step (t = ")
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
729 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
730 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
731
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
732 case -7:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
733 retval = std::string ("the corrector could not converge (t = ")
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
734 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
735 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
736
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
737 case -8:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
738 retval = std::string ("the matrix of partial derivatives is singular (t = ")
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
739 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
740 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
741
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
742 case -9:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
743 retval = std::string ("the corrector could not converge (t = ")
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
744 + t_curr + "; repeated test failures)";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
745 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
746
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
747 case -10:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
748 retval = std::string ("corrector could not converge because IRES was -1 (t = ")
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
749 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
750 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
751
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
752 case -11:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
753 retval = std::string ("return requested in user-supplied function (t = ")
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
754 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
755 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
756
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
757 case -12:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
758 retval = "failed to compute consistent initial conditions";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
759 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
760
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
761 case -13:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
762 retval = std::string ("unrecoverable error encountered inside user's PSOL function (t = ")
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
763 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
764 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
765
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
766 case -14:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
767 retval = std::string ("the Krylov linear system solver failed to converge (t = ")
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
768 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
769 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
770
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
771 case -33:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
772 retval = "unrecoverable error (see printed message)";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
773 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
774
3995
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
775 default:
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
776 retval = "unknown error state";
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
777 break;
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
778 }
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
779
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
780 return retval;
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3991
diff changeset
781 }