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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
1843
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_base_de_h) |
|
25 #define octave_base_de_h 1 |
|
26 |
3995
|
27 #include <string> |
|
28 |
1843
|
29 #include "dColVector.h" |
|
30 #include "dMatrix.h" |
|
31 |
1879
|
32 class |
|
33 base_diff_eqn |
1843
|
34 { |
|
35 public: |
|
36 |
3995
|
37 base_diff_eqn (void) |
|
38 : x (), t (0.0), stop_time (0.0), stop_time_set (false), |
3997
|
39 restart (true), integration_error (false), istate (0) { } |
1843
|
40 |
3995
|
41 base_diff_eqn (const ColumnVector& xx, double tt) |
|
42 : x (xx), t (tt), stop_time (0.0), stop_time_set (false), |
3997
|
43 restart (true), integration_error (false), istate (0) { } |
1843
|
44 |
3995
|
45 base_diff_eqn (const base_diff_eqn& a) |
|
46 : x (a.x), t (a.t), stop_time (0.0), stop_time_set (false), |
3997
|
47 restart (true), integration_error (false), istate (0) { } |
1843
|
48 |
|
49 virtual ~base_diff_eqn (void) { } |
|
50 |
|
51 base_diff_eqn& operator = (const base_diff_eqn& a) |
|
52 { |
1958
|
53 if (this != &a) |
|
54 { |
|
55 x = a.x; |
|
56 t = a.t; |
3995
|
57 stop_time = a.stop_time; |
|
58 stop_time_set = a.stop_time_set; |
|
59 restart = a.restart; |
|
60 integration_error = a.integration_error; |
3997
|
61 istate = a.istate; |
1958
|
62 } |
3995
|
63 |
1843
|
64 return *this; |
|
65 } |
|
66 |
3984
|
67 void initialize (const ColumnVector& x0, double t0) |
1843
|
68 { |
|
69 x = x0; |
|
70 t = t0; |
3995
|
71 integration_error = false; |
3997
|
72 istate = 0; |
1843
|
73 force_restart (); |
|
74 } |
|
75 |
5275
|
76 octave_idx_type size (void) const { return x.capacity (); } |
1843
|
77 |
|
78 ColumnVector state (void) const { return x; } |
|
79 |
|
80 double time (void) const { return t; } |
|
81 |
4277
|
82 void set_stop_time (double tt) |
3995
|
83 { |
|
84 stop_time_set = true; |
4277
|
85 stop_time = tt; |
4049
|
86 force_restart (); |
3995
|
87 } |
|
88 |
4049
|
89 void clear_stop_time (void) |
|
90 { |
|
91 stop_time_set = false; |
|
92 force_restart (); |
|
93 } |
3995
|
94 |
|
95 virtual void force_restart (void) { restart = true; } |
|
96 |
|
97 bool integration_ok (void) const { return ! integration_error; } |
|
98 |
5275
|
99 octave_idx_type integration_state (void) const { return istate; } |
3997
|
100 |
3995
|
101 virtual std::string error_message (void) const = 0; |
|
102 |
1843
|
103 protected: |
|
104 |
|
105 ColumnVector x; |
3995
|
106 |
1843
|
107 double t; |
3995
|
108 |
|
109 double stop_time; |
|
110 |
|
111 bool stop_time_set; |
|
112 |
|
113 bool restart; |
|
114 |
|
115 bool integration_error; |
3997
|
116 |
5275
|
117 octave_idx_type istate; |
1843
|
118 }; |
|
119 |
|
120 #endif |
|
121 |
|
122 /* |
|
123 ;;; Local Variables: *** |
|
124 ;;; mode: C++ *** |
|
125 ;;; End: *** |
|
126 */ |