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