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