Blame SOURCES/gsl-1.15-odeinitval2_upstream_rev4788.patch

a3f154
diff -up wrk/ode-initval2/bsimp.c.wrk wrk/ode-initval2/bsimp.c
a3f154
diff -U0 wrk/ode-initval2/ChangeLog.wrk wrk/ode-initval2/ChangeLog
a3f154
--- wrk/ode-initval2/ChangeLog.wrk	2013-01-29 13:40:22.470035141 +0100
a3f154
+++ wrk/ode-initval2/ChangeLog	2013-01-29 12:58:21.000000000 +0100
a3f154
@@ -0,0 +1,52 @@
a3f154
+2013-01-27  Tuomo Keskitalo  <tuomo.keskitalo@iki.fi>
a3f154
+
a3f154
+	* msbdf.c: Corrected bug which enabled order to be changed 
a3f154
+	by two (first by stability enhancement, then by order evaluation
a3f154
+	after a rejected step). Thanks for Frantisek Kluknavsky and
a3f154
+	Andreas Schwab for bug reports!
a3f154
+	
a3f154
+	* msbdf.c: Added more state variables explicitly to be reset in 
a3f154
+	msbdf_reset. 
a3f154
+
a3f154
+	*msbdf.c: Added abscorscaled to remove division of abscor for 
a3f154
+	use in msbdf_eval_order and subsequent backwards multiplication.
a3f154
+	
a3f154
+	*test.c: test_extreme_problems: Increased ringmod case tolerances 
a3f154
+	from 1e-7 to 1e-12 to increase precision. Because that
a3f154
+	increases computational burden, I also decreased end time 
a3f154
+	from 1e-3 to 1e-5. That decreased the acidity of the test 
a3f154
+	significantly, but the test case is now more appropriate 
a3f154
+	for normal "make check". Thanks for Frantisek Kluknavsky
a3f154
+	for pointing out bad design of the test case.
a3f154
+
a3f154
+2012-09-10  Rhys Ulerich  <rhys.ulerich@gmail.com>
a3f154
+
a3f154
+	* test.c: Correct two out-of-order declarations.
a3f154
+	Thanks to Brian Gladman for spotting the problem.
a3f154
+
a3f154
+2012-03-10  Tuomo Keskitalo  <tuomo.keskitalo@iki.fi>
a3f154
+
a3f154
+	* driver.c: Added function gsl_odeiv2_driver_reset_hstart to
a3f154
+	allow resetting step size, possibly change its sign, too.
a3f154
+	Check for non-zero hstart in initializations.
a3f154
+
a3f154
+	* test.c: Modified test_driver to carry out tests with all
a3f154
+	steppers. Small printout changes.
a3f154
+
a3f154
+2012-01-21  Tuomo Keskitalo  <tuomo.keskitalo@iki.fi>
a3f154
+
a3f154
+	* rkf45.c: Bug correction: Set gives_exact_dydt_out to 1 in
a3f154
+	rkf45_type
a3f154
+
a3f154
+2012-01-14  Tuomo Keskitalo  <tuomo.keskitalo@iki.fi>
a3f154
+
a3f154
+	* evolve.c: Modified initial derivative evaluation in evolve_apply
a3f154
+	to reuse previously calculated values. This saves calls to the
a3f154
+	user function. Thanks for Illes Farkas for pointing out redundant
a3f154
+	function calls!
a3f154
+
a3f154
+2011-06-28  Brian Gough  <bjg@network-theory.co.uk>
a3f154
+
a3f154
+	* rk4imp.c (rk4imp_apply): use M_SQRT3 instead of sqrt(3) in array
a3f154
+	initialiser.
a3f154
+
a3f154
diff -up wrk/ode-initval2/control.c.wrk wrk/ode-initval2/control.c
a3f154
diff -up wrk/ode-initval2/control_utils.c.wrk wrk/ode-initval2/control_utils.c
a3f154
diff -up wrk/ode-initval2/cscal.c.wrk wrk/ode-initval2/cscal.c
a3f154
diff -up wrk/ode-initval2/cstd.c.wrk wrk/ode-initval2/cstd.c
a3f154
diff -up wrk/ode-initval2/driver.c.wrk wrk/ode-initval2/driver.c
a3f154
--- wrk/ode-initval2/driver.c.wrk	2013-01-29 13:40:22.508035371 +0100
a3f154
+++ wrk/ode-initval2/driver.c	2013-01-29 13:07:29.000000000 +0100
a3f154
@@ -81,7 +81,7 @@ driver_alloc (const gsl_odeiv2_system *
a3f154
       GSL_ERROR_NULL ("failed to allocate evolve object", GSL_ENOMEM);
a3f154
     }
a3f154
 
a3f154
-  if (hstart >= 0.0 || hstart < 0.0)
a3f154
+  if (hstart > 0.0 || hstart < 0.0)
a3f154
     {
a3f154
       state->h = hstart;
a3f154
     }
a3f154
@@ -459,6 +459,29 @@ gsl_odeiv2_driver_reset (gsl_odeiv2_driv
a3f154
   return GSL_SUCCESS;
a3f154
 }
a3f154
 
a3f154
+int
a3f154
+gsl_odeiv2_driver_reset_hstart (gsl_odeiv2_driver * d, const double hstart)
a3f154
+{
a3f154
+  /* Resets current driver and sets initial step size to hstart */
a3f154
+
a3f154
+  gsl_odeiv2_driver_reset (d);
a3f154
+
a3f154
+  if ((d->hmin > fabs (hstart)) || (fabs (hstart) > d->hmax))
a3f154
+    {
a3f154
+      GSL_ERROR_NULL ("hmin <= fabs(h) <= hmax required", GSL_EINVAL);
a3f154
+    }
a3f154
+
a3f154
+  if (hstart > 0.0 || hstart < 0.0)
a3f154
+    {
a3f154
+      d->h = hstart;
a3f154
+    }
a3f154
+  else
a3f154
+    {
a3f154
+      GSL_ERROR_NULL ("invalid hstart", GSL_EINVAL);
a3f154
+    }
a3f154
+
a3f154
+  return GSL_SUCCESS;
a3f154
+}
a3f154
 
a3f154
 void
a3f154
 gsl_odeiv2_driver_free (gsl_odeiv2_driver * state)
a3f154
diff -up wrk/ode-initval2/evolve.c.wrk wrk/ode-initval2/evolve.c
a3f154
--- wrk/ode-initval2/evolve.c.wrk	2013-01-29 13:40:22.482035214 +0100
a3f154
+++ wrk/ode-initval2/evolve.c	2013-01-29 13:07:32.000000000 +0100
a3f154
@@ -138,16 +138,24 @@ gsl_odeiv2_evolve_apply (gsl_odeiv2_evol
a3f154
 
a3f154
   DBL_MEMCPY (e->y0, y, e->dimension);
a3f154
 
a3f154
-  /* Calculate initial dydt once if the method can benefit. */
a3f154
-
a3f154
+  /* Calculate initial dydt once or reuse previous value if the method
a3f154
+     can benefit. */
a3f154
+  
a3f154
   if (step->type->can_use_dydt_in)
a3f154
     {
a3f154
-      int status = GSL_ODEIV_FN_EVAL (dydt, t0, y, e->dydt_in);
a3f154
+      if (e->count == 0)
a3f154
+	{
a3f154
+	  int status = GSL_ODEIV_FN_EVAL (dydt, t0, y, e->dydt_in);
a3f154
 
a3f154
-      if (status)
a3f154
-        {
a3f154
-          return status;
a3f154
-        }
a3f154
+	  if (status)
a3f154
+	    {
a3f154
+	      return status;
a3f154
+	    }
a3f154
+	}
a3f154
+      else
a3f154
+	{
a3f154
+	  DBL_MEMCPY (e->dydt_in, e->dydt_out, e->dimension);
a3f154
+	}
a3f154
     }
a3f154
 
a3f154
 try_step:
a3f154
diff -up wrk/ode-initval2/gsl_odeiv2.h.wrk wrk/ode-initval2/gsl_odeiv2.h
a3f154
--- wrk/ode-initval2/gsl_odeiv2.h.wrk	2013-01-29 13:40:22.468035129 +0100
a3f154
+++ wrk/ode-initval2/gsl_odeiv2.h	2013-01-29 13:07:52.000000000 +0100
a3f154
@@ -326,6 +326,7 @@ int gsl_odeiv2_driver_apply_fixed_step (
a3f154
                                         const unsigned long int n,
a3f154
                                         double y[]);
a3f154
 int gsl_odeiv2_driver_reset (gsl_odeiv2_driver * d);
a3f154
+int gsl_odeiv2_driver_reset_hstart (gsl_odeiv2_driver * d, const double hstart);
a3f154
 void gsl_odeiv2_driver_free (gsl_odeiv2_driver * state);
a3f154
 
a3f154
 __END_DECLS
a3f154
diff -up wrk/ode-initval2/Makefile.am.wrk wrk/ode-initval2/Makefile.am
a3f154
diff -up wrk/ode-initval2/Makefile.in.wrk wrk/ode-initval2/Makefile.in
a3f154
diff -up wrk/ode-initval2/modnewton1.c.wrk wrk/ode-initval2/modnewton1.c
a3f154
diff -up wrk/ode-initval2/msadams.c.wrk wrk/ode-initval2/msadams.c
a3f154
diff -up wrk/ode-initval2/msbdf.c.wrk wrk/ode-initval2/msbdf.c
a3f154
--- wrk/ode-initval2/msbdf.c.wrk	2013-01-29 13:40:22.473035159 +0100
a3f154
+++ wrk/ode-initval2/msbdf.c	2013-01-28 10:42:35.000000000 +0100
a3f154
@@ -82,6 +82,7 @@ typedef struct
a3f154
   size_t *ordprevbackup;        /* backup of ordprev */
a3f154
   double *errlev;               /* desired error level of y */
a3f154
   gsl_vector *abscor;           /* absolute y values for correction */
a3f154
+  gsl_vector *abscorscaled;     /* scaled abscor for order evaluation */
a3f154
   gsl_vector *relcor;           /* relative y values for correction */
a3f154
   gsl_vector *svec;             /* saved abscor & work area */
a3f154
   gsl_vector *tempvec;          /* work area */
a3f154
@@ -91,7 +92,6 @@ typedef struct
a3f154
   gsl_matrix *M;                /* Newton iteration matrix */
a3f154
   gsl_permutation *p;           /* permutation for LU decomposition of M */
a3f154
   gsl_vector *rhs;              /* right hand side equations (-G) */
a3f154
-
a3f154
   long int ni;                  /* stepper call counter */
a3f154
   size_t ord;                   /* current order of method */
a3f154
   double tprev;                 /* t point of previous call */
a3f154
@@ -446,6 +446,33 @@ msbdf_alloc (size_t dim)
a3f154
       GSL_ERROR_NULL ("failed to allocate space for rhs", GSL_ENOMEM);
a3f154
     }
a3f154
 
a3f154
+  state->abscorscaled = gsl_vector_alloc (dim);
a3f154
+
a3f154
+  if (state->abscorscaled == 0)
a3f154
+    {
a3f154
+      gsl_vector_free (state->rhs); 
a3f154
+      gsl_permutation_free (state->p);
a3f154
+      gsl_matrix_free (state->M);
a3f154
+      free (state->dfdt);
a3f154
+      gsl_matrix_free (state->dfdy);
a3f154
+      gsl_vector_free (state->tempvec);
a3f154
+      gsl_vector_free (state->svec);
a3f154
+      gsl_vector_free (state->relcor);
a3f154
+      gsl_vector_free (state->abscor);
a3f154
+      free (state->errlev);
a3f154
+      free (state->ordprevbackup);
a3f154
+      free (state->ordprev);
a3f154
+      free (state->hprevbackup);
a3f154
+      free (state->hprev);
a3f154
+      free (state->l);
a3f154
+      free (state->ytmp2);
a3f154
+      free (state->ytmp);
a3f154
+      free (state->zbackup);
a3f154
+      free (state->z);
a3f154
+      free (state);
a3f154
+      GSL_ERROR_NULL ("failed to allocate space for abscorscaled", GSL_ENOMEM);
a3f154
+    }
a3f154
+
a3f154
   msbdf_reset ((void *) state, dim);
a3f154
 
a3f154
   state->driver = NULL;
a3f154
@@ -926,14 +953,14 @@ msbdf_corrector (void *vstate, const gsl
a3f154
 }
a3f154
 
a3f154
 static int
a3f154
-msbdf_eval_order (gsl_vector * abscor, gsl_vector * tempvec,
a3f154
+msbdf_eval_order (gsl_vector * abscorscaled, gsl_vector * tempvec,
a3f154
                   gsl_vector * svec, const double errcoeff,
a3f154
                   const size_t dim, const double errlev[],
a3f154
                   const double ordm1coeff, const double ordp1coeff,
a3f154
                   const double ordp1coeffprev, const double ordp2coeff,
a3f154
                   const double hprev[],
a3f154
                   const double h, const double z[],
a3f154
-                  size_t * ord, size_t * ordwait)
a3f154
+                  size_t * ord)
a3f154
 {
a3f154
   /* Evaluates and executes change in method order (current, current-1
a3f154
      or current+1). Order which maximizes the step length is selected.
a3f154
@@ -953,7 +980,7 @@ msbdf_eval_order (gsl_vector * abscor, g
a3f154
 
a3f154
   /* Relative step length estimate for current order */
a3f154
 
a3f154
-  ordest = 1.0 / (pow (bias * gsl_blas_dnrm2 (abscor) / sqrt (dim)
a3f154
+  ordest = 1.0 / (pow (bias * gsl_blas_dnrm2 (abscorscaled) / sqrt (dim)
a3f154
                        * errcoeff, 1.0 / (*ord + 1)) + safety);
a3f154
 
a3f154
   /* Relative step length estimate for order ord - 1 */
a3f154
@@ -983,7 +1010,7 @@ msbdf_eval_order (gsl_vector * abscor, g
a3f154
       for (i = 0; i < dim; i++)
a3f154
         {
a3f154
           gsl_vector_set (svec, i, gsl_vector_get (svec, i) * c +
a3f154
-                          gsl_vector_get (abscor, i));
a3f154
+                          gsl_vector_get (abscorscaled, i));
a3f154
         }
a3f154
 
a3f154
       ordp1est = 1.0 / (pow (bias2 * gsl_blas_dnrm2 (svec) / sqrt (dim)
a3f154
@@ -1020,8 +1047,6 @@ msbdf_eval_order (gsl_vector * abscor, g
a3f154
 #endif
a3f154
     }
a3f154
 
a3f154
-  *ordwait = *ord + 2;
a3f154
-
a3f154
   return GSL_SUCCESS;
a3f154
 }
a3f154
 
a3f154
@@ -1096,6 +1121,7 @@ msbdf_apply (void *vstate, size_t dim, d
a3f154
   size_t *const ordprevbackup = state->ordprevbackup;
a3f154
   double *const errlev = state->errlev;
a3f154
   gsl_vector *const abscor = state->abscor;
a3f154
+  gsl_vector *const abscorscaled = state->abscorscaled;
a3f154
   gsl_vector *const relcor = state->relcor;
a3f154
   gsl_vector *const svec = state->svec;
a3f154
   gsl_vector *const tempvec = state->tempvec;
a3f154
@@ -1591,13 +1617,16 @@ msbdf_apply (void *vstate, size_t dim, d
a3f154
       }
a3f154
   }
a3f154
 
a3f154
-  /* Scale abscor with errlev for later use in norm calculations */
a3f154
+  /* Scale abscor with errlev for later use in norm calculations
a3f154
+     in order evaluation in msbdf_eval_order
a3f154
+   */
a3f154
   {
a3f154
     size_t i;
a3f154
 
a3f154
     for (i = 0; i < dim; i++)
a3f154
       {
a3f154
-        gsl_vector_set (abscor, i, gsl_vector_get (abscor, i) / errlev[i]);
a3f154
+        gsl_vector_set (abscorscaled, i, 
a3f154
+                        gsl_vector_get (abscor, i) / errlev[i]);
a3f154
       }
a3f154
   }
a3f154
 
a3f154
@@ -1613,27 +1642,28 @@ msbdf_apply (void *vstate, size_t dim, d
a3f154
 
a3f154
       for (i = 0; i < dim; i++)
a3f154
         {
a3f154
-          gsl_vector_set (svec, i, gsl_vector_get (abscor, i));
a3f154
+          gsl_vector_set (svec, i, gsl_vector_get (abscorscaled, i));
a3f154
         }
a3f154
     }
a3f154
 
a3f154
-  /* Consider and execute order change for next step */
a3f154
+  /* Consider and execute order change for next step if order is unchanged. */
a3f154
 
a3f154
-  if (state->ordwait == 0)
a3f154
-    {
a3f154
-      msbdf_eval_order (abscor, tempvec, svec, errcoeff, dim, errlev,
a3f154
-                        ordm1coeff, ordp1coeff,
a3f154
-                        state->ordp1coeffprev, ordp2coeff,
a3f154
-                        hprev, h, z, &(state->ord), &(state->ordwait));
a3f154
-    }
a3f154
+  if (state->ordwait == 0) 
a3f154
+  { 
a3f154
+    if (ord - ordprev[0] == 0)
a3f154
+      {
a3f154
+        msbdf_eval_order (abscorscaled, tempvec, svec, errcoeff, dim, errlev,
a3f154
+                          ordm1coeff, ordp1coeff,
a3f154
+                          state->ordp1coeffprev, ordp2coeff,
a3f154
+                          hprev, h, z, &(state->ord));
a3f154
 
a3f154
-  /* Undo scaling of abscor for possible order increase on next step */
a3f154
-  {
a3f154
-    size_t i;
a3f154
-    
a3f154
-    for (i = 0; i < dim; i++)
a3f154
+        state->ordwait = state->ord + 2;
a3f154
+      }
a3f154
+    else
a3f154
       {
a3f154
-        gsl_vector_set (abscor, i, gsl_vector_get (abscor, i) * errlev[i]);
a3f154
+        /* Postpone order evaluation if order has been modified elsewhere */
a3f154
+    
a3f154
+        state->ordwait = 2;
a3f154
       }
a3f154
   }
a3f154
   
a3f154
@@ -1701,10 +1731,13 @@ msbdf_reset (void *vstate, size_t dim)
a3f154
   state->ordwaitbackup = 2;
a3f154
   state->failord = 0;
a3f154
   state->failt = GSL_NAN;
a3f154
+  state->tprev = GSL_NAN;  
a3f154
   state->gammaprev = 1.0;
a3f154
+  state->gammaprevbackup = 1.0;
a3f154
   state->nJ = 0;
a3f154
   state->nM = 0;
a3f154
   state->failcount = 0;
a3f154
+  state->ordp1coeffprev = 0.0;
a3f154
 
a3f154
   DBL_ZERO_MEMSET (state->hprev, MSBDF_MAX_ORD);
a3f154
   DBL_ZERO_MEMSET (state->hprevbackup, MSBDF_MAX_ORD);
a3f154
diff -up wrk/ode-initval2/odeiv_util.h.wrk wrk/ode-initval2/odeiv_util.h
a3f154
diff -up wrk/ode-initval2/rk1imp.c.wrk wrk/ode-initval2/rk1imp.c
a3f154
diff -up wrk/ode-initval2/rk2.c.wrk wrk/ode-initval2/rk2.c
a3f154
diff -up wrk/ode-initval2/rk2imp.c.wrk wrk/ode-initval2/rk2imp.c
a3f154
diff -up wrk/ode-initval2/rk4.c.wrk wrk/ode-initval2/rk4.c
a3f154
diff -up wrk/ode-initval2/rk4imp.c.wrk wrk/ode-initval2/rk4imp.c
a3f154
--- wrk/ode-initval2/rk4imp.c.wrk	2013-01-29 13:40:22.479035196 +0100
a3f154
+++ wrk/ode-initval2/rk4imp.c	2013-01-29 13:08:32.000000000 +0100
a3f154
@@ -249,7 +249,7 @@ rk4imp_apply (void *vstate, size_t dim,
a3f154
   gsl_matrix *A = state->A;
a3f154
 
a3f154
   const double b[] = { 0.5, 0.5 };
a3f154
-  const double c[] = { (3 - sqrt (3)) / 6, (3 + sqrt (3)) / 6 };
a3f154
+  const double c[] = { (3.0 - M_SQRT3) / 6.0, (3.0 + M_SQRT3) / 6.0 };
a3f154
 
a3f154
   gsl_matrix_set (A, 0, 0, 1.0 / 4);
a3f154
   gsl_matrix_set (A, 0, 1, (3 - 2 * sqrt (3)) / 12);
a3f154
diff -up wrk/ode-initval2/rk8pd.c.wrk wrk/ode-initval2/rk8pd.c
a3f154
diff -up wrk/ode-initval2/rkck.c.wrk wrk/ode-initval2/rkck.c
a3f154
diff -up wrk/ode-initval2/rkf45.c.wrk wrk/ode-initval2/rkf45.c
a3f154
--- wrk/ode-initval2/rkf45.c.wrk	2013-01-29 13:40:22.464035105 +0100
a3f154
+++ wrk/ode-initval2/rkf45.c	2013-01-29 13:08:45.000000000 +0100
a3f154
@@ -369,7 +369,7 @@ rkf45_free (void *vstate)
a3f154
 
a3f154
 static const gsl_odeiv2_step_type rkf45_type = { "rkf45",       /* name */
a3f154
   1,                            /* can use dydt_in */
a3f154
-  0,                            /* gives exact dydt_out */
a3f154
+  1,                            /* gives exact dydt_out */
a3f154
   &rkf45_alloc,
a3f154
   &rkf45_apply,
a3f154
   &stepper_set_driver_null,
a3f154
diff -up wrk/ode-initval2/rksubs.c.wrk wrk/ode-initval2/rksubs.c
a3f154
diff -up wrk/ode-initval2/step.c.wrk wrk/ode-initval2/step.c
a3f154
diff -up wrk/ode-initval2/step_utils.c.wrk wrk/ode-initval2/step_utils.c
a3f154
diff -up wrk/ode-initval2/test.c.wrk wrk/ode-initval2/test.c
a3f154
--- wrk/ode-initval2/test.c.wrk	2013-01-29 13:40:22.487035244 +0100
a3f154
+++ wrk/ode-initval2/test.c	2013-01-28 10:42:50.000000000 +0100
a3f154
@@ -163,7 +163,7 @@ rhs_xsin (double t, const double y[], do
a3f154
   static int n = 0, m = 0;
a3f154
   extern int nfe;
a3f154
   nfe += 1;
a3f154
-  
a3f154
+
a3f154
   if (rhs_xsin_reset)
a3f154
     {
a3f154
       rhs_xsin_reset = 0;
a3f154
@@ -1073,6 +1073,7 @@ test_odeiv_stepper (const gsl_odeiv2_ste
a3f154
 
a3f154
   {
a3f154
     int s = gsl_odeiv2_step_apply (d->s, t, h, y, yerr, 0, 0, sys);
a3f154
+
a3f154
     if (s != GSL_SUCCESS)
a3f154
       {
a3f154
         gsl_test (s, "test_odeiv_stepper: %s step_apply returned %d", desc,
a3f154
@@ -1191,13 +1192,13 @@ test_evolve_system (const gsl_odeiv2_ste
a3f154
       if (s != GSL_SUCCESS)
a3f154
         {
a3f154
           /* check that t and y are unchanged */
a3f154
-          gsl_test_abs (t, t_orig, 0.0, "%s, t must be restored on failure",
a3f154
+          gsl_test_abs (t, t_orig, 0.0, "%s t must be restored on failure",
a3f154
                         gsl_odeiv2_step_name (d->s));
a3f154
 
a3f154
           for (i = 0; i < sys->dimension; i++)
a3f154
             {
a3f154
               gsl_test_abs (y[i], y_orig[i], 0.0,
a3f154
-                            "%s, y must be restored on failure",
a3f154
+                            "%s y must be restored on failure",
a3f154
                             gsl_odeiv2_step_name (d->s), desc, i);
a3f154
             }
a3f154
 
a3f154
@@ -1259,11 +1260,11 @@ sys_driver (const gsl_odeiv2_step_type *
a3f154
   gsl_odeiv2_driver *d =
a3f154
     gsl_odeiv2_driver_alloc_standard_new (sys, T, h, epsabs, epsrel,
a3f154
                                           1.0, 0.0);
a3f154
-  
a3f154
+
a3f154
   extern int nfe, nje;
a3f154
   nfe = 0;
a3f154
   nje = 0;
a3f154
-  
a3f154
+
a3f154
   while (t < t1)
a3f154
     {
a3f154
       s = gsl_odeiv2_evolve_apply (d->e, d->c, d->s, sys, &t, t1, &h, y);
a3f154
@@ -1570,7 +1571,8 @@ test_user_break (const gsl_odeiv2_step_t
a3f154
 
a3f154
   int s = gsl_odeiv2_driver_apply (d, &t, t1, y);
a3f154
 
a3f154
-  gsl_test ((s - GSL_EBADFUNC), "test_user_break returned %d", s);
a3f154
+  gsl_test ((s - GSL_EBADFUNC), "%s test_user_break returned %d",
a3f154
+            gsl_odeiv2_step_name (d->s), s);
a3f154
 
a3f154
   gsl_odeiv2_driver_free (d);
a3f154
 }
a3f154
@@ -1938,17 +1940,15 @@ test_extreme_problems (void)
a3f154
   const size_t sd[] = { 4, 3, NRINGMOD };
a3f154
 
a3f154
   /* Integration interval for problems */
a3f154
+  
a3f154
   const double start[CONST_EXTREME_NPROB] = { 0.0 };
a3f154
-  const double end[CONST_EXTREME_NPROB] = { 1e11, 1e11, 1e-3 };
a3f154
+  const double end[CONST_EXTREME_NPROB] = { 1e11, 1e11, 1e-5 };
a3f154
 
a3f154
   const double epsabs[CONST_EXTREME_NPROB] =
a3f154
-    { 1e1 * GSL_DBL_MIN, 1e1 * GSL_DBL_MIN, 1e-7 };
a3f154
-  const double epsrel[CONST_EXTREME_NPROB] = { 1e-12, 1e-12, 1e-7 };
a3f154
+    { 1e1 * GSL_DBL_MIN, 1e1 * GSL_DBL_MIN, 1e-12 };
a3f154
+  const double epsrel[CONST_EXTREME_NPROB] = { 1e-12, 1e-12, 1e-12 };
a3f154
   const double initstepsize[CONST_EXTREME_NPROB] = { 1e-5, 1e-5, 1e-10 };
a3f154
 
a3f154
-  /* Problem specific tolerance modification coefficients */
a3f154
-  const double pec[CONST_EXTREME_NPROB] = { 1.0, 1.0, 1e1 };
a3f154
-
a3f154
   /* Steppers */
a3f154
 
a3f154
   steppers[0] = gsl_odeiv2_step_bsimp;
a3f154
@@ -2024,7 +2024,7 @@ test_extreme_problems (void)
a3f154
             const double val1 = y[k];
a3f154
             const double val2 = y[sd[p] * i + k];
a3f154
             gsl_test_rel (val1, val2,
a3f154
-                          (pec[p] * GSL_MAX (err_target[0], err_target[i])),
a3f154
+                          (GSL_MAX (err_target[0], err_target[i])),
a3f154
                           "%s/%s %s [%d]",
a3f154
                           steppers[0]->name, steppers[i]->name,
a3f154
                           probname[p], k);
a3f154
@@ -2033,57 +2033,81 @@ test_extreme_problems (void)
a3f154
 }
a3f154
 
a3f154
 void
a3f154
-test_driver (void)
a3f154
+test_driver (const gsl_odeiv2_step_type * T)
a3f154
 {
a3f154
   /* Tests for gsl_odeiv2_driver object */
a3f154
+
a3f154
   int s;
a3f154
   const double tol = 1e-8;
a3f154
   const double hmax = 1e-2;
a3f154
 
a3f154
   double y[] = { 1.0, 0.0 };
a3f154
   double t = 0.0;
a3f154
+  const double tinit = 0.0;
a3f154
   const double t1 = 8.25;
a3f154
   const double t2 = 100;
a3f154
   const double t3 = -2.5;
a3f154
   const size_t minsteps = ceil (t1 / hmax);
a3f154
   const size_t maxsteps = 20;
a3f154
   const double hmin = 1e-10;
a3f154
-  const size_t nfsteps = 100;
a3f154
-  
a3f154
-  gsl_odeiv2_driver *d =
a3f154
-    gsl_odeiv2_driver_alloc_y_new (&rhs_func_sin, gsl_odeiv2_step_rkf45,
a3f154
-                                   1e-3, tol, tol);
a3f154
+
a3f154
+  const unsigned long int nfsteps = 100000;
a3f154
+  const double hfixed = 0.000025;
a3f154
+
a3f154
+  gsl_odeiv2_driver *d = gsl_odeiv2_driver_alloc_y_new (&rhs_func_sin, T,
a3f154
+                                                        1e-3, tol, tol);
a3f154
   gsl_odeiv2_driver_set_hmax (d, hmax);
a3f154
 
a3f154
   s = gsl_odeiv2_driver_apply (d, &t, t1, y);
a3f154
 
a3f154
   if (s != GSL_SUCCESS)
a3f154
     {
a3f154
-      gsl_test (s, "test_driver apply returned %d", s);
a3f154
+      gsl_test (s, "%s test_driver apply returned %d",
a3f154
+                gsl_odeiv2_step_name (d->s), s);
a3f154
     }
a3f154
 
a3f154
   /* Test that result is correct */
a3f154
 
a3f154
-  gsl_test_rel (y[0], cos (t1), d->n * tol, "test_driver y0 ");
a3f154
-  gsl_test_rel (y[1], sin (t1), d->n * tol, "test_driver y1 ");
a3f154
+  gsl_test_rel (y[0], cos (t1), d->n * tol, "%s test_driver y0",
a3f154
+                gsl_odeiv2_step_name (d->s));
a3f154
+  gsl_test_rel (y[1], sin (t1), d->n * tol, "%s test_driver y1",
a3f154
+                gsl_odeiv2_step_name (d->s));
a3f154
 
a3f154
   /* Test that maximum step length is obeyed */
a3f154
 
a3f154
   if (d->n < minsteps)
a3f154
     {
a3f154
-      gsl_test (1, "test_driver steps %d < minsteps %d \n", d->n, minsteps);
a3f154
+      gsl_test (1, "%s test_driver steps %d < minsteps %d \n",
a3f154
+                gsl_odeiv2_step_name (d->s), d->n, minsteps);
a3f154
     }
a3f154
   else
a3f154
     {
a3f154
-      gsl_test (0, "test_driver max step length test");
a3f154
+      gsl_test (0, "%s test_driver max step length test",
a3f154
+                gsl_odeiv2_step_name (d->s));
a3f154
     }
a3f154
 
a3f154
+  /* Test changing integration direction from forward to backward */
a3f154
+
a3f154
+  gsl_odeiv2_driver_reset_hstart (d, -1e-3);
a3f154
+
a3f154
+  s = gsl_odeiv2_driver_apply (d, &t, tinit, y);
a3f154
+
a3f154
+  if (s != GSL_SUCCESS)
a3f154
+    {
a3f154
+      gsl_test (s, "%s test_driver apply returned %d",
a3f154
+                gsl_odeiv2_step_name (d->s), s);
a3f154
+    }
a3f154
+
a3f154
+  gsl_test_rel (y[0], cos (tinit), d->n * tol,
a3f154
+                "%s test_driver y0", gsl_odeiv2_step_name (d->s));
a3f154
+  gsl_test_rel (y[1], sin (tinit), d->n * tol,
a3f154
+                "%s test_driver y1", gsl_odeiv2_step_name (d->s));
a3f154
+
a3f154
   gsl_odeiv2_driver_free (d);
a3f154
 
a3f154
   /* Test that maximum number of steps is obeyed */
a3f154
 
a3f154
-  d = gsl_odeiv2_driver_alloc_y_new (&rhs_func_sin, gsl_odeiv2_step_rkf45,
a3f154
-                                     1e-3, tol, tol);
a3f154
+  d = gsl_odeiv2_driver_alloc_y_new (&rhs_func_sin, T, 1e-3, tol, tol);
a3f154
   gsl_odeiv2_driver_set_hmax (d, hmax);
a3f154
   gsl_odeiv2_driver_set_nmax (d, maxsteps);
a3f154
 
a3f154
@@ -2091,19 +2115,20 @@ test_driver (void)
a3f154
 
a3f154
   if (d->n != maxsteps + 1)
a3f154
     {
a3f154
-      gsl_test (1, "test_driver steps %d, expected %d", d->n, maxsteps + 1);
a3f154
+      gsl_test (1, "%s test_driver steps %d, expected %d",
a3f154
+                gsl_odeiv2_step_name (d->s), d->n, maxsteps + 1);
a3f154
     }
a3f154
   else
a3f154
     {
a3f154
-      gsl_test (0, "test_driver max steps test");
a3f154
+      gsl_test (0, "%s test_driver max steps test",
a3f154
+                gsl_odeiv2_step_name (d->s));
a3f154
     }
a3f154
 
a3f154
   gsl_odeiv2_driver_free (d);
a3f154
 
a3f154
   /* Test that minimum step length is obeyed */
a3f154
 
a3f154
-  d = gsl_odeiv2_driver_alloc_y_new (&rhs_func_broken, gsl_odeiv2_step_rk8pd,
a3f154
-                                     1e-3, tol, tol);
a3f154
+  d = gsl_odeiv2_driver_alloc_y_new (&rhs_func_broken, T, 1e-3, tol, tol);
a3f154
 
a3f154
   gsl_odeiv2_driver_set_hmin (d, hmin);
a3f154
   y[0] = 0.0;
a3f154
@@ -2113,77 +2138,87 @@ test_driver (void)
a3f154
 
a3f154
   if (s != GSL_ENOPROG)
a3f154
     {
a3f154
-      gsl_test (1, "test_driver min step test returned %d", s);
a3f154
+      gsl_test (1, "%s test_driver min step test returned %d",
a3f154
+                gsl_odeiv2_step_name (d->s), s);
a3f154
     }
a3f154
   else
a3f154
     {
a3f154
-      gsl_test (0, "test_driver min step test");
a3f154
+      gsl_test (0, "%s test_driver min step test",
a3f154
+                gsl_odeiv2_step_name (d->s));
a3f154
     }
a3f154
 
a3f154
   gsl_odeiv2_driver_free (d);
a3f154
 
a3f154
   /* Test negative integration direction */
a3f154
 
a3f154
-  d = gsl_odeiv2_driver_alloc_y_new (&rhs_func_sin, gsl_odeiv2_step_rkf45,
a3f154
-                                     -1e-3, tol, tol);
a3f154
+  d = gsl_odeiv2_driver_alloc_y_new (&rhs_func_sin, T, -1e-3, tol, tol);
a3f154
 
a3f154
   y[0] = 1.0;
a3f154
   y[1] = 0.0;
a3f154
   t = 2.5;
a3f154
 
a3f154
-  gsl_odeiv2_driver_set_nmax (d, 1000);
a3f154
   s = gsl_odeiv2_driver_apply (d, &t, t3, y);
a3f154
 
a3f154
   {
a3f154
-    const double tol = 1e-6;
a3f154
+    const double tol = 1e-3;
a3f154
     const double test = fabs (t - t3);
a3f154
     const double val = fabs (sin (-5.0) - y[1]);
a3f154
 
a3f154
     if (test > GSL_DBL_EPSILON)
a3f154
       {
a3f154
         gsl_test (1,
a3f154
-                  "test_driver negative dir diff %e, expected less than %e",
a3f154
-                  test, GSL_DBL_EPSILON);
a3f154
+                  "%s test_driver negative dir diff %e, expected less than %e",
a3f154
+                  gsl_odeiv2_step_name (d->s), test, GSL_DBL_EPSILON);
a3f154
       }
a3f154
     else if (val > tol)
a3f154
       {
a3f154
-        gsl_test (1, "test_driver negative dir val %e, expected less than %e",
a3f154
-                  val, tol);
a3f154
+        gsl_test (1,
a3f154
+                  "%s test_driver negative dir val %e, expected less than %e",
a3f154
+                  gsl_odeiv2_step_name (d->s), val, tol);
a3f154
       }
a3f154
     else
a3f154
       {
a3f154
-        gsl_test (s, "test_driver negative direction test");
a3f154
+        gsl_test (s, "%s test_driver negative direction test",
a3f154
+                  gsl_odeiv2_step_name (d->s));
a3f154
       }
a3f154
   }
a3f154
 
a3f154
   /* Test driver_apply_fixed_step */
a3f154
 
a3f154
-  s = gsl_odeiv2_driver_apply_fixed_step (d, &t, 0.025, nfsteps, y);
a3f154
+  gsl_odeiv2_driver_reset_hstart (d, 1e-3);
a3f154
+  s = gsl_odeiv2_driver_apply_fixed_step (d, &t, hfixed, nfsteps, y);
a3f154
+
a3f154
+  if (s != GSL_SUCCESS)
a3f154
+    {
a3f154
+      gsl_test (s, "%s test_driver apply_fixed_step returned %d",
a3f154
+                gsl_odeiv2_step_name (d->s), s);
a3f154
+    }
a3f154
 
a3f154
   {
a3f154
-    const double tol = 1e-6;
a3f154
+    const double tol = 1e-3;
a3f154
     const double val = fabs (sin (-2.5) - y[1]);
a3f154
 
a3f154
     if (fabs (t) > nfsteps * GSL_DBL_EPSILON)
a3f154
       {
a3f154
         gsl_test (1,
a3f154
-                  "test_driver apply_fixed_step diff %e, expected less than %e",
a3f154
-                  fabs (t), nfsteps * GSL_DBL_EPSILON);
a3f154
+                  "%s test_driver apply_fixed_step t %e, expected less than %e",
a3f154
+                  gsl_odeiv2_step_name (d->s), fabs (t),
a3f154
+                  nfsteps * GSL_DBL_EPSILON);
a3f154
       }
a3f154
     else if (val > tol)
a3f154
       {
a3f154
         gsl_test (1,
a3f154
-                  "test_driver apply_fixed_step val %e, expected less than %e",
a3f154
-                  val, tol);
a3f154
+                  "%s test_driver apply_fixed_step val %e, expected less than %e",
a3f154
+                  gsl_odeiv2_step_name (d->s), val, tol);
a3f154
       }
a3f154
     else
a3f154
       {
a3f154
-        gsl_test (s, "test_driver apply_fixed_step test");
a3f154
+        gsl_test (s, "%s test_driver apply_fixed_step test",
a3f154
+                  gsl_odeiv2_step_name (d->s));
a3f154
       }
a3f154
   }
a3f154
 
a3f154
   gsl_odeiv2_driver_free (d);
a3f154
-
a3f154
 }
a3f154
 
a3f154
 void
a3f154
@@ -2407,7 +2442,7 @@ main (void)
a3f154
 {
a3f154
 
a3f154
   /* Benchmark routine to compare stepper performance */
a3f154
-  /* benchmark_precision(); return 0;*/
a3f154
+  /* benchmark_precision(); return 0; */
a3f154
 
a3f154
   /* Test single problem, for debugging purposes */
a3f154
   /* test_evolve_temp (gsl_odeiv2_step_msadams, 1e-3, 1e-8); return 0; */
a3f154
@@ -2453,10 +2488,6 @@ main (void)
a3f154
   for (i = 0; p[i].type != 0; i++)
a3f154
     {
a3f154
       test_stepper (p[i].type);
a3f154
-    }
a3f154
-
a3f154
-  for (i = 0; p[i].type != 0; i++)
a3f154
-    {
a3f154
       test_evolve_linear (p[i].type, p[i].h, 1e-10);
a3f154
       test_evolve_exp (p[i].type, p[i].h, 1e-5);
a3f154
       test_evolve_sin (p[i].type, p[i].h, 1e-8);
a3f154
@@ -2468,6 +2499,7 @@ main (void)
a3f154
       test_broken (p[i].type, p[i].h, 1e-8);
a3f154
       test_stepsize_fail (p[i].type, p[i].h);
a3f154
       test_user_break (p[i].type, p[i].h);
a3f154
+      test_driver (p[i].type);
a3f154
     }
a3f154
 
a3f154
   /* Derivative test for explicit steppers */
a3f154
@@ -2493,14 +2525,12 @@ main (void)
a3f154
     }
a3f154
 
a3f154
   /* Special tests */
a3f154
-  
a3f154
+
a3f154
   test_nonstiff_problems ();
a3f154
 
a3f154
   test_stiff_problems ();
a3f154
 
a3f154
   test_extreme_problems ();
a3f154
 
a3f154
-  test_driver ();
a3f154
-  
a3f154
   exit (gsl_test_summary ());
a3f154
 }
a3f154
diff -up wrk/ode-initval2/TODO.wrk wrk/ode-initval2/TODO