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