Subject: Functions to test for numerically evaluation
From: Dieter Kaiser
Date: Wed, 8 Oct 2008 22:22:21 +0200
Because the tests for numerically evaluation of functions with more than one
argument gets more and more complicated I have written four different routines
which accept an arbitrary number of arguments.
Furthermore I have detected some inconsistencies for the functions I have
implemented which are due to different algoritm I have used.
Perhaps these four functions could help to avoid inconsistencies and furthermore
help to get more readable code.
So what do you think? Should we use these functions consequently? Is there
something which could be done much better?
Here is the code of the test functions (the main idea is taken from the function
bessel-numerical-eval-p in bessel.lisp):
**********
;;; Test for numerically evaluation in float precision
(defun float-numerical-eval-p (&rest args)
(let ((flag nil))
(dolist (ll args)
(when (not (float-or-rational-p ll))
(return-from float-numerical-eval-p nil))
(when (floatp ll) (setq flag t)))
(if (or $numer flag) t nil)))
;;; Test for numerically evaluation in complex float precision
(defun complex-float-numerical-eval-p (&rest args)
(let ((flag nil))
(dolist (ll args)
(when (not (complex-number-p ll 'float-or-rational-p))
(return-from complex-float-numerical-eval-p nil))
(when (or (floatp ($realpart ll)) (floatp ($imagpart ll)))
(setq flag t)))
(if (or $numer flag) t nil)))
;;; Test for numerically evaluation in bigfloat precision
(defun bigfloat-numerical-eval-p (&rest args)
(let ((flag nil))
(dolist (ll args)
(when (not (bigfloat-or-number-p ll))
(return-from bigfloat-numerical-eval-p nil))
(when ($bfloatp ll) (setq flag t)))
(if (or $numer flag) t nil)))
;;; Test for numerically evaluation in complex bigfloat precision
(defun complex-bigfloat-numerical-eval-p (&rest args)
(let ((flag nil))
(dolist (ll args)
(when (not (complex-number-p ll 'bigfloat-or-number-p))
(return-from complex-bigfloat-numerical-eval-p nil))
(when (or ($bfloatp ($realpart ll)) ($bfloatp ($imagpart ll)))
(setq flag t)))
(if (or $numer flag) t nil)))
**********
Dieter Kaiser