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