1843
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1843
|
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_base_de_h) |
|
24 #define octave_base_de_h 1 |
|
25 |
|
26 #include "dColVector.h" |
|
27 #include "dMatrix.h" |
|
28 |
1879
|
29 class |
|
30 base_diff_eqn |
1843
|
31 { |
|
32 public: |
|
33 |
1879
|
34 base_diff_eqn (void) : x (), t (0.0) { } |
1843
|
35 |
1879
|
36 base_diff_eqn (const ColumnVector& xx, double tt) : x (xx), t (tt) { } |
1843
|
37 |
1879
|
38 base_diff_eqn (const base_diff_eqn& a) : x (a.x), t (a.t) { } |
1843
|
39 |
|
40 virtual ~base_diff_eqn (void) { } |
|
41 |
|
42 base_diff_eqn& operator = (const base_diff_eqn& a) |
|
43 { |
1958
|
44 if (this != &a) |
|
45 { |
|
46 x = a.x; |
|
47 t = a.t; |
|
48 } |
1843
|
49 return *this; |
|
50 } |
|
51 |
|
52 // Derived classes must provide functions to actually do the |
|
53 // integration. |
|
54 |
|
55 // Return the vector of states at output time t. |
3508
|
56 virtual ColumnVector do_integrate (double tt) = 0; |
1843
|
57 |
|
58 // Return a matrix of states at each output time specified by t. |
|
59 // The rows of the result matrix should each correspond to a new |
|
60 // output time. |
3508
|
61 virtual Matrix do_integrate (const ColumnVector& tt) = 0; |
1843
|
62 |
3511
|
63 virtual Matrix do_integrate (const ColumnVector& tt, |
|
64 const ColumnVector& ttcrit) = 0; |
|
65 |
1843
|
66 // There must also be a way for us to force the integration to |
|
67 // restart. |
|
68 virtual void force_restart (void) = 0; |
|
69 |
|
70 // Lots of ways to call the single function and optionally set and |
|
71 // get additional information. |
|
72 |
|
73 // Integrate to t from current point. |
3508
|
74 virtual ColumnVector integrate (double tt) |
|
75 { return do_integrate (tt); } |
1843
|
76 |
|
77 // Set new x0, t0 and integrate to t. |
3508
|
78 virtual ColumnVector integrate (const ColumnVector& x0, double t0, double tt) |
1843
|
79 { |
|
80 initialize (x0, t0); |
3508
|
81 return do_integrate (tt); |
1843
|
82 } |
|
83 |
|
84 // Integrate from current point and return output at all points |
|
85 // specified by t. |
3510
|
86 virtual Matrix integrate (const ColumnVector& tt) |
3508
|
87 { return do_integrate (tt); } |
1843
|
88 |
|
89 // Set new x0, t0 and integrate to return output at all points |
|
90 // specified by t. |
|
91 virtual Matrix integrate (const ColumnVector& x0, double t0, |
3511
|
92 const ColumnVector& tt) |
1843
|
93 { |
|
94 initialize (x0, t0); |
3508
|
95 return do_integrate (tt); |
1843
|
96 } |
|
97 |
3511
|
98 // Integrate from current point and return output at all points |
|
99 // specified by t. |
|
100 virtual Matrix integrate (const ColumnVector& tt, |
|
101 const ColumnVector& ttcrit) |
|
102 { return do_integrate (tt, ttcrit); } |
|
103 |
|
104 // Set new x0, t0 and integrate to return output at all points |
|
105 // specified by t. |
|
106 virtual Matrix integrate (const ColumnVector& x0, double t0, |
|
107 const ColumnVector& tt, |
|
108 const ColumnVector& ttcrit) |
|
109 { |
|
110 initialize (x0, t0); |
|
111 return do_integrate (tt, ttcrit); |
|
112 } |
|
113 |
1843
|
114 virtual void initialize (const ColumnVector& x0, double t0) |
|
115 { |
|
116 x = x0; |
|
117 t = t0; |
|
118 force_restart (); |
|
119 } |
|
120 |
|
121 int size (void) const { return x.capacity (); } |
|
122 |
|
123 ColumnVector state (void) const { return x; } |
|
124 |
|
125 double time (void) const { return t; } |
|
126 |
|
127 protected: |
|
128 |
|
129 ColumnVector x; |
|
130 double t; |
|
131 }; |
|
132 |
|
133 #endif |
|
134 |
|
135 /* |
|
136 ;;; Local Variables: *** |
|
137 ;;; mode: C++ *** |
|
138 ;;; End: *** |
|
139 */ |