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 DAEFunc(void)51 DAEFunc (void) 52 : fun (nullptr), jac (nullptr), reset (true) { } 53 DAEFunc(DAERHSFunc f)54 DAEFunc (DAERHSFunc f) 55 : fun (f), jac (nullptr), reset (true) { } 56 DAEFunc(DAERHSFunc f,DAEJacFunc j)57 DAEFunc (DAERHSFunc f, DAEJacFunc j) 58 : fun (f), jac (j), reset (true) { } 59 DAEFunc(const DAEFunc & a)60 DAEFunc (const DAEFunc& a) 61 : fun (a.fun), jac (a.jac), reset (a.reset) { } 62 63 DAEFunc& operator = (const DAEFunc& a) 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 function(void)76 DAERHSFunc function (void) const { return fun; } 77 set_function(DAERHSFunc f)78 DAEFunc& set_function (DAERHSFunc f) 79 { 80 fun = f; 81 reset = true; 82 return *this; 83 } 84 jacobian_function(void)85 DAEJacFunc jacobian_function (void) const { return jac; } 86 set_jacobian_function(DAEJacFunc j)87 DAEFunc& set_jacobian_function (DAEJacFunc j) 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 108