annotate liboctave/DASPK.h @ 3912:f56cd411adb4

[project @ 2002-04-28 03:12:27 by jwe]
author jwe
date Sun, 28 Apr 2002 03:12:28 +0000
parents
children b050da7f9994
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3912
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
1 /*
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
2
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
3 Copyright (C) 1996, 1997, 2002 John W. Eaton
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
4
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
6
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
10 later version.
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
11
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
15 for more details.
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
16
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
20
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
21 */
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
22
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
23 #if !defined (octave_DASPK_h)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
24 #define octave_DASPK_h 1
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
25
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
26 #if defined (__GNUG__)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
27 #pragma interface
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
28 #endif
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
29
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
30 #include <cfloat>
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
31 #include <cmath>
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
32
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
33 #include "DAE.h"
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
34
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
35 class
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
36 DASPK_options
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
37 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
38 public:
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
39
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
40 DASPK_options (void) { init (); }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
41
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
42 DASPK_options (const DASPK_options& opt) { copy (opt); }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
43
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
44 DASPK_options& operator = (const DASPK_options& opt)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
45 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
46 if (this != &opt)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
47 copy (opt);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
48
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
49 return *this;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
50 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
51
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
52 ~DASPK_options (void) { }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
53
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
54 void init (void)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
55 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
56 x_absolute_tolerance = DBL_EPSILON * DBL_EPSILON;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
57 x_initial_step_size = -1.0;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
58 x_maximum_step_size = -1.0;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
59 x_minimum_step_size = 0.0;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
60 x_relative_tolerance = sqrt (DBL_EPSILON);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
61 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
62
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
63 void copy (const DASPK_options& opt)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
64 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
65 x_absolute_tolerance = opt.x_absolute_tolerance;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
66 x_initial_step_size = opt.x_initial_step_size;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
67 x_maximum_step_size = opt.x_maximum_step_size;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
68 x_minimum_step_size = opt.x_minimum_step_size;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
69 x_relative_tolerance = opt.x_relative_tolerance;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
70 }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
71
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
72 void set_default_options (void) { init (); }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
73
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
74 void set_absolute_tolerance (double val)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
75 { x_absolute_tolerance = (val > 0.0) ? val : DBL_EPSILON * DBL_EPSILON; }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
76
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
77 void set_initial_step_size (double val)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
78 { x_initial_step_size = (val >= 0.0) ? val : -1.0; }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
79
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
80 void set_maximum_step_size (double val)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
81 { x_maximum_step_size = (val >= 0.0) ? val : -1.0; }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
82
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
83 void set_minimum_step_size (double val)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
84 { x_minimum_step_size = (val >= 0.0) ? val : 0.0; }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
85
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
86 void set_relative_tolerance (double val)
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
87 { x_relative_tolerance = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
88
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
89 double absolute_tolerance (void) { return x_absolute_tolerance; }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
90
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
91 double initial_step_size (void) { return x_initial_step_size; }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
92
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
93 double maximum_step_size (void) { return x_maximum_step_size; }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
94
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
95 double minimum_step_size (void) { return x_minimum_step_size; }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
96
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
97 double relative_tolerance (void) { return x_relative_tolerance; }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
98
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
99 private:
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
100
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
101 double x_absolute_tolerance;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
102 double x_initial_step_size;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
103 double x_maximum_step_size;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
104 double x_minimum_step_size;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
105 double x_relative_tolerance;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
106 };
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
107
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
108 class
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
109 DASPK : public DAE, public DASPK_options
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
110 {
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
111 public:
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
112
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
113 DASPK (void);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
114
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
115 DASPK (const ColumnVector& x, double time, DAEFunc& f);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
116
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
117 DASPK (const ColumnVector& x, const ColumnVector& xdot,
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
118 double time, DAEFunc& f);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
119
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
120 ~DASPK (void) { }
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
121
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
122 void force_restart (void);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
123
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
124 void set_stop_time (double t);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
125 void clear_stop_time (void);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
126
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
127 ColumnVector do_integrate (double t);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
128
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
129 Matrix do_integrate (const ColumnVector& tout);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
130
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
131 Matrix do_integrate (const ColumnVector& tout, const ColumnVector& tcrit);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
132
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
133 Matrix integrate (const ColumnVector& tout, Matrix& xdot_out);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
134
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
135 Matrix integrate (const ColumnVector& tout, Matrix& xdot_out,
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
136 const ColumnVector& tcrit);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
137
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
138 private:
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
139
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
140 double stop_time;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
141 int stop_time_set;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
142
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
143 int n;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
144 int integration_error;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
145 int restart;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
146 int liw;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
147 int lrw;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
148 int idid;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
149 int sanity_checked;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
150 Array<int> info;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
151 Array<int> iwork;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
152 Array<double> rwork;
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
153
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
154 friend int ddaspk_j (double *time, double *state, double *deriv,
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
155 double *pd, double *cj, double *rpar, int *ipar);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
156
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
157 friend int ddaspk_f (double *time, double *state, double *deriv,
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
158 double *delta, int *ires, double *rpar, int *ipar);
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
159
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
160 };
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
161
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
162 #endif
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
163
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
164 /*
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
165 ;;; Local Variables: ***
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
166 ;;; mode: C++ ***
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
167 ;;; End: ***
f56cd411adb4 [project @ 2002-04-28 03:12:27 by jwe]
jwe
parents:
diff changeset
168 */