GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
DAEFunc.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_DAEFunc_h)
27 #define octave_DAEFunc_h 1
28 
29 #include "octave-config.h"
30 
31 class Matrix;
32 class ColumnVector;
33 
34 class
35 DAEFunc
36 {
37 public:
38 
39  typedef ColumnVector (*DAERHSFunc) (const ColumnVector& x,
40  const ColumnVector& xdot,
41  double t, octave_idx_type& ires);
42 
43  // This is really the form used by DASSL:
44  //
45  // PD = DG/DY + CJ * DG/DYPRIME
46 
47  typedef Matrix (*DAEJacFunc) (const ColumnVector& x,
48  const ColumnVector& xdot,
49  double t, double cj);
50 
51  DAEFunc (void)
52  : fun (nullptr), jac (nullptr), reset (true) { }
53 
54  DAEFunc (DAERHSFunc f)
55  : fun (f), jac (nullptr), reset (true) { }
56 
57  DAEFunc (DAERHSFunc f, DAEJacFunc j)
58  : fun (f), jac (j), reset (true) { }
59 
60  DAEFunc (const DAEFunc& a)
61  : fun (a.fun), jac (a.jac), reset (a.reset) { }
62 
64  {
65  if (this != &a)
66  {
67  fun = a.fun;
68  jac = a.jac;
69  reset = a.reset;
70  }
71  return *this;
72  }
73 
74  virtual ~DAEFunc (void) = default;
75 
76  DAERHSFunc function (void) const { return fun; }
77 
78  DAEFunc& set_function (DAERHSFunc f)
79  {
80  fun = f;
81  reset = true;
82  return *this;
83  }
84 
85  DAEJacFunc jacobian_function (void) const { return jac; }
86 
88  {
89  jac = j;
90  reset = true;
91  return *this;
92  }
93 
94 protected:
95 
96  DAERHSFunc fun;
97  DAEJacFunc jac;
98 
99  // This variable is TRUE when this object is constructed, and also
100  // after any internal data has changed. Derived classes may use
101  // this information (and change it) to know when to (re)initialize
102  // their own internal data related to this object.
103 
104  bool reset;
105 };
106 
107 #endif
ColumnVector & operator=(const ColumnVector &a)
Definition: dColVector.h:56
ColumnVector(void)
Definition: dColVector.h:40
DAEJacFunc jacobian_function(void) const
Definition: DAEFunc.h:85
DAEFunc(void)
Definition: DAEFunc.h:51
virtual ~DAEFunc(void)=default
bool reset
Definition: DAEFunc.h:104
DAEFunc(DAERHSFunc f)
Definition: DAEFunc.h:54
DAEFunc & set_jacobian_function(DAEJacFunc j)
Definition: DAEFunc.h:87
DAEFunc & set_function(DAERHSFunc f)
Definition: DAEFunc.h:78
DAEJacFunc jac
Definition: DAEFunc.h:97
DAEFunc(DAERHSFunc f, DAEJacFunc j)
Definition: DAEFunc.h:57
DAERHSFunc fun
Definition: DAEFunc.h:96
DAEFunc(const DAEFunc &a)
Definition: DAEFunc.h:60
Definition: dMatrix.h:42
F77_RET_T const F77_DBLE * x
F77_RET_T const F77_DBLE const F77_DBLE * f