annotate liboctave/DASSL.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
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
1 /*
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
2
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 7482
diff changeset
4 2002, 2003, 2004, 2005, 2006, 2007, 2008 John W. Eaton
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
5
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
7
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
9a4c07481e61 [project @ 1993-08-08 01:20:23 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.
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
12
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
16 for more details.
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
17
9a4c07481e61 [project @ 1993-08-08 01:20:23 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/>.
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
21
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
22 */
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
23
238
780cbbc57b7c [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents: 227
diff changeset
24 #ifdef HAVE_CONFIG_H
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1011
diff changeset
25 #include <config.h>
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
26 #endif
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
27
1842
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
28 #include <cfloat>
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
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
1842
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
32 #include "DASSL.h"
1847
2ffe49eb95a5 [project @ 1996-02-03 12:47:55 by jwe]
jwe
parents: 1842
diff changeset
33 #include "f77-fcn.h"
227
1a48a1b91489 [project @ 1993-11-15 10:10:35 by jwe]
jwe
parents: 84
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"
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4066
diff changeset
36 #include "quit.h"
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
37
11495
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
38 typedef octave_idx_type (*dassl_fcn_ptr) (const double&, const double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
39 const double*, double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
40 octave_idx_type&, double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
41 octave_idx_type*);
3507
00fdd363c098 [project @ 2000-02-01 21:31:44 by jwe]
jwe
parents: 3487
diff changeset
42
11495
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
43 typedef octave_idx_type (*dassl_jac_ptr) (const double&, const double*,
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*);
3507
00fdd363c098 [project @ 2000-02-01 21:31:44 by jwe]
jwe
parents: 3487
diff changeset
47
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
48 extern "C"
4552
6f3382e08a52 [project @ 2003-10-27 20:38:02 by jwe]
jwe
parents: 4429
diff changeset
49 {
6f3382e08a52 [project @ 2003-10-27 20:38:02 by jwe]
jwe
parents: 4429
diff changeset
50 F77_RET_T
11495
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
51 F77_FUNC (ddassl, DDASSL) (dassl_fcn_ptr, const octave_idx_type&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
52 double&, double*, double*, double&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
53 const octave_idx_type*, const double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
54 const double*, octave_idx_type&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
55 double*, const octave_idx_type&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
56 octave_idx_type*, const octave_idx_type&,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
57 const double*, const octave_idx_type*,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
58 dassl_jac_ptr);
4552
6f3382e08a52 [project @ 2003-10-27 20:38:02 by jwe]
jwe
parents: 4429
diff changeset
59 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
60
532
2ca256b77602 [project @ 1994-07-20 19:56:55 by jwe]
jwe
parents: 465
diff changeset
61 static DAEFunc::DAERHSFunc user_fun;
2ca256b77602 [project @ 1994-07-20 19:56:55 by jwe]
jwe
parents: 465
diff changeset
62 static DAEFunc::DAEJacFunc user_jac;
3993
f23bc69132cc [project @ 2002-07-16 20:18:56 by jwe]
jwe
parents: 3991
diff changeset
63
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
64 static octave_idx_type nn;
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
65
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
66 static octave_idx_type
3991
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
67 ddassl_f (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
68 double *delta, octave_idx_type& ires, double *, octave_idx_type *)
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
69 {
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4066
diff changeset
70 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4066
diff changeset
71
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5765
diff changeset
72 // 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
73
1546
a272c4056bab [project @ 1995-10-07 03:38:40 by jwe]
jwe
parents: 1482
diff changeset
74 ColumnVector tmp_deriv (nn);
a272c4056bab [project @ 1995-10-07 03:38:40 by jwe]
jwe
parents: 1482
diff changeset
75 ColumnVector tmp_state (nn);
a272c4056bab [project @ 1995-10-07 03:38:40 by jwe]
jwe
parents: 1482
diff changeset
76 ColumnVector tmp_delta (nn);
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
77
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
78 for (octave_idx_type i = 0; i < nn; i++)
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
79 {
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
80 tmp_deriv.elem (i) = deriv [i];
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
81 tmp_state.elem (i) = state [i];
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
82 }
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
83
3849
5266e351a19c [project @ 2001-11-02 04:50:09 by jwe]
jwe
parents: 3520
diff changeset
84 tmp_delta = user_fun (tmp_state, tmp_deriv, time, ires);
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
85
3849
5266e351a19c [project @ 2001-11-02 04:50:09 by jwe]
jwe
parents: 3520
diff changeset
86 if (ires >= 0)
256
e592734b002b [project @ 1993-12-08 23:36:33 by jwe]
jwe
parents: 238
diff changeset
87 {
3849
5266e351a19c [project @ 2001-11-02 04:50:09 by jwe]
jwe
parents: 3520
diff changeset
88 if (tmp_delta.length () == 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
89 ires = -2;
3849
5266e351a19c [project @ 2001-11-02 04:50:09 by jwe]
jwe
parents: 3520
diff changeset
90 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
91 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
92 for (octave_idx_type i = 0; i < nn; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
93 delta [i] = tmp_delta.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
94 }
256
e592734b002b [project @ 1993-12-08 23:36:33 by jwe]
jwe
parents: 238
diff changeset
95 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
96
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4066
diff changeset
97 END_INTERRUPT_WITH_EXCEPTIONS;
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4066
diff changeset
98
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
99 return 0;
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
100 }
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
101
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
102 static octave_idx_type
3991
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
103 ddassl_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
104 double *pd, const double& cj, double *, octave_idx_type *)
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
105 {
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4066
diff changeset
106 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4066
diff changeset
107
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5765
diff changeset
108 // 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
109
1546
a272c4056bab [project @ 1995-10-07 03:38:40 by jwe]
jwe
parents: 1482
diff changeset
110 ColumnVector tmp_state (nn);
a272c4056bab [project @ 1995-10-07 03:38:40 by jwe]
jwe
parents: 1482
diff changeset
111 ColumnVector tmp_deriv (nn);
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
112
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
113 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
114 {
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
115 tmp_deriv.elem (i) = deriv [i];
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
116 tmp_state.elem (i) = state [i];
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
117 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
118
3991
48d2bc4a3729 [project @ 2002-07-16 17:46:50 by jwe]
jwe
parents: 3990
diff changeset
119 Matrix tmp_pd = user_jac (tmp_state, tmp_deriv, time, cj);
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
120
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
121 for (octave_idx_type j = 0; j < nn; j++)
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
122 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
123 pd [nn * j + i] = tmp_pd.elem (i, j);
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
124
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4066
diff changeset
125 END_INTERRUPT_WITH_EXCEPTIONS;
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4066
diff changeset
126
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
127 return 0;
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
128 }
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
129
1546
a272c4056bab [project @ 1995-10-07 03:38:40 by jwe]
jwe
parents: 1482
diff changeset
130 ColumnVector
1842
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
131 DASSL::do_integrate (double tout)
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
132 {
1945
8c4bce5e773e [project @ 1996-02-14 01:03:03 by jwe]
jwe
parents: 1939
diff changeset
133 ColumnVector retval;
8c4bce5e773e [project @ 1996-02-14 01:03:03 by jwe]
jwe
parents: 1939
diff changeset
134
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
135 if (! initialized || restart || DAEFunc::reset|| DASSL_options::reset)
1945
8c4bce5e773e [project @ 1996-02-14 01:03:03 by jwe]
jwe
parents: 1939
diff changeset
136 {
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
137 integration_error = false;
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
138
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
139 initialized = true;
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
140
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
141 info.resize (15, 1);
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
142
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
143 for (octave_idx_type i = 0; i < 15; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
144 info(i) = 0;
1945
8c4bce5e773e [project @ 1996-02-14 01:03:03 by jwe]
jwe
parents: 1939
diff changeset
145
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
146 octave_idx_type n = size ();
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
147
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4192
diff changeset
148 liw = 21 + n;
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
149 lrw = 40 + 9*n + n*n;
1945
8c4bce5e773e [project @ 1996-02-14 01:03:03 by jwe]
jwe
parents: 1939
diff changeset
150
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
151 nn = n;
1945
8c4bce5e773e [project @ 1996-02-14 01:03:03 by jwe]
jwe
parents: 1939
diff changeset
152
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
153 iwork.resize (liw, 1);
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
154 rwork.resize (lrw, 1);
256
e592734b002b [project @ 1993-12-08 23:36:33 by jwe]
jwe
parents: 238
diff changeset
155
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
156 info(0) = 0;
3994
a41827ec5677 [project @ 2002-07-16 23:57:09 by jwe]
jwe
parents: 3993
diff changeset
157
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
158 if (stop_time_set)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
159 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
160 rwork(0) = stop_time;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
161 info(3) = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
162 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
163 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
164 info(3) = 0;
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
165
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
166 restart = 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 // DAEFunc
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
169
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
170 user_fun = DAEFunc::function ();
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
171 user_jac = DAEFunc::jacobian_function ();
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
172
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
173 if (user_fun)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
174 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
175 octave_idx_type ires = 0;
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
176
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
177 ColumnVector res = (*user_fun) (x, xdot, t, ires);
3993
f23bc69132cc [project @ 2002-07-16 20:18:56 by jwe]
jwe
parents: 3991
diff changeset
178
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
179 if (res.length () != x.length ())
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
180 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
181 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
182 ("dassl: inconsistent sizes for state and residual vectors");
3849
5266e351a19c [project @ 2001-11-02 04:50:09 by jwe]
jwe
parents: 3520
diff changeset
183
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
184 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
185 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
186 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
187 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
188 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
189 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
190 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
191 ("dassl: no user supplied RHS subroutine!");
2344
968a33af8b3d [project @ 1996-07-24 21:49:32 by jwe]
jwe
parents: 1993
diff changeset
192
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
193 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
194 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
195 }
2344
968a33af8b3d [project @ 1996-07-24 21:49:32 by jwe]
jwe
parents: 1993
diff changeset
196
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
197 info(4) = user_jac ? 1 : 0;
2344
968a33af8b3d [project @ 1996-07-24 21:49:32 by jwe]
jwe
parents: 1993
diff changeset
198
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
199 DAEFunc::reset = false;
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
200
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
201 // DASSL_options
3998
f6df65db67f9 [project @ 2002-07-24 18:10:39 by jwe]
jwe
parents: 3997
diff changeset
202
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
203 double hmax = maximum_step_size ();
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
204 if (hmax >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
205 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
206 rwork(1) = hmax;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
207 info(6) = 1;
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 info(6) = 0;
3998
f6df65db67f9 [project @ 2002-07-24 18:10:39 by jwe]
jwe
parents: 3997
diff changeset
211
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
212 double h0 = initial_step_size ();
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
213 if (h0 >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
214 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
215 rwork(2) = h0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
216 info(7) = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
217 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
218 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
219 info(7) = 0;
3998
f6df65db67f9 [project @ 2002-07-24 18:10:39 by jwe]
jwe
parents: 3997
diff changeset
220
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4192
diff changeset
221 if (step_limit () >= 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
222 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
223 info(11) = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
224 iwork(20) = step_limit ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
225 }
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4192
diff changeset
226 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
227 info(11) = 0;
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4192
diff changeset
228
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
229 octave_idx_type maxord = maximum_order ();
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
230 if (maxord >= 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
231 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
232 if (maxord > 0 && maxord < 6)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
233 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
234 info(8) = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
235 iwork(2) = maxord;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
236 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
237 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
238 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
239 (*current_liboctave_error_handler)
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
240 ("dassl: invalid value for maximum order: %d", maxord);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
241 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
242 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
243 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
244 }
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
245
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
246 octave_idx_type enc = enforce_nonnegativity_constraints ();
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
247 info(9) = enc ? 1 : 0;
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
248
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
249 octave_idx_type ccic = compute_consistent_initial_condition ();
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
250 info(10) = ccic ? 1 : 0;
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
251
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
252 abs_tol = absolute_tolerance ();
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
253 rel_tol = relative_tolerance ();
289
c23f50e61c58 [project @ 1994-01-13 06:25:58 by jwe]
jwe
parents: 256
diff changeset
254
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
255 octave_idx_type abs_tol_len = abs_tol.length ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
256 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
257
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
258 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
259 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
260 info(1) = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
261 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
262 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
263 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
264 info(1) = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
265 }
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
266 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
267 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
268 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
269 ("dassl: inconsistent sizes for tolerance arrays");
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
270
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
271 integration_error = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
272 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
273 }
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
274
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
275 DASSL_options::reset = false;
289
c23f50e61c58 [project @ 1994-01-13 06:25:58 by jwe]
jwe
parents: 256
diff changeset
276 }
4047
7b0c139ac8af [project @ 2002-08-15 20:52:55 by jwe]
jwe
parents: 4043
diff changeset
277
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
278 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
279 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
280
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
281 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
282
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
283 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
284 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
285
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
286 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
287 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
288
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
289 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
290 octave_idx_type *idummy = 0;
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
291
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
292 F77_XFCN (ddassl, DDASSL, (ddassl_f, nn, t, px, pxdot, tout, pinfo,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
293 prel_tol, pabs_tol, istate, prwork, lrw,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
294 piwork, liw, dummy, idummy, ddassl_j));
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
295
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
296 switch (istate)
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
297 {
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
298 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
299 // 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
300 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
301 // (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
302 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
303 // (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
304 // interpolation. YPRIME(*) is obtained by interpolation.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
305 retval = x;
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
306 t = tout;
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
307 break;
1360
7eb93d12654c [project @ 1995-09-05 21:51:54 by jwe]
jwe
parents: 1326
diff changeset
308
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
309 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
310 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
311 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
312 // specified a zero component in ATOL and the
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
313 // corresponding computed solution component is zero.
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
314 // Thus, a pure relative error test is impossible for
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
315 // this component.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
316 case -6: // DDASSL had repeated error test failures on the last
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
317 // attempted step.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
318 case -7: // The corrector could not converge.
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
319 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
320 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
321 // error test failures in this step.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
322 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
323 // equal to minus one.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
324 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
325 // returned to the calling program.
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
326 case -12: // DDASSL failed to compute the initial YPRIME.
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
327 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
328 // recover. A message is printed explaining the trouble
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
329 // and control is returned to the calling program. For
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
330 // 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
331 integration_error = true;
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
332 break;
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
333
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
334 default:
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
335 integration_error = true;
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
336 (*current_liboctave_error_handler)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
337 ("unrecognized value of istate (= %d) returned from ddassl",
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
338 istate);
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
339 break;
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
340 }
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
341
1945
8c4bce5e773e [project @ 1996-02-14 01:03:03 by jwe]
jwe
parents: 1939
diff changeset
342 return retval;
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
343 }
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
344
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
345 Matrix
1842
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
346 DASSL::do_integrate (const ColumnVector& tout)
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
347 {
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
348 Matrix dummy;
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
349 return integrate (tout, dummy);
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
350 }
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
351
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
352 Matrix
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
353 DASSL::integrate (const ColumnVector& tout, Matrix& xdot_out)
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
354 {
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
355 Matrix retval;
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
356
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
357 octave_idx_type n_out = tout.capacity ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
358 octave_idx_type n = size ();
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
359
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
360 if (n_out > 0 && n > 0)
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
361 {
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
362 retval.resize (n_out, n);
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
363 xdot_out.resize (n_out, n);
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
364
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
365 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
366 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
367 retval.elem (0, i) = x.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
368 xdot_out.elem (0, i) = xdot.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
369 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
370
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
371 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
372 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
373 ColumnVector x_next = do_integrate (tout.elem (j));
256
e592734b002b [project @ 1993-12-08 23:36:33 by jwe]
jwe
parents: 238
diff changeset
374
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
375 if (integration_error)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
376 return retval;
256
e592734b002b [project @ 1993-12-08 23:36:33 by jwe]
jwe
parents: 238
diff changeset
377
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
378 for (octave_idx_type i = 0; i < n; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
379 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
380 retval.elem (j, i) = x_next.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
381 xdot_out.elem (j, i) = xdot.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
382 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
383 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
384 }
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
385
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
386 return retval;
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
387 }
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
388
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
389 Matrix
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3507
diff changeset
390 DASSL::do_integrate (const ColumnVector& tout, const ColumnVector& tcrit)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3507
diff changeset
391 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3507
diff changeset
392 Matrix dummy;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3507
diff changeset
393 return integrate (tout, dummy, tcrit);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3507
diff changeset
394 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3507
diff changeset
395
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3507
diff changeset
396 Matrix
1842
0574a1f3a273 [project @ 1996-02-03 11:44:02 by jwe]
jwe
parents: 1546
diff changeset
397 DASSL::integrate (const ColumnVector& tout, Matrix& xdot_out,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
398 const ColumnVector& tcrit)
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
399 {
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
400 Matrix retval;
4049
a35a3c5d4740 [project @ 2002-08-16 08:54:31 by jwe]
jwe
parents: 4047
diff changeset
401
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
402 octave_idx_type n_out = tout.capacity ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
403 octave_idx_type n = size ();
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
404
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
405 if (n_out > 0 && n > 0)
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
406 {
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
407 retval.resize (n_out, n);
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
408 xdot_out.resize (n_out, n);
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
409
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
410 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
411 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
412 retval.elem (0, i) = x.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
413 xdot_out.elem (0, i) = xdot.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
414 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
415
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
416 octave_idx_type n_crit = tcrit.capacity ();
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
417
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
418 if (n_crit > 0)
10314
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 octave_idx_type i_crit = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
421 octave_idx_type i_out = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
422 double next_crit = tcrit.elem (0);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
423 double next_out;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
424 while (i_out < n_out)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
425 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
426 bool do_restart = false;
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
427
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
428 next_out = tout.elem (i_out);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
429 if (i_crit < n_crit)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
430 next_crit = tcrit.elem (i_crit);
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
431
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
432 bool save_output;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
433 double t_out;
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
434
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
435 if (next_crit == next_out)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
436 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
437 set_stop_time (next_crit);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
438 t_out = next_out;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
439 save_output = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
440 i_out++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
441 i_crit++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
442 do_restart = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
443 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
444 else if (next_crit < next_out)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
445 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
446 if (i_crit < n_crit)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
447 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
448 set_stop_time (next_crit);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
449 t_out = next_crit;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
450 save_output = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
451 i_crit++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
452 do_restart = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
453 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
454 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
455 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
456 clear_stop_time ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
457 t_out = next_out;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
458 save_output = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
459 i_out++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
460 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
461 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
462 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
463 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
464 set_stop_time (next_crit);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
465 t_out = next_out;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
466 save_output = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
467 i_out++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
468 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
469
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
470 ColumnVector x_next = do_integrate (t_out);
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
471
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
472 if (integration_error)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
473 return retval;
256
e592734b002b [project @ 1993-12-08 23:36:33 by jwe]
jwe
parents: 238
diff changeset
474
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
475 if (save_output)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
476 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
477 for (octave_idx_type i = 0; i < n; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
478 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
479 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
480 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
481 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
482 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
483
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
484 if (do_restart)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
485 force_restart ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
486 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
487 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
488 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
489 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
490 retval = integrate (tout, xdot_out);
256
e592734b002b [project @ 1993-12-08 23:36:33 by jwe]
jwe
parents: 238
diff changeset
491
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
492 if (integration_error)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
493 return retval;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
494 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
495 }
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
496
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
497 return retval;
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
498 }
289
c23f50e61c58 [project @ 1994-01-13 06:25:58 by jwe]
jwe
parents: 256
diff changeset
499
3995
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
500 std::string
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
501 DASSL::error_message (void) const
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
502 {
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
503 std::string retval;
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
504
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5307
diff changeset
505 std::ostringstream buf;
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5307
diff changeset
506 buf << t;
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5307
diff changeset
507 std::string t_curr = buf.str ();
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
508
3997
d4091aff6468 [project @ 2002-07-17 18:00:06 by jwe]
jwe
parents: 3996
diff changeset
509 switch (istate)
3995
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
510 {
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
511 case 1:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
512 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
513 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
514
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
515 case 2:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
516 retval = "integration completed by stepping exactly to TOUT";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
517 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
518
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
519 case 3:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
520 retval = "integration to tout completed by stepping past TOUT";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
521 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
522
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
523 case -1:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
524 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
525 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
526 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
527
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
528 case -2:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
529 retval = "the error tolerances are too stringent";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
530 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
531
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
532 case -3:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
533 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
534 + t_curr
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
535 + "; 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
536 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
537
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
538 case -6:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
539 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
540 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
541 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
542
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
543 case -7:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
544 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
545 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
546 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
547
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
548 case -8:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
549 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
550 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
551 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
552
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
553 case -9:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
554 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
555 + t_curr + "; repeated test failures)";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
556 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
557
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
558 case -10:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
559 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
560 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
561 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
562
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
563 case -11:
4043
6fae69a1796e [project @ 2002-08-15 03:36:27 by jwe]
jwe
parents: 3998
diff changeset
564 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
565 + t_curr + ")";
3996
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
566 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
567
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
568 case -12:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
569 retval = "failed to compute consistent initial conditions";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
570 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
571
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
572 case -33:
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
573 retval = "unrecoverable error (see printed message)";
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
574 break;
98107d72871c [project @ 2002-07-17 16:22:05 by jwe]
jwe
parents: 3995
diff changeset
575
3995
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
576 default:
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
577 retval = "unknown error state";
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
578 break;
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
579 }
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
580
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
581 return retval;
ee0304212be0 [project @ 2002-07-17 04:32:42 by jwe]
jwe
parents: 3994
diff changeset
582 }