diff options
Diffstat (limited to 'cl')
-rw-r--r-- | cl/src/approx/maceps.lisp | 14 | ||||
-rw-r--r-- | cl/tests/maceps.lisp | 10 |
2 files changed, 12 insertions, 12 deletions
diff --git a/cl/src/approx/maceps.lisp b/cl/src/approx/maceps.lisp index cd24482..ad234e8 100644 --- a/cl/src/approx/maceps.lisp +++ b/cl/src/approx/maceps.lisp @@ -1,13 +1,11 @@ (in-package :lizfcm.approx) -(defun compute-maceps (val f) - (let* ((h val) - (a val) - (err val)) +(defun compute-maceps (f a init) + (let ((h init) + (err init)) (loop while (> err 0) do - (progn - (setf h (/ h 2) - err (abs (- (funcall f (+ a h)) - (funcall f a))))) + (setf h (/ h 2) + err (abs (- (funcall f (+ a h)) + (funcall f a)))) collect (list a h err)))) diff --git a/cl/tests/maceps.lisp b/cl/tests/maceps.lisp index 9d61772..cd5ced9 100644 --- a/cl/tests/maceps.lisp +++ b/cl/tests/maceps.lisp @@ -13,10 +13,12 @@ (test maceps :description "double precision provides precision about (mac eps of single precision) squared" - (let* ((maceps-computation-double (compute-maceps 1.0d0 - (lambda (x) x))) - (maceps-computation-single (compute-maceps 1.0 - (lambda (x) x))) + (let* ((maceps-computation-double (compute-maceps (lambda (x) x) + 1.0d0 + 1.0d0)) + (maceps-computation-single (compute-maceps (lambda (x) x) + 1.0 + 1.0)) (last-double-h (cadar (last maceps-computation-double))) (last-single-h (cadar (last maceps-computation-single)))) (is (within-range-p |