comparison src/DLD-FUNCTIONS/fsolve.cc @ 4132:87eb044020ae

[project @ 2002-10-29 21:21:45 by jwe]
author jwe
date Tue, 29 Oct 2002 21:21:45 +0000
parents 19a1626b8d57
children 02ca908056e9
comparison
equal deleted inserted replaced
4131:597fbc55ea40 4132:87eb044020ae
183 ColumnVector x (args(1).vector_value ()); 183 ColumnVector x (args(1).vector_value ());
184 184
185 if (error_state) 185 if (error_state)
186 FSOLVE_ABORT1 ("expecting vector as second argument"); 186 FSOLVE_ABORT1 ("expecting vector as second argument");
187 187
188 if (nargin > 2) 188 if (nargin > 3)
189 warning ("fsolve: ignoring extra arguments"); 189 warning ("fsolve: ignoring extra arguments");
190 190
191 if (nargout > 2) 191 if (nargout > 3)
192 warning ("fsolve: can't compute path output yet"); 192 warning ("fsolve: can't compute path output yet");
193 193
194 NLFunc nleqn_fcn (fsolve_user_function); 194 NLFunc nleqn_fcn (fsolve_user_function);
195 NLEqn nleqn (x, nleqn_fcn); 195 NLEqn nleqn (x, nleqn_fcn);
196 nleqn.set_options (fsolve_opts); 196 nleqn.set_options (fsolve_opts);
203 std::string msg = nleqn.error_message (); 203 std::string msg = nleqn.error_message ();
204 204
205 retval(2) = msg; 205 retval(2) = msg;
206 retval(1) = static_cast<double> (hybrd_info_to_fsolve_info (info)); 206 retval(1) = static_cast<double> (hybrd_info_to_fsolve_info (info));
207 207
208 if (nleqn.solution_ok ()) 208 retval(0) = soln;
209 retval(0) = soln; 209
210 else 210 if (! nleqn.solution_ok () && nargout < 2)
211 { 211 error ("fsolve: %s", msg.c_str ());
212 retval(0) = Matrix ();
213
214 if (nargout < 2)
215 error ("fsolve: %s", msg.c_str ());
216 }
217 } 212 }
218 } 213 }
219 else 214 else
220 print_usage ("fsolve"); 215 print_usage ("fsolve");
221 216