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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
3
|
20 |
|
21 */ |
|
22 |
382
|
23 #if !defined (octave_NLEqn_h) |
|
24 #define octave_NLEqn_h 1 |
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
1296
|
27 #pragma interface |
|
28 #endif |
|
29 |
1531
|
30 #include <cfloat> |
|
31 #include <cmath> |
|
32 |
3998
|
33 #include "NLEqn-opts.h" |
289
|
34 |
1865
|
35 class |
|
36 NLEqn : public NLFunc, public NLEqn_options |
3
|
37 { |
1865
|
38 public: |
1531
|
39 |
1865
|
40 NLEqn (void) |
3971
|
41 : NLFunc (), NLEqn_options (), x (), solution_status (0) { } |
1531
|
42 |
1865
|
43 NLEqn (const ColumnVector& xx, const NLFunc f) |
3971
|
44 : NLFunc (f), NLEqn_options (), x (xx), solution_status (0) { } |
1531
|
45 |
1865
|
46 NLEqn (const NLEqn& a) |
3971
|
47 : NLFunc (a.fun, a.jac), NLEqn_options (), x (a.x), |
|
48 solution_status (a.solution_status) { } |
3
|
49 |
1531
|
50 NLEqn& operator = (const NLEqn& a) |
|
51 { |
1865
|
52 if (this != &a) |
|
53 { |
|
54 NLFunc::operator = (a); |
|
55 NLEqn_options::operator = (a); |
1531
|
56 |
1865
|
57 x = a.x; |
3971
|
58 solution_status = a.solution_status; |
1865
|
59 } |
1531
|
60 return *this; |
|
61 } |
3
|
62 |
1865
|
63 ~NLEqn (void) { } |
3
|
64 |
1865
|
65 void set_states (const ColumnVector& xx) { x = xx; } |
1531
|
66 |
|
67 ColumnVector states (void) const { return x; } |
|
68 |
1865
|
69 int size (void) const { return x.capacity (); } |
3
|
70 |
1531
|
71 ColumnVector solve (void) |
|
72 { |
|
73 int info; |
|
74 return solve (info); |
|
75 } |
3
|
76 |
1531
|
77 ColumnVector solve (const ColumnVector& xvec) |
|
78 { |
|
79 set_states (xvec); |
|
80 int info; |
|
81 return solve (info); |
|
82 } |
3
|
83 |
1531
|
84 ColumnVector solve (const ColumnVector& xvec, int& info) |
|
85 { |
|
86 set_states (xvec); |
|
87 return solve (info); |
|
88 } |
|
89 |
|
90 ColumnVector solve (int& info); |
3
|
91 |
3971
|
92 int solution_state (void) const { return solution_status; } |
|
93 |
|
94 bool solution_ok (void) const { return solution_status == 1; } |
|
95 |
|
96 std::string error_message (void) const; |
|
97 |
|
98 private: |
3
|
99 |
1531
|
100 ColumnVector x; |
3971
|
101 int solution_status; |
3
|
102 |
|
103 void error (const char* msg); |
|
104 }; |
|
105 |
|
106 #endif |
|
107 |
|
108 /* |
|
109 ;;; Local Variables: *** |
|
110 ;;; mode: C++ *** |
|
111 ;;; End: *** |
|
112 */ |