3
|
1 // ODE.h -*- C++ -*- |
|
2 /* |
|
3 |
296
|
4 Copyright (C) 1992, 1993, 1994 John W. Eaton |
3
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
382
|
24 #if !defined (octave_ODE_h) |
|
25 #define octave_ODE_h 1 |
|
26 |
461
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
238
|
31 class ostream; |
3
|
32 |
461
|
33 #include "dMatrix.h" |
|
34 #include "dColVector.h" |
3
|
35 #include "ODEFunc.h" |
|
36 |
384
|
37 extern "C++" { |
|
38 |
289
|
39 class ODE_options |
|
40 { |
|
41 public: |
|
42 |
|
43 ODE_options (void); |
|
44 ODE_options (const ODE_options& opt); |
|
45 |
|
46 ODE_options& operator = (const ODE_options& opt); |
|
47 |
|
48 ~ODE_options (void); |
|
49 |
|
50 void init (void); |
|
51 void copy (const ODE_options& opt); |
|
52 |
|
53 void set_default_options (void); |
|
54 |
|
55 void set_absolute_tolerance (double); |
|
56 void set_initial_step_size (double); |
|
57 void set_maximum_step_size (double); |
|
58 void set_minimum_step_size (double); |
|
59 void set_relative_tolerance (double); |
|
60 |
|
61 double absolute_tolerance (void); |
|
62 double initial_step_size (void); |
|
63 double maximum_step_size (void); |
|
64 double minimum_step_size (void); |
|
65 double relative_tolerance (void); |
|
66 |
|
67 private: |
|
68 |
|
69 double x_absolute_tolerance; |
|
70 double x_initial_step_size; |
|
71 double x_maximum_step_size; |
|
72 double x_minimum_step_size; |
|
73 double x_relative_tolerance; |
|
74 }; |
|
75 |
|
76 class ODE : public ODEFunc, public ODE_options |
3
|
77 { |
|
78 public: |
|
79 |
|
80 ODE (void); |
|
81 |
|
82 ODE (int n); |
|
83 |
|
84 ODE (const ColumnVector& state, double time, const ODEFunc& f); |
|
85 |
|
86 virtual ~ODE (void); |
|
87 |
|
88 virtual int size (void) const; |
|
89 virtual ColumnVector state (void) const; |
|
90 virtual double time (void) const; |
|
91 |
|
92 virtual void force_restart (void); |
|
93 virtual void initialize (const ColumnVector& x, double t); |
|
94 virtual void set_stop_time (double t); |
|
95 virtual void clear_stop_time (void); |
|
96 |
|
97 virtual ColumnVector integrate (double t); |
|
98 |
|
99 void integrate (int nsteps, double tstep, ostream& s); |
|
100 |
|
101 Matrix integrate (const ColumnVector& tout); |
|
102 Matrix integrate (const ColumnVector& tout, const ColumnVector& tcrit); |
|
103 |
|
104 protected: |
|
105 |
|
106 /* |
|
107 * Some of this is probably too closely related to LSODE, but hey, |
|
108 * this is just a first attempt... |
|
109 */ |
|
110 |
|
111 int n; |
|
112 double t; |
|
113 ColumnVector x; |
|
114 |
|
115 double stop_time; |
|
116 int stop_time_set; |
|
117 |
|
118 private: |
|
119 |
258
|
120 int integration_error; |
3
|
121 int restart; |
|
122 int method_flag; |
|
123 int *iwork; |
|
124 double *rwork; |
|
125 int istate; |
|
126 int itol; |
|
127 int itask; |
|
128 int iopt; |
|
129 int liw; |
|
130 int lrw; |
|
131 |
|
132 friend int lsode_f (int *neq, double *t, double *y, double *ydot); |
|
133 |
|
134 friend int lsode_j (int *neq, double *t, double *y, int *ml, int *mu, |
|
135 double *pd, int *nrowpd); |
|
136 |
|
137 }; |
|
138 |
382
|
139 } // extern "C++" |
|
140 |
3
|
141 #endif |
|
142 |
|
143 /* |
|
144 ;;; Local Variables: *** |
|
145 ;;; mode: C++ *** |
|
146 ;;; page-delimiter: "^/\\*" *** |
|
147 ;;; End: *** |
|
148 */ |