comparison src/fsolve.cc @ 636:fae2bd91c027

[project @ 1994-08-23 18:39:50 by jwe]
author jwe
date Tue, 23 Aug 1994 18:39:50 +0000
parents aecbe369233b
children 0a81458ef677
comparison
equal deleted inserted replaced
635:5338832d2cf6 636:fae2bd91c027
49 switch (info) 49 switch (info)
50 { 50 {
51 case -1: 51 case -1:
52 info = -2; 52 info = -2;
53 break; 53 break;
54
54 case 0: 55 case 0:
55 info = -1; 56 info = -1;
56 break; 57 break;
58
57 case 1: 59 case 1:
58 break; 60 break;
61
59 case 2: 62 case 2:
60 info = 4; 63 info = 4;
61 break; 64 break;
65
62 case 3: 66 case 3:
63 case 4: 67 case 4:
64 case 5: 68 case 5:
65 info = 3; 69 info = 3;
66 break; 70 break;
71
67 default: 72 default:
68 panic_impossible (); 73 panic_impossible ();
69 break; 74 break;
70 } 75 }
76
71 return info; 77 return info;
72 } 78 }
73 79
74 ColumnVector 80 ColumnVector
75 fsolve_user_function (const ColumnVector& x) 81 fsolve_user_function (const ColumnVector& x)
103 Octave_object tmp = fsolve_fcn->eval (0, 1, args); 109 Octave_object tmp = fsolve_fcn->eval (0, 1, args);
104 if (tmp.length () > 0 && tmp(0).is_defined ()) 110 if (tmp.length () > 0 && tmp(0).is_defined ())
105 { 111 {
106 retval = tmp(0).vector_value (); 112 retval = tmp(0).vector_value ();
107 113
108 if (retval.length () <= 0) 114 if (error_state || retval.length () <= 0)
109 gripe_user_supplied_eval ("fsolve"); 115 gripe_user_supplied_eval ("fsolve");
110 } 116 }
111 else 117 else
112 gripe_user_supplied_eval ("fsolve"); 118 gripe_user_supplied_eval ("fsolve");
113 } 119 }
140 fsolve_fcn = is_valid_function (args(1), "fsolve", 1); 146 fsolve_fcn = is_valid_function (args(1), "fsolve", 1);
141 if (! fsolve_fcn || takes_correct_nargs (fsolve_fcn, 2, "fsolve", 1) != 1) 147 if (! fsolve_fcn || takes_correct_nargs (fsolve_fcn, 2, "fsolve", 1) != 1)
142 return retval; 148 return retval;
143 149
144 ColumnVector x = args(2).vector_value (); 150 ColumnVector x = args(2).vector_value ();
151
152 if (error_state)
153 {
154 error ("fsolve: expecting vector as second argument");
155 return retval;
156 }
145 157
146 if (nargin > 3) 158 if (nargin > 3)
147 warning ("fsolve: ignoring extra arguments"); 159 warning ("fsolve: ignoring extra arguments");
148 160
149 if (nargout > 2) 161 if (nargout > 2)
260 int nargin = args.length (); 272 int nargin = args.length ();
261 273
262 if (nargin == 1) 274 if (nargin == 1)
263 { 275 {
264 print_fsolve_option_list (); 276 print_fsolve_option_list ();
277 return retval;
265 } 278 }
266 else if (nargin == 3) 279 else if (nargin == 3)
267 { 280 {
268 if (args(1).is_string ()) 281 char *keyword = args(1).string_value ();
282
283 if (! error_state)
269 { 284 {
270 char *keyword = args(1).string_value ();
271 double val = args(2).double_value (); 285 double val = args(2).double_value ();
272 do_fsolve_option (keyword, val); 286
287 if (! error_state)
288 {
289 do_fsolve_option (keyword, val);
290 return retval;
291 }
273 } 292 }
274 else 293 }
275 print_usage ("fsolve_options"); 294
276 } 295 print_usage ("fsolve_options");
277 else
278 print_usage ("fsolve_options");
279 296
280 return retval; 297 return retval;
281 } 298 }
282 299
283 /* 300 /*