# HG changeset patch # User jwe # Date 755913544 0 # Node ID 74d73a4b3fc78e1edcbd91ce68e78879021123eb # Parent 23866011a5f2295864d7ec82276ac7ba57874237 [project @ 1993-12-14 23:57:42 by jwe] diff --git a/liboctave/Quad.cc b/liboctave/Quad.cc --- a/liboctave/Quad.cc +++ b/liboctave/Quad.cc @@ -31,15 +31,21 @@ static integrand_fcn user_fcn; +// XXX FIXME XXX -- would be nice to not have to have this global +// variable. +// Nonzero means an error occurred in the calculation of the integrand +// function, and the user wants us to quit. +int quad_integration_error = 0; + extern "C" { - int F77_FCN (dqagp) (const double (*)(double*), const double*, + int F77_FCN (dqagp) (const double (*)(double*, int*), const double*, const double*, const int*, const double*, const double*, const double*, double*, double*, int*, int*, const int*, const int*, int*, int*, double*); - int F77_FCN (dqagi) (const double (*)(double*), const double*, + int F77_FCN (dqagi) (const double (*)(double*, int*), const double*, const int*, const double*, const double*, double*, double*, int*, int*, const int*, const int*, int*, int*, double*); @@ -83,7 +89,7 @@ } static double -user_function (double *x) +user_function (double *x, int *ierr) { #if defined (sun) && defined (__GNUC__) double xx = access_double (x); @@ -91,7 +97,14 @@ double xx = *x; #endif - return (*user_fcn) (xx); + quad_integration_error = 0; + + double retval = (*user_fcn) (xx); + + if (quad_integration_error) + *ierr = -1; + + return retval; } DefQuad::DefQuad (integrand_fcn fcn) : Quad (fcn) diff --git a/liboctave/Quad.h b/liboctave/Quad.h --- a/liboctave/Quad.h +++ b/liboctave/Quad.h @@ -37,6 +37,12 @@ #endif +// XXX FIXME XXX -- would be nice to not have to have this global +// variable. +// Nonzero means an error occurred in the calculation of the integrand +// function, and the user wants us to quit. +extern int quad_integration_error; + class Quad { public: @@ -96,6 +102,7 @@ private: + int integration_error; double bound; IntegralType type; }; diff --git a/src/npsol.cc b/src/npsol.cc --- a/src/npsol.cc +++ b/src/npsol.cc @@ -86,6 +86,7 @@ { error ("npsol: error evaluating objective function"); npsol_objective_error = 1; // XXX FIXME XXX + delete [] tmp; return retval; } @@ -163,6 +164,7 @@ if (error_state) { + delete [] tmp; error ("npsol: error evaluating constraints"); return retval; } diff --git a/src/quad.cc b/src/quad.cc --- a/src/quad.cc +++ b/src/quad.cc @@ -59,7 +59,17 @@ if (quad_fcn != NULL_TREE) { tree_constant *tmp = quad_fcn->eval (args, 2, 1, 0); + delete [] args; + + if (error_state) + { + delete [] tmp; + quad_integration_error = 1; // XXX FIXME XXX + gripe_user_supplied_eval ("quad"); + return retval; + } + if (tmp != NULL_TREE_CONST && tmp[0].is_defined ()) { retval = tmp[0].to_scalar (); @@ -68,8 +78,8 @@ else { delete [] tmp; + quad_integration_error = 1; // XXX FIXME XXX gripe_user_supplied_eval ("quad"); - jump_to_top_level (); } }