Mercurial > octave
annotate liboctave/numeric/LSODE.cc @ 23577:80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
* ov.h (is_empty): Use OCTAVE_DEPRECATED macro around function.
* ov.h (isempty): New function.
* Array.h (is_empty): Use OCTAVE_DEPRECATED macro around function.
* Array.h (isempty): New function.
* Range.h (is_empty): Use OCTAVE_DEPRECATED macro around function.
* Range.h (isempty): New function.
* Sparse.h (is_empty): Use OCTAVE_DEPRECATED macro around function.
* Sparse.h (isempty): New function.
* Backend.cc, BaseControl.cc, Canvas.cc, Figure.cc, gl-select.cc,
__magick_read__.cc, __qp__.cc, cellfun.cc, daspk.cc, dasrt.cc, dassl.cc,
data.cc, debug.cc, det.cc, eig.cc, error.cc, fft.cc, filter.cc, find.cc,
ft-text-renderer.cc, gl-render.cc, gl2ps-print.cc, graphics.cc, graphics.in.h,
hess.cc, inv.cc, lsode.cc, lu.cc, max.cc, mex.cc, mxarray.in.h, oct-handle.h,
oct-lvalue.cc, oct-map.cc, oct-map.h, oct-stream.cc, pinv.cc, pr-output.cc,
quadcc.cc, qz.cc, strfind.cc, strfns.cc, sylvester.cc, time.cc, toplev.cc,
tril.cc, urlwrite.cc, utils.cc, utils.h, xnorm.cc, __delaunayn__.cc,
__glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc,
__voronoi__.cc, chol.cc, convhulln.cc, ov-base-diag.cc, ov-base-mat.cc,
ov-base-sparse.cc, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-sparse.cc,
ov-cell.cc, ov-class.cc, ov-classdef.cc, ov-cx-sparse.cc, ov-fcn-inline.cc,
ov-flt-re-mat.cc, ov-intx.h, ov-java.cc, ov-perm.cc, ov-range.cc, ov-re-mat.cc,
ov-re-sparse.cc, ov-str-mat.cc, ov-struct.cc, ov-usr-fcn.cc, ov.cc, ov.h,
bp-table.cc, oct-parse.in.yy, pt-eval.cc, pt-tm-const.cc, pt-tm-const.h,
Array.cc, Range.cc, Range.h, Sparse.cc, Sparse.h, chNDArray.cc, dNDArray.cc,
fNDArray.cc, DASPK.cc, DASRT.cc, DASSL.cc, LSODE.cc, bsxfun-defs.cc,
eigs-base.cc, oct-convn.cc, qr.cc:
Replace instances of is_empty with isempty.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 11 Jun 2017 22:14:09 -0700 |
parents | d691ed308237 |
children | 336f89b6208b |
rev | line source |
---|---|
3 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1993-2017 John W. Eaton |
3 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
10 (at your option) any later version. |
3 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
15 GNU General Public License for more details. |
3 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
3 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
24 # include "config.h" |
3 | 25 #endif |
26 | |
5765 | 27 #include <sstream> |
28 | |
1842 | 29 #include "LSODE.h" |
1847 | 30 #include "f77-fcn.h" |
227 | 31 #include "lo-error.h" |
4180 | 32 #include "quit.h" |
3 | 33 |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
34 typedef F77_INT (*lsode_fcn_ptr) (const F77_INT&, const double&, double*, |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
35 double*, F77_INT&); |
3507 | 36 |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
37 typedef F77_INT (*lsode_jac_ptr) (const F77_INT&, const double&, double*, |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
38 const F77_INT&, const F77_INT&, double*, |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
39 const F77_INT&); |
3507 | 40 |
3 | 41 extern "C" |
4552 | 42 { |
43 F77_RET_T | |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
44 F77_FUNC (dlsode, DLSODE) (lsode_fcn_ptr, F77_INT&, F77_DBLE*, F77_DBLE&, |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
45 F77_DBLE&, F77_INT&, F77_DBLE&, const F77_DBLE*, |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
46 F77_INT&, F77_INT&, F77_INT&, F77_DBLE*, |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
47 F77_INT&, F77_INT*, F77_INT&, lsode_jac_ptr, |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
48 F77_INT&); |
4552 | 49 } |
3 | 50 |
532 | 51 static ODEFunc::ODERHSFunc user_fun; |
52 static ODEFunc::ODEJacFunc user_jac; | |
3 | 53 static ColumnVector *tmp_x; |
54 | |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
55 static F77_INT |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
56 lsode_f (const F77_INT& neq, const double& time, double *, double *deriv, |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
57 F77_INT& ierr) |
3 | 58 { |
4180 | 59 BEGIN_INTERRUPT_WITH_EXCEPTIONS; |
60 | |
2343 | 61 ColumnVector tmp_deriv; |
3 | 62 |
1360 | 63 // NOTE: this won't work if LSODE passes copies of the state vector. |
64 // In that case we have to create a temporary vector object | |
65 // and copy. | |
66 | |
1251 | 67 tmp_deriv = (*user_fun) (*tmp_x, time); |
3 | 68 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23475
diff
changeset
|
69 if (tmp_deriv.isempty ()) |
1251 | 70 ierr = -1; |
258 | 71 else |
72 { | |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
73 for (F77_INT i = 0; i < neq; i++) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
74 deriv[i] = tmp_deriv.elem (i); |
258 | 75 } |
3 | 76 |
4180 | 77 END_INTERRUPT_WITH_EXCEPTIONS; |
78 | |
3 | 79 return 0; |
80 } | |
81 | |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
82 static F77_INT |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
83 lsode_j (const F77_INT& neq, const double& time, double *, const F77_INT&, |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
84 const F77_INT&, double *pd, const F77_INT& nrowpd) |
3 | 85 { |
4180 | 86 BEGIN_INTERRUPT_WITH_EXCEPTIONS; |
87 | |
1251 | 88 Matrix tmp_jac (neq, neq); |
3 | 89 |
1360 | 90 // NOTE: this won't work if LSODE passes copies of the state vector. |
91 // In that case we have to create a temporary vector object | |
92 // and copy. | |
93 | |
1251 | 94 tmp_jac = (*user_jac) (*tmp_x, time); |
3 | 95 |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
96 for (F77_INT j = 0; j < neq; j++) |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
97 for (F77_INT i = 0; i < neq; i++) |
15020
560317fd5977
maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents:
15018
diff
changeset
|
98 pd[nrowpd * j + i] = tmp_jac (i, j); |
3 | 99 |
4180 | 100 END_INTERRUPT_WITH_EXCEPTIONS; |
101 | |
3 | 102 return 0; |
103 } | |
104 | |
105 ColumnVector | |
1842 | 106 LSODE::do_integrate (double tout) |
3 | 107 { |
1945 | 108 ColumnVector retval; |
109 | |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
110 static F77_INT nn = 0; |
4049 | 111 |
112 if (! initialized || restart || ODEFunc::reset || LSODE_options::reset) | |
1945 | 113 { |
4049 | 114 integration_error = false; |
1945 | 115 |
4049 | 116 initialized = true; |
117 | |
118 istate = 1; | |
119 | |
22988
cd33c785e80e
put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22960
diff
changeset
|
120 F77_INT n = octave::to_f77_int (size ()); |
4049 | 121 |
122 nn = n; | |
3955 | 123 |
5275 | 124 octave_idx_type max_maxord = 0; |
4231 | 125 |
4049 | 126 if (integration_method () == "stiff") |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
127 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
128 max_maxord = 5; |
4231 | 129 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
130 if (jac) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
131 method_flag = 21; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
132 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
133 method_flag = 22; |
3955 | 134 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
135 liw = 20 + n; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
136 lrw = 22 + n * (9 + n); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
137 } |
4049 | 138 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
139 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
140 max_maxord = 12; |
4231 | 141 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
142 method_flag = 10; |
3955 | 143 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
144 liw = 20; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
145 lrw = 22 + 16 * n; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
146 } |
4049 | 147 |
11574
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
148 iwork.resize (dim_vector (liw, 1)); |
5552 | 149 |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
150 for (F77_INT i = 4; i < 9; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
151 iwork(i) = 0; |
5552 | 152 |
11574
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
153 rwork.resize (dim_vector (lrw, 1)); |
5552 | 154 |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
155 for (F77_INT i = 4; i < 9; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
156 rwork(i) = 0; |
5552 | 157 |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
158 octave_idx_type maxord = maximum_order (); |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
159 |
4231 | 160 if (maxord >= 0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
161 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
162 if (maxord > 0 && maxord <= max_maxord) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
163 { |
22988
cd33c785e80e
put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22960
diff
changeset
|
164 iwork(4) = octave::to_f77_int (maxord); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
165 iopt = 1; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
166 } |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
167 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
168 { |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
169 // FIXME: Should this be a warning? |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
170 (*current_liboctave_error_handler) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
171 ("lsode: invalid value for maximum order"); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
172 integration_error = true; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
173 return retval; |
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 } |
4231 | 176 |
4049 | 177 if (stop_time_set) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
178 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
179 itask = 4; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
180 rwork(0) = stop_time; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
181 iopt = 1; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
182 } |
4049 | 183 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
184 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
185 itask = 1; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
186 } |
258 | 187 |
4049 | 188 restart = false; |
189 | |
190 // ODEFunc | |
3 | 191 |
4049 | 192 // NOTE: this won't work if LSODE passes copies of the state vector. |
193 // In that case we have to create a temporary vector object | |
194 // and copy. | |
3 | 195 |
4049 | 196 tmp_x = &x; |
197 | |
198 user_fun = function (); | |
199 user_jac = jacobian_function (); | |
200 | |
2343 | 201 ColumnVector xdot = (*user_fun) (x, t); |
202 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20229
diff
changeset
|
203 if (x.numel () != xdot.numel ()) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
204 { |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
205 // FIXME: Should this be a warning? |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
206 (*current_liboctave_error_handler) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
207 ("lsode: inconsistent sizes for state and derivative vectors"); |
2343 | 208 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
209 integration_error = true; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
210 return retval; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
211 } |
2343 | 212 |
4049 | 213 ODEFunc::reset = false; |
214 | |
215 // LSODE_options | |
216 | |
217 rel_tol = relative_tolerance (); | |
218 abs_tol = absolute_tolerance (); | |
219 | |
22988
cd33c785e80e
put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22960
diff
changeset
|
220 F77_INT abs_tol_len = octave::to_f77_int (abs_tol.numel ()); |
4049 | 221 |
222 if (abs_tol_len == 1) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
223 itol = 1; |
4049 | 224 else if (abs_tol_len == n) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
225 itol = 2; |
4049 | 226 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
227 { |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
228 // FIXME: Should this be a warning? |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
229 (*current_liboctave_error_handler) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
230 ("lsode: inconsistent sizes for state and absolute tolerance vectors"); |
4049 | 231 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
232 integration_error = true; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
233 return retval; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
234 } |
2343 | 235 |
4049 | 236 double iss = initial_step_size (); |
237 if (iss >= 0.0) | |
10314
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 rwork(4) = iss; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
240 iopt = 1; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
241 } |
4049 | 242 |
243 double maxss = maximum_step_size (); | |
244 if (maxss >= 0.0) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
245 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
246 rwork(5) = maxss; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
247 iopt = 1; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
248 } |
4049 | 249 |
250 double minss = minimum_step_size (); | |
251 if (minss >= 0.0) | |
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 rwork(6) = minss; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
254 iopt = 1; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
255 } |
4049 | 256 |
22988
cd33c785e80e
put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22960
diff
changeset
|
257 F77_INT sl = octave::to_f77_int (step_limit ()); |
4049 | 258 if (sl > 0) |
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 iwork(5) = sl; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
261 iopt = 1; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
262 } |
4049 | 263 |
264 LSODE_options::reset = false; | |
3 | 265 } |
266 | |
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
|
267 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
|
268 |
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
|
269 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
|
270 |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
271 F77_INT *piwork = iwork.fortran_vec (); |
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
|
272 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
|
273 |
22988
cd33c785e80e
put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22960
diff
changeset
|
274 F77_INT tmp_istate = octave::to_f77_int (istate); |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
275 |
4583 | 276 F77_XFCN (dlsode, DLSODE, (lsode_f, nn, px, t, tout, itol, rel_tol, |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
277 pabs_tol, itask, tmp_istate, iopt, prwork, lrw, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
278 piwork, liw, lsode_j, method_flag)); |
3 | 279 |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
280 istate = tmp_istate; |
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
281 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
282 switch (istate) |
3 | 283 { |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
284 case 1: // prior to initial integration step. |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
285 case 2: // lsode was successful. |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
286 retval = x; |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
287 t = tout; |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
288 break; |
3996 | 289 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
290 case -1: // excess work done on this call (perhaps wrong mf). |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
291 case -2: // excess accuracy requested (tolerances too small). |
8807
401d54a83690
use 'invalid', not 'illegal'
John W. Eaton <jwe@octave.org>
parents:
7482
diff
changeset
|
292 case -3: // invalid input detected (see printed message). |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
293 case -4: // repeated error test failures (check all inputs). |
12600
7c000c70f873
LSODE.cc: Add semicolon to error messages to prevent run-together text.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
294 case -5: // repeated convergence failures (perhaps bad Jacobian |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
295 // supplied or wrong choice of mf or tolerances). |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
296 case -6: // error weight became zero during problem. (solution |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
297 // component i vanished, and atol or atol(i) = 0.) |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
298 case -13: // return requested in user-supplied function. |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
299 integration_error = true; |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
300 break; |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
301 |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
302 default: |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
303 integration_error = true; |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
304 (*current_liboctave_error_handler) |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
305 ("unrecognized value of istate (= %d) returned from lsode", istate); |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7231
diff
changeset
|
306 break; |
3 | 307 } |
308 | |
1945 | 309 return retval; |
3 | 310 } |
311 | |
3959 | 312 std::string |
313 LSODE::error_message (void) const | |
314 { | |
315 std::string retval; | |
316 | |
5765 | 317 std::ostringstream buf; |
318 buf << t; | |
319 std::string t_curr = buf.str (); | |
4042 | 320 |
3959 | 321 switch (istate) |
322 { | |
323 case 1: | |
3996 | 324 retval = "prior to initial integration step"; |
3959 | 325 break; |
326 | |
327 case 2: | |
328 retval = "successful exit"; | |
329 break; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
330 |
3959 | 331 case 3: |
332 retval = "prior to continuation call with modified parameters"; | |
333 break; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
334 |
3996 | 335 case -1: |
4042 | 336 retval = std::string ("excess work on this call (t = ") |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
337 + t_curr + "; perhaps wrong integration method)"; |
3996 | 338 break; |
339 | |
340 case -2: | |
341 retval = "excess accuracy requested (tolerances too small)"; | |
342 break; | |
343 | |
344 case -3: | |
345 retval = "invalid input detected (see printed message)"; | |
346 break; | |
347 | |
348 case -4: | |
4042 | 349 retval = std::string ("repeated error test failures (t = ") |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
350 + t_curr + "; check all inputs)"; |
3996 | 351 break; |
352 | |
353 case -5: | |
4042 | 354 retval = std::string ("repeated convergence failures (t = ") |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
355 + t_curr |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
356 + "; perhaps bad Jacobian supplied or wrong choice of integration method or tolerances)"; |
3996 | 357 break; |
358 | |
359 case -6: | |
4042 | 360 retval = std::string ("error weight became zero during problem. (t = ") |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
361 + t_curr |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
362 + "; solution component i vanished, and atol or atol(i) == 0)"; |
3996 | 363 break; |
364 | |
365 case -13: | |
4042 | 366 retval = "return requested in user-supplied function (t = " |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
367 + t_curr + ")"; |
3996 | 368 break; |
369 | |
3959 | 370 default: |
371 retval = "unknown error state"; | |
372 break; | |
373 } | |
374 | |
375 return retval; | |
376 } | |
377 | |
3 | 378 Matrix |
1842 | 379 LSODE::do_integrate (const ColumnVector& tout) |
3 | 380 { |
381 Matrix retval; | |
4049 | 382 |
20229
5dfaaaae784f
Deprecate Array::capacity() and Sparse::capacity() for numel() and nzmax().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
383 octave_idx_type n_out = tout.numel (); |
22988
cd33c785e80e
put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22960
diff
changeset
|
384 F77_INT n = octave::to_f77_int (size ()); |
3 | 385 |
386 if (n_out > 0 && n > 0) | |
387 { | |
388 retval.resize (n_out, n); | |
389 | |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
390 for (F77_INT i = 0; i < n; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
391 retval.elem (0, i) = x.elem (i); |
3 | 392 |
5275 | 393 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
|
394 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
395 ColumnVector x_next = do_integrate (tout.elem (j)); |
258 | 396 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
397 if (integration_error) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
398 return retval; |
258 | 399 |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
400 for (F77_INT i = 0; i < n; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
401 retval.elem (j, i) = x_next.elem (i); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
402 } |
3 | 403 } |
404 | |
405 return retval; | |
406 } | |
407 | |
408 Matrix | |
3511 | 409 LSODE::do_integrate (const ColumnVector& tout, const ColumnVector& tcrit) |
3 | 410 { |
411 Matrix retval; | |
4049 | 412 |
20229
5dfaaaae784f
Deprecate Array::capacity() and Sparse::capacity() for numel() and nzmax().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
413 octave_idx_type n_out = tout.numel (); |
22988
cd33c785e80e
put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22960
diff
changeset
|
414 F77_INT n = octave::to_f77_int (size ()); |
3 | 415 |
416 if (n_out > 0 && n > 0) | |
417 { | |
418 retval.resize (n_out, n); | |
419 | |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
420 for (F77_INT i = 0; i < n; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
421 retval.elem (0, i) = x.elem (i); |
3 | 422 |
20229
5dfaaaae784f
Deprecate Array::capacity() and Sparse::capacity() for numel() and nzmax().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
423 octave_idx_type n_crit = tcrit.numel (); |
3 | 424 |
425 if (n_crit > 0) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
426 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
427 octave_idx_type i_crit = 0; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
428 octave_idx_type i_out = 1; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
429 double next_crit = tcrit.elem (0); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
430 double next_out; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
431 while (i_out < n_out) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
432 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
433 bool do_restart = false; |
3 | 434 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
435 next_out = tout.elem (i_out); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
436 if (i_crit < n_crit) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
437 next_crit = tcrit.elem (i_crit); |
3 | 438 |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
439 bool save_output = false; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
440 double t_out; |
3 | 441 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
442 if (next_crit == next_out) |
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 set_stop_time (next_crit); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
445 t_out = next_out; |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
446 save_output = true; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
447 i_out++; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
448 i_crit++; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
449 do_restart = true; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
450 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
451 else if (next_crit < next_out) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
452 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
453 if (i_crit < n_crit) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
454 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
455 set_stop_time (next_crit); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
456 t_out = next_crit; |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
457 save_output = false; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
458 i_crit++; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
459 do_restart = true; |
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 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
462 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
463 clear_stop_time (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
464 t_out = next_out; |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
465 save_output = true; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
466 i_out++; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
467 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
468 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
469 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
470 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
471 set_stop_time (next_crit); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
472 t_out = next_out; |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
473 save_output = true; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
474 i_out++; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
475 } |
3 | 476 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
477 ColumnVector x_next = do_integrate (t_out); |
3 | 478 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
479 if (integration_error) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
480 return retval; |
258 | 481 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
482 if (save_output) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
483 { |
22960
0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
484 for (F77_INT i = 0; i < n; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
485 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
|
486 } |
3 | 487 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
488 if (do_restart) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
489 force_restart (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
490 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
491 } |
3 | 492 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
493 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
494 retval = do_integrate (tout); |
258 | 495 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
496 if (integration_error) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
497 return retval; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
498 } |
3 | 499 } |
500 | |
501 return retval; | |
502 } |