changeset 260:74d73a4b3fc7

[project @ 1993-12-14 23:57:42 by jwe]
author jwe
date Tue, 14 Dec 1993 23:59:04 +0000
parents 23866011a5f2
children 48f2876fc807
files liboctave/Quad.cc liboctave/Quad.h src/npsol.cc src/quad.cc
diffstat 4 files changed, 37 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/Quad.cc	Tue Dec 14 22:21:35 1993 +0000
+++ b/liboctave/Quad.cc	Tue Dec 14 23:59:04 1993 +0000
@@ -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)
--- a/liboctave/Quad.h	Tue Dec 14 22:21:35 1993 +0000
+++ b/liboctave/Quad.h	Tue Dec 14 23:59:04 1993 +0000
@@ -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;
 };
--- a/src/npsol.cc	Tue Dec 14 22:21:35 1993 +0000
+++ b/src/npsol.cc	Tue Dec 14 23:59:04 1993 +0000
@@ -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;
 	}
--- a/src/quad.cc	Tue Dec 14 22:21:35 1993 +0000
+++ b/src/quad.cc	Tue Dec 14 23:59:04 1993 +0000
@@ -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 ();
 	}
     }