From eb3bf5e5259c9bbf32627f46c69a0b05683efe56 Mon Sep 17 00:00:00 2001
From: liam <liam@a3d8a0fb-c1db-0310-ace7-a616afeb9e30>
Date: Sat, 16 Feb 2008 16:21:14 +0000
Subject: [PATCH] Fix error in test of numerical-integration.  For tests with
 outcome near zero, just make it zero.

git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@3293 a3d8a0fb-c1db-0310-ace7-a616afeb9e30
---
 init/tests.lisp            | 8 +++++++-
 numerical-integration.lisp | 4 ++--
 polynomial.lisp            | 6 +++---
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/init/tests.lisp b/init/tests.lisp
index b3051316..f373cf91 100644
--- a/init/tests.lisp
+++ b/init/tests.lisp
@@ -17,12 +17,18 @@
   "The number of decimal digits on which floating point
    number must agree.")
 
+(defparameter *zero-threshold* 1.0d-15
+  "Threshold below which a number is tpo be considered zero.")
+
 (defun fp-string (fp &optional (decimal-digits *test-fp-decimal-digits*))
   "Format the floating point number as a string for comparison."
   (if (typep fp 'complex)
       (list (fp-string (realpart fp)) (fp-string (imagpart fp)))
       (format nil "~,v,2,0,,,ve"
-	      decimal-digits (if (typep fp 'double-float) #\d #\e) fp)))
+	      decimal-digits (if (typep fp 'double-float) #\d #\e)
+	      (if (< (abs fp)  *zero-threshold*)
+		  0.0d0
+		  fp))))
 
 (defmacro assert-first-fp-equal (expected form &rest extras)
   (lisp-unit::expand-assert
diff --git a/numerical-integration.lisp b/numerical-integration.lisp
index e5d65518..60f66a0d 100644
--- a/numerical-integration.lisp
+++ b/numerical-integration.lisp
@@ -1,6 +1,6 @@
 ;; Numerical integration
 ;; Liam Healy, Wed Jul  5 2006 - 23:14
-;; Time-stamp: <2008-02-03 13:22:48EST numerical-integration.lisp>
+;; Time-stamp: <2008-02-16 11:07:23EST numerical-integration.lisp>
 ;; $Id: $
 
 ;;; To do: QAWS, QAWO, QAWF, more tests
@@ -232,5 +232,5 @@
      (integration-QAG one-sine 0.0d0 pi :gauss15 20 ws)))
   (lisp-unit:assert-error
    'gsl-error
-   (letm ((ws (integration-workspace ws 20)))
+   (letm ((ws (integration-workspace 20)))
      (integration-QAG one-sine 0.0d0 pi :gauss15 50 ws))))
diff --git a/polynomial.lisp b/polynomial.lisp
index 3274e597..8b633f5f 100644
--- a/polynomial.lisp
+++ b/polynomial.lisp
@@ -1,6 +1,6 @@
 ;; Polynomials
 ;; Liam Healy, Tue Mar 21 2006 - 18:33
-;; Time-stamp: <2008-02-05 22:35:20EST polynomial.lisp>
+;; Time-stamp: <2008-02-16 11:17:51EST polynomial.lisp>
 ;; $Id: $
 
 (in-package :gsl)
@@ -194,8 +194,8 @@
    (lisp-unit:fp-values (solve-cubic -6.0d0 -13.0d0 42.0d0)))
   ;; This should use double-float-unequal
   (lisp-unit:assert-equal
-   '(("-0.902598308594d-17" "-1.000000000000d+00")
-     ("-0.902598308594d-17" "1.000000000000d+00")
+   '(("0.000000000000d+01" "-1.000000000000d+00")
+     ("0.000000000000d+01" "1.000000000000d+00")
      ("0.100000000000d+01" "0.000000000000d+01"))
    (lisp-unit:fp-values (solve-cubic-complex -1.0d0 1.0d0 -1.0d0)))
   (lisp-unit:assert-equal
-- 
GitLab