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