comparison liboctave/NLEqn.cc @ 1251:97eac19837dc

[project @ 1995-04-11 15:58:32 by jwe]
author jwe
date Tue, 11 Apr 1995 15:58:32 +0000
parents b6360f2d4fa6
children bb67a902760b
comparison
equal deleted inserted replaced
1250:5cca5ae20299 1251:97eac19837dc
34 #include "lo-error.h" 34 #include "lo-error.h"
35 35
36 extern "C" 36 extern "C"
37 { 37 {
38 int F77_FCN (hybrd1) (int (*)(int*, double*, double*, int*), 38 int F77_FCN (hybrd1) (int (*)(int*, double*, double*, int*),
39 const int*, double*, double*, const double*, 39 const int&, double*, double*, const double&,
40 int*, double*, const int*); 40 int&, double*, const int&);
41 41
42 int F77_FCN (hybrj1) (int (*)(int*, double*, double*, double*, int*, int*), 42 int F77_FCN (hybrj1) (int (*)(int*, double*, double*, double*, int*, int*),
43 const int*, double*, double*, double*, const int*, 43 const int&, double*, double*, double*, const int&,
44 const double*, int*, double*, const int*); 44 const double&, int&, double*, const int&);
45 } 45 }
46 46
47 static nonlinear_fcn user_fun; 47 static nonlinear_fcn user_fun;
48 static jacobian_fcn user_jac; 48 static jacobian_fcn user_jac;
49 49
203 } 203 }
204 204
205 Vector 205 Vector
206 NLEqn::solve (int& info) 206 NLEqn::solve (int& info)
207 { 207 {
208 int tmp_info = 0;
209
210 if (n == 0) 208 if (n == 0)
211 { 209 {
212 error ("equation set not initialized"); 210 error ("equation set not initialized");
213 return Vector (); 211 return Vector ();
214 } 212 }
227 { 225 {
228 int lwa = (n*(n+13))/2; 226 int lwa = (n*(n+13))/2;
229 double *wa = new double [lwa]; 227 double *wa = new double [lwa];
230 double *fjac = new double [n*n]; 228 double *fjac = new double [n*n];
231 229
232 F77_FCN (hybrj1) (hybrj1_fcn, &n, px, fvec, fjac, &n, &tol, 230 F77_FCN (hybrj1) (hybrj1_fcn, n, px, fvec, fjac, n, tol, info,
233 &tmp_info, wa, &lwa); 231 wa, lwa);
234 232
235 delete [] wa; 233 delete [] wa;
236 delete [] fjac; 234 delete [] fjac;
237 } 235 }
238 else 236 else
239 { 237 {
240 int lwa = (n*(3*n+13))/2; 238 int lwa = (n*(3*n+13))/2;
241 double *wa = new double [lwa]; 239 double *wa = new double [lwa];
242 240
243 F77_FCN (hybrd1) (hybrd1_fcn, &n, px, fvec, &tol, &tmp_info, wa, &lwa); 241 F77_FCN (hybrd1) (hybrd1_fcn, n, px, fvec, tol, info, wa, lwa);
244 242
245 delete [] wa; 243 delete [] wa;
246 } 244 }
247 245
248 Vector retval; 246 Vector retval;
249
250 info = tmp_info;
251 247
252 if (info >= 0) 248 if (info >= 0)
253 { 249 {
254 retval.resize (n); 250 retval.resize (n);
255 251