1841
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1841
|
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_DASSL_h) |
|
24 #define octave_DASSL_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
1871
|
30 #include <cfloat> |
1868
|
31 #include <cmath> |
|
32 |
1841
|
33 #include "DAE.h" |
|
34 |
1868
|
35 class |
|
36 DASSL_options |
1841
|
37 { |
1868
|
38 public: |
|
39 |
|
40 DASSL_options (void) { init (); } |
1841
|
41 |
1868
|
42 DASSL_options (const DASSL_options& opt) { copy (opt); } |
|
43 |
|
44 DASSL_options& operator = (const DASSL_options& opt) |
|
45 { |
|
46 if (this != &opt) |
|
47 copy (opt); |
1841
|
48 |
1868
|
49 return *this; |
|
50 } |
|
51 |
|
52 ~DASSL_options (void) { } |
1841
|
53 |
1868
|
54 void init (void) |
|
55 { |
|
56 double sqrt_eps = sqrt (DBL_EPSILON); |
|
57 x_absolute_tolerance = sqrt_eps; |
|
58 x_initial_step_size = -1.0; |
|
59 x_maximum_step_size = -1.0; |
|
60 x_minimum_step_size = 0.0; |
|
61 x_relative_tolerance = sqrt_eps; |
|
62 } |
1841
|
63 |
1868
|
64 void copy (const DASSL_options& opt) |
|
65 { |
|
66 x_absolute_tolerance = opt.x_absolute_tolerance; |
|
67 x_initial_step_size = opt.x_initial_step_size; |
|
68 x_maximum_step_size = opt.x_maximum_step_size; |
|
69 x_minimum_step_size = opt.x_minimum_step_size; |
|
70 x_relative_tolerance = opt.x_relative_tolerance; |
|
71 } |
1841
|
72 |
1868
|
73 void set_default_options (void) { init (); } |
|
74 |
|
75 void set_absolute_tolerance (double val) |
|
76 { x_absolute_tolerance = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); } |
|
77 |
|
78 void set_initial_step_size (double val) |
|
79 { x_initial_step_size = (val >= 0.0) ? val : -1.0; } |
1841
|
80 |
1868
|
81 void set_maximum_step_size (double val) |
|
82 { x_maximum_step_size = (val >= 0.0) ? val : -1.0; } |
|
83 |
|
84 void set_minimum_step_size (double val) |
|
85 { x_minimum_step_size = (val >= 0.0) ? val : 0.0; } |
|
86 |
|
87 void set_relative_tolerance (double val) |
|
88 { x_relative_tolerance = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); } |
1841
|
89 |
1868
|
90 double absolute_tolerance (void) { return x_absolute_tolerance; } |
|
91 |
|
92 double initial_step_size (void) { return x_initial_step_size; } |
|
93 |
|
94 double maximum_step_size (void) { return x_maximum_step_size; } |
|
95 |
|
96 double minimum_step_size (void) { return x_minimum_step_size; } |
|
97 |
|
98 double relative_tolerance (void) { return x_relative_tolerance; } |
|
99 |
|
100 private: |
1841
|
101 |
|
102 double x_absolute_tolerance; |
|
103 double x_initial_step_size; |
|
104 double x_maximum_step_size; |
|
105 double x_minimum_step_size; |
|
106 double x_relative_tolerance; |
|
107 }; |
|
108 |
1868
|
109 class |
|
110 DASSL : public DAE, public DASSL_options |
1841
|
111 { |
|
112 public: |
|
113 |
|
114 DASSL (void); |
|
115 |
|
116 DASSL (const ColumnVector& x, double time, DAEFunc& f); |
|
117 |
|
118 DASSL (const ColumnVector& x, const ColumnVector& xdot, |
|
119 double time, DAEFunc& f); |
|
120 |
1945
|
121 ~DASSL (void) { } |
1841
|
122 |
|
123 void force_restart (void); |
|
124 |
|
125 void set_stop_time (double t); |
|
126 void clear_stop_time (void); |
|
127 |
|
128 ColumnVector do_integrate (double t); |
|
129 |
|
130 Matrix do_integrate (const ColumnVector& tout); |
|
131 |
3519
|
132 Matrix do_integrate (const ColumnVector& tout, const ColumnVector& tcrit); |
|
133 |
1841
|
134 Matrix integrate (const ColumnVector& tout, Matrix& xdot_out); |
|
135 |
|
136 Matrix integrate (const ColumnVector& tout, Matrix& xdot_out, |
|
137 const ColumnVector& tcrit); |
|
138 |
|
139 private: |
|
140 |
|
141 double stop_time; |
|
142 int stop_time_set; |
|
143 |
3488
|
144 int n; |
1841
|
145 int integration_error; |
|
146 int restart; |
|
147 int liw; |
|
148 int lrw; |
|
149 int idid; |
2344
|
150 int sanity_checked; |
1945
|
151 Array<int> info; |
|
152 Array<int> iwork; |
|
153 Array<double> rwork; |
1841
|
154 |
|
155 friend int ddassl_j (double *time, double *state, double *deriv, |
|
156 double *pd, double *cj, double *rpar, int *ipar); |
|
157 |
|
158 friend int ddassl_f (double *time, double *state, double *deriv, |
|
159 double *delta, int *ires, double *rpar, int *ipar); |
|
160 |
|
161 }; |
|
162 |
|
163 #endif |
|
164 |
|
165 /* |
|
166 ;;; Local Variables: *** |
|
167 ;;; mode: C++ *** |
|
168 ;;; End: *** |
|
169 */ |