Mercurial > hg > octave-terminal
changeset 1937:4872b6022e6f
[project @ 1996-02-12 04:40:56 by jwe]
author | jwe |
---|---|
date | Mon, 12 Feb 1996 04:40:56 +0000 |
parents | 49f93fba6871 |
children | 126ebfbf3f99 |
files | liboctave/NLEqn.cc |
diffstat | 1 files changed, 26 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/NLEqn.cc +++ b/liboctave/NLEqn.cc @@ -144,47 +144,48 @@ double tol = tolerance (); - double *fvec = new double [n]; - double *px = new double [n]; - for (int i = 0; i < n; i++) - px[i] = x.elem (i); + retval = x; + double *px = retval.fortran_vec (); user_fun = fun; user_jac = jac; if (jac) { + Array<double> fvec (n); + double *pfvec = fvec.fortran_vec (); + int lwa = (n*(n+13))/2; - double *wa = new double [lwa]; - double *fjac = new double [n*n]; + Array<double> wa (lwa); + double *pwa = wa.fortran_vec (); - F77_FCN (hybrj1, HYBRJ1) (hybrj1_fcn, n, px, fvec, fjac, n, tol, - info, wa, lwa); + Array<double> fjac (n*n); + double *pfjac = fjac.fortran_vec (); - delete [] wa; - delete [] fjac; + F77_XFCN (hybrj1, HYBRJ1, (hybrj1_fcn, n, px, pfvec, pfjac, n, + tol, info, pwa, lwa)); + + if (f77_exception_encountered) + (*current_liboctave_error_handler) ("unrecoverable error in hybrj1"); } else { - int lwa = (n*(3*n+13))/2; - double *wa = new double [lwa]; + Array<double> fvec (n); + double *pfvec = fvec.fortran_vec (); - F77_FCN (hybrd1, HYBRD1) (hybrd1_fcn, n, px, fvec, tol, info, - wa, lwa); + int lwa = (n*(3*n+13))/2; + Array<double> wa (lwa); + double *pwa = wa.fortran_vec (); - delete [] wa; + F77_XFCN (hybrd1, HYBRD1, (hybrd1_fcn, n, px, pfvec, tol, info, + pwa, lwa)); + + if (f77_exception_encountered) + (*current_liboctave_error_handler) ("unrecoverable error in hybrd1"); } - if (info >= 0) - { - retval.resize (n); - - for (int i = 0; i < n; i++) - retval.elem (i) = px[i]; - } - - delete [] fvec; - delete [] px; + if (info < 0) + retval.resize (0); return retval; }