3
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2001, 2002, 2005, |
|
4 2007 John W. Eaton |
3
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
3
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
3
|
21 |
|
22 */ |
|
23 |
382
|
24 #if !defined (octave_DAEFunc_h) |
|
25 #define octave_DAEFunc_h 1 |
|
26 |
465
|
27 class Matrix; |
|
28 class ColumnVector; |
3
|
29 |
1868
|
30 class |
|
31 DAEFunc |
3
|
32 { |
|
33 public: |
|
34 |
1528
|
35 typedef ColumnVector (*DAERHSFunc) (const ColumnVector& x, |
3849
|
36 const ColumnVector& xdot, |
5275
|
37 double t, octave_idx_type& ires); |
1528
|
38 |
3991
|
39 // This is really the form used by DASSL: |
|
40 // |
|
41 // PD = DG/DY + CJ * DG/DYPRIME |
|
42 |
|
43 typedef Matrix (*DAEJacFunc) (const ColumnVector& x, |
|
44 const ColumnVector& xdot, |
|
45 double t, double cj); |
1528
|
46 |
|
47 DAEFunc (void) |
4049
|
48 : fun (0), jac (0), reset (true) { } |
532
|
49 |
1528
|
50 DAEFunc (DAERHSFunc f) |
4049
|
51 : fun (f), jac (0), reset (true) { } |
532
|
52 |
1528
|
53 DAEFunc (DAERHSFunc f, DAEJacFunc j) |
4049
|
54 : fun (f), jac (j), reset (true) { } |
3
|
55 |
1528
|
56 DAEFunc (const DAEFunc& a) |
4049
|
57 : fun (a.fun), jac (a.jac), reset (a.reset) { } |
3
|
58 |
1528
|
59 DAEFunc& operator = (const DAEFunc& a) |
|
60 { |
1868
|
61 if (this != &a) |
|
62 { |
|
63 fun = a.fun; |
|
64 jac = a.jac; |
4049
|
65 reset = a.reset; |
1868
|
66 } |
1528
|
67 return *this; |
|
68 } |
3
|
69 |
1868
|
70 ~DAEFunc (void) { } |
|
71 |
1528
|
72 DAERHSFunc function (void) const { return fun; } |
|
73 |
|
74 DAEFunc& set_function (DAERHSFunc f) |
|
75 { |
|
76 fun = f; |
4049
|
77 reset = true; |
1528
|
78 return *this; |
|
79 } |
3
|
80 |
1528
|
81 DAEJacFunc jacobian_function (void) const { return jac; } |
3
|
82 |
1528
|
83 DAEFunc& set_jacobian_function (DAEJacFunc j) |
|
84 { |
|
85 jac = j; |
4049
|
86 reset = true; |
1528
|
87 return *this; |
|
88 } |
3
|
89 |
|
90 protected: |
|
91 |
|
92 DAERHSFunc fun; |
|
93 DAEJacFunc jac; |
4049
|
94 |
|
95 // This variable is TRUE when this object is constructed, and also |
|
96 // after any internal data has changed. Derived classes may use |
|
97 // this information (and change it) to know when to (re)initialize |
|
98 // their own internal data related to this object. |
|
99 |
|
100 bool reset; |
3
|
101 }; |
|
102 |
|
103 #endif |