Mercurial > octave-nkf
comparison src/DLD-FUNCTIONS/fsolve.cc @ 5275:23b37da9fd5b
[project @ 2005-04-08 16:07:35 by jwe]
author | jwe |
---|---|
date | Fri, 08 Apr 2005 16:07:37 +0000 |
parents | c0121a3b9cbe |
children | 4c8a2e4e0717 |
comparison
equal
deleted
inserted
replaced
5274:eae7b40388e9 | 5275:23b37da9fd5b |
---|---|
54 static bool warned_jac_imaginary = false; | 54 static bool warned_jac_imaginary = false; |
55 | 55 |
56 // Is this a recursive call? | 56 // Is this a recursive call? |
57 static int call_depth = 0; | 57 static int call_depth = 0; |
58 | 58 |
59 int | 59 octave_idx_type |
60 hybrd_info_to_fsolve_info (int info) | 60 hybrd_info_to_fsolve_info (octave_idx_type info) |
61 { | 61 { |
62 switch (info) | 62 switch (info) |
63 { | 63 { |
64 case -1: | 64 case -1: |
65 info = -2; | 65 info = -2; |
93 ColumnVector | 93 ColumnVector |
94 fsolve_user_function (const ColumnVector& x) | 94 fsolve_user_function (const ColumnVector& x) |
95 { | 95 { |
96 ColumnVector retval; | 96 ColumnVector retval; |
97 | 97 |
98 int n = x.length (); | 98 octave_idx_type n = x.length (); |
99 | 99 |
100 octave_value_list args; | 100 octave_value_list args; |
101 args.resize (1); | 101 args.resize (1); |
102 | 102 |
103 if (n > 1) | 103 if (n > 1) |
104 { | 104 { |
105 Matrix m (n, 1); | 105 Matrix m (n, 1); |
106 for (int i = 0; i < n; i++) | 106 for (octave_idx_type i = 0; i < n; i++) |
107 m (i, 0) = x (i); | 107 m (i, 0) = x (i); |
108 octave_value vars (m); | 108 octave_value vars (m); |
109 args(0) = vars; | 109 args(0) = vars; |
110 } | 110 } |
111 else | 111 else |
142 Matrix | 142 Matrix |
143 fsolve_user_jacobian (const ColumnVector& x) | 143 fsolve_user_jacobian (const ColumnVector& x) |
144 { | 144 { |
145 Matrix retval; | 145 Matrix retval; |
146 | 146 |
147 int n = x.length (); | 147 octave_idx_type n = x.length (); |
148 | 148 |
149 octave_value_list args; | 149 octave_value_list args; |
150 args.resize (1); | 150 args.resize (1); |
151 | 151 |
152 if (n > 1) | 152 if (n > 1) |
153 { | 153 { |
154 Matrix m (n, 1); | 154 Matrix m (n, 1); |
155 for (int i = 0; i < n; i++) | 155 for (octave_idx_type i = 0; i < n; i++) |
156 m(i,0) = x(i); | 156 m(i,0) = x(i); |
157 octave_value vars (m); | 157 octave_value vars (m); |
158 args(0) = vars; | 158 args(0) = vars; |
159 } | 159 } |
160 else | 160 else |
314 nleqn_fcn.set_jacobian_function (fsolve_user_jacobian); | 314 nleqn_fcn.set_jacobian_function (fsolve_user_jacobian); |
315 | 315 |
316 NLEqn nleqn (x, nleqn_fcn); | 316 NLEqn nleqn (x, nleqn_fcn); |
317 nleqn.set_options (fsolve_opts); | 317 nleqn.set_options (fsolve_opts); |
318 | 318 |
319 int info; | 319 octave_idx_type info; |
320 ColumnVector soln = nleqn.solve (info); | 320 ColumnVector soln = nleqn.solve (info); |
321 | 321 |
322 if (! error_state) | 322 if (! error_state) |
323 { | 323 { |
324 std::string msg = nleqn.error_message (); | 324 std::string msg = nleqn.error_message (); |