This is the mail archive of the gsl-discuss@sourceware.org mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cvs version: make check FAIL


On Wednesday 24 May 2006 01:42 am, picca@synchrotron-soleil.fr wrote:
> Hello
>
> Instead of computing 2 times fabs(fn), why not storing it in a
> variable ?
>
>        result->val = fn;
> -      result->err = GSL_DBL_EPSILON*fabs(fn);
> +      result->err = 2.0*GSL_DBL_EPSILON;
> +      double factor = fabs(fn);
> +      if (factor > 1.0)
> +          result->err *= factor;
>
> Have a nice day.

Sure, that sounds fine to me.  The cost of the extra fabs() is rather 
trivial, but avoiding it will save a few clock cycles.

I've attached a patch to be used in place of the earlier patch.

Thanks.

    Lowell
-- 
Lowell D. Johnson
Linux:  Bringing stability, security, and freedom to home and business
        computing since 1991.  www.linux.org
Free and Open Source Software:  Of the people, by the people, for the 
people.
Index: mathieu_angfunc.c
===================================================================
RCS file: /cvs/gsl/gsl/specfunc/mathieu_angfunc.c,v
retrieving revision 1.1
diff -u -r1.1 mathieu_angfunc.c
--- mathieu_angfunc.c	18 Apr 2006 17:59:46 -0000	1.1
+++ mathieu_angfunc.c	24 May 2006 22:17:49 -0000
@@ -31,7 +31,7 @@
 int gsl_sf_mathieu_c(int order, double qq, double zz, gsl_sf_result *result)
 {
   int even_odd, ii, status;
-  double coeff[NUM_MATHIEU_COEFF], aa, norm, fn;
+  double coeff[NUM_MATHIEU_COEFF], aa, norm, fn, factor;
 
 
   norm = 0.0;
@@ -54,7 +54,10 @@
       fn = cos(order*zz)/norm;
       
       result->val = fn;
-      result->err = GSL_DBL_EPSILON*fabs(fn);
+      result->err = 2.0*GSL_DBL_EPSILON;
+      factor = fabs(fn);
+      if (factor > 1.0)
+          result->err *= factor;
       
       return GSL_SUCCESS;
   }
@@ -97,7 +100,10 @@
   fn /= norm;
 
   result->val = fn;
-  result->err = GSL_DBL_EPSILON*fabs(fn);
+  result->err = 2.0*GSL_DBL_EPSILON;
+  factor = fabs(fn);
+  if (factor > 1.0)
+      result->err *= factor;
   
   return GSL_SUCCESS;
 }
@@ -106,7 +112,7 @@
 int gsl_sf_mathieu_s(int order, double qq, double zz,gsl_sf_result *result)
 {
   int even_odd, ii, status;
-  double coeff[NUM_MATHIEU_COEFF], aa, norm, fn;
+  double coeff[NUM_MATHIEU_COEFF], aa, norm, fn, factor;
 
 
   norm = 0.0;
@@ -126,7 +132,10 @@
       fn = sin(order*zz);
       
       result->val = fn;
-      result->err = GSL_DBL_EPSILON*fabs(fn);
+      result->err = 2.0*GSL_DBL_EPSILON;
+      factor = fabs(fn);
+      if (factor > 1.0)
+          result->err *= factor;
       
       return GSL_SUCCESS;
   }
@@ -167,7 +176,10 @@
   fn /= norm;
 
   result->val = fn;
-  result->err = GSL_DBL_EPSILON*fabs(fn);
+  result->err = 2.0*GSL_DBL_EPSILON;
+  factor = fabs(fn);
+  if (factor > 1.0)
+      result->err *= factor;
   
   return GSL_SUCCESS;
 }
Index: mathieu_radfunc.c
===================================================================
RCS file: /cvs/gsl/gsl/specfunc/mathieu_radfunc.c,v
retrieving revision 1.1
diff -u -r1.1 mathieu_radfunc.c
--- mathieu_radfunc.c	18 Apr 2006 17:59:46 -0000	1.1
+++ mathieu_radfunc.c	24 May 2006 22:17:49 -0000
@@ -34,7 +34,7 @@
                         gsl_sf_result *result)
 {
   int even_odd, kk, mm, status;
-  double maxerr = 1e-14, amax, pi = acos(-1.0), fn;
+  double maxerr = 1e-14, amax, pi = acos(-1.0), fn, factor;
   double coeff[NUM_MATHIEU_COEFF], aa, fc, fj, fjp;
   double j1c, j2c, j1pc, j2pc;
   double u1, u2;
@@ -141,7 +141,10 @@
   }
 
   result->val = fn;
-  result->err = GSL_DBL_EPSILON*fabs(fn);
+  result->err = 2.0*GSL_DBL_EPSILON;
+  factor = fabs(fn);
+  if (factor > 1.0)
+      result->err *= factor;
   
   return GSL_SUCCESS;
 }
@@ -151,7 +154,7 @@
                         gsl_sf_result *result)
 {
   int even_odd, kk, mm, status;
-  double maxerr = 1e-14, amax, pi = acos(-1.0), fn;
+  double maxerr = 1e-14, amax, pi = acos(-1.0), fn, factor;
   double coeff[NUM_MATHIEU_COEFF], aa, fc, fj, fjp, fjm;
   double j1c, j2c, j1mc, j2mc, j1pc, j2pc;
   double u1, u2;
@@ -268,7 +271,10 @@
   }
 
   result->val = fn;
-  result->err = GSL_DBL_EPSILON*fabs(fn);
+  result->err = 2.0*GSL_DBL_EPSILON;
+  factor = fabs(fn);
+  if (factor > 1.0)
+      result->err *= factor;
   
   return GSL_SUCCESS;
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]