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 |
238
|
27 class ostream; |
3
|
28 |
461
|
29 #include "dMatrix.h" |
|
30 #include "dColVector.h" |
3
|
31 #include "ODEFunc.h" |
|
32 |
384
|
33 extern "C++" { |
|
34 |
289
|
35 class ODE_options |
|
36 { |
|
37 public: |
|
38 |
|
39 ODE_options (void); |
|
40 ODE_options (const ODE_options& opt); |
|
41 |
|
42 ODE_options& operator = (const ODE_options& opt); |
|
43 |
|
44 ~ODE_options (void); |
|
45 |
|
46 void init (void); |
|
47 void copy (const ODE_options& opt); |
|
48 |
|
49 void set_default_options (void); |
|
50 |
|
51 void set_absolute_tolerance (double); |
|
52 void set_initial_step_size (double); |
|
53 void set_maximum_step_size (double); |
|
54 void set_minimum_step_size (double); |
|
55 void set_relative_tolerance (double); |
|
56 |
|
57 double absolute_tolerance (void); |
|
58 double initial_step_size (void); |
|
59 double maximum_step_size (void); |
|
60 double minimum_step_size (void); |
|
61 double relative_tolerance (void); |
|
62 |
|
63 private: |
|
64 |
|
65 double x_absolute_tolerance; |
|
66 double x_initial_step_size; |
|
67 double x_maximum_step_size; |
|
68 double x_minimum_step_size; |
|
69 double x_relative_tolerance; |
|
70 }; |
|
71 |
|
72 class ODE : public ODEFunc, public ODE_options |
3
|
73 { |
|
74 public: |
|
75 |
|
76 ODE (void); |
|
77 |
|
78 ODE (int n); |
|
79 |
|
80 ODE (const ColumnVector& state, double time, const ODEFunc& f); |
|
81 |
|
82 virtual ~ODE (void); |
|
83 |
|
84 virtual int size (void) const; |
|
85 virtual ColumnVector state (void) const; |
|
86 virtual double time (void) const; |
|
87 |
|
88 virtual void force_restart (void); |
|
89 virtual void initialize (const ColumnVector& x, double t); |
|
90 virtual void set_stop_time (double t); |
|
91 virtual void clear_stop_time (void); |
|
92 |
|
93 virtual ColumnVector integrate (double t); |
|
94 |
|
95 void integrate (int nsteps, double tstep, ostream& s); |
|
96 |
|
97 Matrix integrate (const ColumnVector& tout); |
|
98 Matrix integrate (const ColumnVector& tout, const ColumnVector& tcrit); |
|
99 |
|
100 protected: |
|
101 |
|
102 /* |
|
103 * Some of this is probably too closely related to LSODE, but hey, |
|
104 * this is just a first attempt... |
|
105 */ |
|
106 |
|
107 int n; |
|
108 double t; |
|
109 ColumnVector x; |
|
110 |
|
111 double stop_time; |
|
112 int stop_time_set; |
|
113 |
|
114 private: |
|
115 |
258
|
116 int integration_error; |
3
|
117 int restart; |
|
118 int method_flag; |
|
119 int *iwork; |
|
120 double *rwork; |
|
121 int istate; |
|
122 int itol; |
|
123 int itask; |
|
124 int iopt; |
|
125 int liw; |
|
126 int lrw; |
|
127 |
|
128 friend int lsode_f (int *neq, double *t, double *y, double *ydot); |
|
129 |
|
130 friend int lsode_j (int *neq, double *t, double *y, int *ml, int *mu, |
|
131 double *pd, int *nrowpd); |
|
132 |
|
133 }; |
|
134 |
382
|
135 } // extern "C++" |
|
136 |
3
|
137 #endif |
|
138 |
|
139 /* |
|
140 ;;; Local Variables: *** |
|
141 ;;; mode: C++ *** |
|
142 ;;; page-delimiter: "^/\\*" *** |
|
143 ;;; End: *** |
|
144 */ |