GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ODE.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2013 John W. Eaton
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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_ODE_h)
24 #define octave_ODE_h 1
25 
26 #include "ODEFunc.h"
27 #include "base-de.h"
28 
29 class
30 ODE : public base_diff_eqn, public ODEFunc
31 {
32 public:
33 
34  ODE (void)
35  : base_diff_eqn (), ODEFunc () { }
36 
37  ODE (const ColumnVector& s, double tm, const ODEFunc& f)
38  : base_diff_eqn (s, tm), ODEFunc (f) { }
39 
40  ODE (const ODE& a)
41  : base_diff_eqn (a), ODEFunc (a) { }
42 
43  ODE& operator = (const ODE& a)
44  {
45  if (this != &a)
46  {
49  }
50  return *this;
51  }
52 
53  virtual ~ODE (void) { }
54 
55  // Derived classes must provide functions to actually do the
56  // integration.
57 
58  // Return the vector of states at output time t.
59  virtual ColumnVector do_integrate (double tt) = 0;
60 
61  // Return a matrix of states at each output time specified by t.
62  // The rows of the result matrix should each correspond to a new
63  // output time.
64  virtual Matrix do_integrate (const ColumnVector& tt) = 0;
65 
66  virtual Matrix do_integrate (const ColumnVector& tt,
67  const ColumnVector& ttcrit) = 0;
68 
69  // Lots of ways to call the single function and optionally set and
70  // get additional information.
71 
72  // Integrate to t from current point.
73  virtual ColumnVector integrate (double tt)
74  { return do_integrate (tt); }
75 
76  // Set new x0, t0 and integrate to t.
77  virtual ColumnVector integrate (const ColumnVector& x0, double t0, double tt)
78  {
79  initialize (x0, t0);
80  return do_integrate (tt);
81  }
82 
83  // Integrate from current point and return output at all points
84  // specified by t.
85  virtual Matrix integrate (const ColumnVector& tt)
86  { return do_integrate (tt); }
87 
88  // Set new x0, t0 and integrate to return output at all points
89  // specified by t.
90  virtual Matrix integrate (const ColumnVector& x0, double t0,
91  const ColumnVector& tt)
92  {
93  initialize (x0, t0);
94  return do_integrate (tt);
95  }
96 
97  // Integrate from current point and return output at all points
98  // specified by t.
99  virtual Matrix integrate (const ColumnVector& tt,
100  const ColumnVector& ttcrit)
101  { return do_integrate (tt, ttcrit); }
102 
103  // Set new x0, t0 and integrate to return output at all points
104  // specified by t.
105  virtual Matrix integrate (const ColumnVector& x0, double t0,
106  const ColumnVector& tt,
107  const ColumnVector& ttcrit)
108  {
109  initialize (x0, t0);
110  return do_integrate (tt, ttcrit);
111  }
112 };
113 
114 #endif