GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ODEFunc.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_ODEFunc_h)
27 #define octave_ODEFunc_h 1
28 
29 #include "octave-config.h"
30 
31 class Matrix;
32 class ColumnVector;
33 
34 class
35 ODEFunc
36 {
37 public:
38 
39  typedef ColumnVector (*ODERHSFunc) (const ColumnVector&, double);
40  typedef Matrix (*ODEJacFunc) (const ColumnVector&, double);
41 
42  ODEFunc (void)
43  : fun (nullptr), jac (nullptr), reset (true) { }
44 
45  ODEFunc (ODERHSFunc f)
46  : fun (f), jac (nullptr), reset (true) { }
47 
48  ODEFunc (ODERHSFunc f, ODEJacFunc j)
49  : fun (f), jac (j), reset (true) { }
50 
51  ODEFunc (const ODEFunc& a)
52  : fun (a.fun), jac (a.jac), reset (true) { }
53 
55  {
56  if (this != &a)
57  {
58  fun = a.fun;
59  jac = a.jac;
60  reset = a.reset;
61  }
62  return *this;
63  }
64 
65  virtual ~ODEFunc (void) = default;
66 
67  ODERHSFunc function (void) const { return fun; }
68 
69  ODEFunc& set_function (ODERHSFunc f)
70  {
71  fun = f;
72  reset = true;
73  return *this;
74  }
75 
76  ODEJacFunc jacobian_function (void) const { return jac; }
77 
79  {
80  jac = j;
81  reset = true;
82  return *this;
83  }
84 
85 protected:
86 
87  ODERHSFunc fun;
88  ODEJacFunc jac;
89 
90  // This variable is TRUE when this object is constructed, and also
91  // after any internal data has changed. Derived classes may use
92  // this information (and change it) to know when to (re)initialize
93  // their own internal data related to this object.
94 
95  bool reset;
96 };
97 
98 #endif
ColumnVector & operator=(const ColumnVector &a)
Definition: dColVector.h:56
ColumnVector(void)
Definition: dColVector.h:40
Definition: dMatrix.h:42
virtual ~ODEFunc(void)=default
ODEFunc & set_jacobian_function(ODEJacFunc j)
Definition: ODEFunc.h:78
ODEFunc(ODERHSFunc f)
Definition: ODEFunc.h:45
ODERHSFunc fun
Definition: ODEFunc.h:87
ODEFunc(const ODEFunc &a)
Definition: ODEFunc.h:51
ODEFunc(void)
Definition: ODEFunc.h:42
ODEFunc & set_function(ODERHSFunc f)
Definition: ODEFunc.h:69
ODEFunc(ODERHSFunc f, ODEJacFunc j)
Definition: ODEFunc.h:48
ODEJacFunc jac
Definition: ODEFunc.h:88
bool reset
Definition: ODEFunc.h:95
ODEJacFunc jacobian_function(void) const
Definition: ODEFunc.h:76
F77_RET_T const F77_DBLE const F77_DBLE * f