3
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
3
|
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 the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 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, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
3
|
21 |
|
22 */ |
|
23 |
382
|
24 #if !defined (octave_DAEFunc_h) |
|
25 #define octave_DAEFunc_h 1 |
|
26 |
5275
|
27 #include "oct-types.h" |
|
28 |
465
|
29 class Matrix; |
|
30 class ColumnVector; |
3
|
31 |
1868
|
32 class |
|
33 DAEFunc |
3
|
34 { |
|
35 public: |
|
36 |
1528
|
37 typedef ColumnVector (*DAERHSFunc) (const ColumnVector& x, |
3849
|
38 const ColumnVector& xdot, |
5275
|
39 double t, octave_idx_type& ires); |
1528
|
40 |
3991
|
41 // This is really the form used by DASSL: |
|
42 // |
|
43 // PD = DG/DY + CJ * DG/DYPRIME |
|
44 |
|
45 typedef Matrix (*DAEJacFunc) (const ColumnVector& x, |
|
46 const ColumnVector& xdot, |
|
47 double t, double cj); |
1528
|
48 |
|
49 DAEFunc (void) |
4049
|
50 : fun (0), jac (0), reset (true) { } |
532
|
51 |
1528
|
52 DAEFunc (DAERHSFunc f) |
4049
|
53 : fun (f), jac (0), reset (true) { } |
532
|
54 |
1528
|
55 DAEFunc (DAERHSFunc f, DAEJacFunc j) |
4049
|
56 : fun (f), jac (j), reset (true) { } |
3
|
57 |
1528
|
58 DAEFunc (const DAEFunc& a) |
4049
|
59 : fun (a.fun), jac (a.jac), reset (a.reset) { } |
3
|
60 |
1528
|
61 DAEFunc& operator = (const DAEFunc& a) |
|
62 { |
1868
|
63 if (this != &a) |
|
64 { |
|
65 fun = a.fun; |
|
66 jac = a.jac; |
4049
|
67 reset = a.reset; |
1868
|
68 } |
1528
|
69 return *this; |
|
70 } |
3
|
71 |
1868
|
72 ~DAEFunc (void) { } |
|
73 |
1528
|
74 DAERHSFunc function (void) const { return fun; } |
|
75 |
|
76 DAEFunc& set_function (DAERHSFunc f) |
|
77 { |
|
78 fun = f; |
4049
|
79 reset = true; |
1528
|
80 return *this; |
|
81 } |
3
|
82 |
1528
|
83 DAEJacFunc jacobian_function (void) const { return jac; } |
3
|
84 |
1528
|
85 DAEFunc& set_jacobian_function (DAEJacFunc j) |
|
86 { |
|
87 jac = j; |
4049
|
88 reset = true; |
1528
|
89 return *this; |
|
90 } |
3
|
91 |
|
92 protected: |
|
93 |
|
94 DAERHSFunc fun; |
|
95 DAEJacFunc jac; |
4049
|
96 |
|
97 // This variable is TRUE when this object is constructed, and also |
|
98 // after any internal data has changed. Derived classes may use |
|
99 // this information (and change it) to know when to (re)initialize |
|
100 // their own internal data related to this object. |
|
101 |
|
102 bool reset; |
3
|
103 }; |
|
104 |
|
105 #endif |
382
|
106 |
|
107 /* |
|
108 ;;; Local Variables: *** |
|
109 ;;; mode: C++ *** |
|
110 ;;; End: *** |
|
111 */ |