GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ODE.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2018 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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License 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 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_ODE_h)
24 #define octave_ODE_h 1
25 
26 #include "octave-config.h"
27 
28 #include "ODEFunc.h"
29 #include "base-de.h"
30 #include "dMatrix.h"
31 
32 class
33 ODE : public base_diff_eqn, public ODEFunc
34 {
35 public:
36 
37  ODE (void)
38  : base_diff_eqn (), ODEFunc () { }
39 
40  ODE (const ColumnVector& s, double tm, const ODEFunc& f)
41  : base_diff_eqn (s, tm), ODEFunc (f) { }
42 
43  ODE (const ODE& a)
44  : base_diff_eqn (a), ODEFunc (a) { }
45 
46  ODE& operator = (const ODE& a)
47  {
48  if (this != &a)
49  {
52  }
53  return *this;
54  }
55 
56  virtual ~ODE (void) = default;
57 
58  // Derived classes must provide functions to actually do the
59  // integration.
60 
61  // Return the vector of states at output time t.
62  virtual ColumnVector do_integrate (double tt) = 0;
63 
64  // Return a matrix of states at each output time specified by t.
65  // The rows of the result matrix should each correspond to a new
66  // output time.
67  virtual Matrix do_integrate (const ColumnVector& tt) = 0;
68 
69  virtual Matrix do_integrate (const ColumnVector& tt,
70  const ColumnVector& ttcrit) = 0;
71 
72  // Lots of ways to call the single function and optionally set and
73  // get additional information.
74 
75  // Integrate to t from current point.
76  virtual ColumnVector integrate (double tt)
77  { return do_integrate (tt); }
78 
79  // Set new x0, t0 and integrate to t.
80  virtual ColumnVector integrate (const ColumnVector& x0, double t0, double tt)
81  {
82  initialize (x0, t0);
83  return do_integrate (tt);
84  }
85 
86  // Integrate from current point and return output at all points
87  // specified by t.
88  virtual Matrix integrate (const ColumnVector& tt)
89  { return do_integrate (tt); }
90 
91  // Set new x0, t0 and integrate to return output at all points
92  // specified by t.
93  virtual Matrix integrate (const ColumnVector& x0, double t0,
94  const ColumnVector& tt)
95  {
96  initialize (x0, t0);
97  return do_integrate (tt);
98  }
99 
100  // Integrate from current point and return output at all points
101  // specified by t.
102  virtual Matrix integrate (const ColumnVector& tt,
103  const ColumnVector& ttcrit)
104  { return do_integrate (tt, ttcrit); }
105 
106  // Set new x0, t0 and integrate to return output at all points
107  // specified by t.
108  virtual Matrix integrate (const ColumnVector& x0, double t0,
109  const ColumnVector& tt,
110  const ColumnVector& ttcrit)
111  {
112  initialize (x0, t0);
113  return do_integrate (tt, ttcrit);
114  }
115 };
116 
117 #endif
ODE(const ColumnVector &s, double tm, const ODEFunc &f)
Definition: ODE.h:40
ODE(void)
Definition: ODE.h:37
virtual Matrix integrate(const ColumnVector &x0, double t0, const ColumnVector &tt, const ColumnVector &ttcrit)
Definition: ODE.h:108
ODEFunc & operator=(const ODEFunc &a)
Definition: ODEFunc.h:51
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
NDArray & operator=(const NDArray &a)
Definition: dNDArray.h:69
virtual ColumnVector integrate(double tt)
Definition: ODE.h:76
virtual Matrix integrate(const ColumnVector &x0, double t0, const ColumnVector &tt)
Definition: ODE.h:93
s
Definition: file-io.cc:2729
static void initialize(void)
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
virtual Matrix integrate(const ColumnVector &tt, const ColumnVector &ttcrit)
Definition: ODE.h:102
Definition: ODE.h:32
base_diff_eqn & operator=(const base_diff_eqn &a)
Definition: base-de.h:51
virtual Matrix integrate(const ColumnVector &tt)
Definition: ODE.h:88
Definition: dMatrix.h:36
virtual ColumnVector integrate(const ColumnVector &x0, double t0, double tt)
Definition: ODE.h:80
ODE(const ODE &a)
Definition: ODE.h:43