comparison liboctave/base-de.h @ 1843:88c5728ae7ae

[project @ 1996-02-03 11:44:20 by jwe] Initial revision
author jwe
date Sat, 03 Feb 1996 11:44:20 +0000
parents
children 1b43d3c06c04
comparison
equal deleted inserted replaced
1842:0574a1f3a273 1843:88c5728ae7ae
1 // base-de.h -*- C++ -*-
2 /*
3
4 Copyright (C) 1996 John W. Eaton
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22 */
23
24 #if !defined (octave_base_de_h)
25 #define octave_base_de_h 1
26
27 #include "dColVector.h"
28 #include "dMatrix.h"
29
30 class base_diff_eqn
31 {
32 public:
33
34 base_diff_eqn (void)
35 : x (), t (0.0) { }
36
37 base_diff_eqn (const ColumnVector& xx, double tt)
38 : x (xx), t (tt) { }
39
40 base_diff_eqn (const base_diff_eqn& a)
41 : x (a.x), t (a.t) { }
42
43 virtual ~base_diff_eqn (void) { }
44
45 base_diff_eqn& operator = (const base_diff_eqn& a)
46 {
47 x = a.x;
48 t = a.t;
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.
56 virtual ColumnVector do_integrate (double t) = 0;
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.
61 virtual Matrix do_integrate (const ColumnVector& t) = 0;
62
63 // There must also be a way for us to force the integration to
64 // restart.
65 virtual void force_restart (void) = 0;
66
67 // Lots of ways to call the single function and optionally set and
68 // get additional information.
69
70 // Integrate to t from current point.
71 virtual ColumnVector integrate (double t)
72 { return do_integrate (t); }
73
74 // Set new x0, t0 and integrate to t.
75 virtual ColumnVector integrate (const ColumnVector& x0, double t0, double t)
76 {
77 initialize (x0, t0);
78 return do_integrate (t);
79 }
80
81 // Integrate from current point and return output at all points
82 // specified by t.
83 virtual Matrix integrate (const ColumnVector t)
84 { return do_integrate (t); }
85
86 // Set new x0, t0 and integrate to return output at all points
87 // specified by t.
88 virtual Matrix integrate (const ColumnVector& x0, double t0,
89 const ColumnVector t)
90 {
91 initialize (x0, t0);
92 return do_integrate (t);
93 }
94
95 virtual void initialize (const ColumnVector& x0, double t0)
96 {
97 x = x0;
98 t = t0;
99 force_restart ();
100 }
101
102 int size (void) const { return x.capacity (); }
103
104 ColumnVector state (void) const { return x; }
105
106 double time (void) const { return t; }
107
108 protected:
109
110 ColumnVector x;
111 double t;
112 };
113
114 #endif
115
116 /*
117 ;;; Local Variables: ***
118 ;;; mode: C++ ***
119 ;;; page-delimiter: "^/\\*" ***
120 ;;; End: ***
121 */