2 ;;; Copyright (c) 2005--2007, by A.J. Rossini <blindglobe@gmail.com>
3 ;;; See COPYRIGHT file for any additional restrictions (BSD license).
4 ;;; Since 1991, ANSI was finally finished. Edited for ANSI Common Lisp.
6 ;;;; lsmacros -- Various macros
8 ;;;; Copyright (c) 1991, by Luke Tierney. Permission is granted for
12 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14 ;;; Macros for LISP-STAT-BASICS Package
16 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22 (in-package :lisp-stat-basics
)
25 ;;;; Floating Point Macros
28 (defmacro declare-double
(&rest vars
) `(declare (long-float ,@vars
)))
31 ;;;; Macros for Defining Vectorized Funcitons
34 (defmacro make-vectorized-function
(sym fcn
)
35 `(defun ,sym
(&rest args
)
36 (apply #'map-elements
#',fcn args
)))
38 (defmacro fixup-vectorized-doc-list
(sym)
39 `(let ((doc (documentation ',sym
'function
)))
40 (if doc
(list (format nil
"~s~%Vectorized." ,sym
))))) ;; AJR: newvers
41 ;; (if doc (list (format nil "~s~%Vectorized."))))) ;;
45 ;;; recursively vectorizes (rv) functions in dists and lispstat-math.
47 (defmacro make-rv-function
(sym fcn
&rest args
)
49 ((and args
(= (length args
) 1))
51 ,@(fixup-vectorized-doc-list fcn
)
52 (declare (inline cmpndp
,fcn
,sym recursive-map-elements list
))
54 (recursive-map-elements #',fcn
#',sym
,@args
)
58 ,@(fixup-vectorized-doc-list fcn
)
59 (declare (inline cmpndp
,fcn
,sym recursive-map-elements list
))
60 (if ,(cons 'or
(mapcar #'(lambda (x) (list 'cmpndp x
)) args
))
61 (recursive-map-elements #',fcn
#',sym
,@args
)
64 `(defun ,sym
(&optional
(x nil has-x
) (y nil has-y
) &rest args
)
65 ,@(fixup-vectorized-doc-list fcn
)
66 (declare (inline cmpndp
,fcn
,sym recursive-map-elements list
))
69 (if (or args
(cmpndp x
) (cmpndp y
))
70 (apply #'recursive-map-elements
#',fcn
#',sym x y args
)
73 (recursive-map-elements #',fcn
#',sym x
)
77 (defmacro make-rv-function-1
(sym fcn
&rest args
)
79 ((and args
(= (length args
) 1))
81 ,@(fixup-vectorized-doc-list fcn
)
82 (declare (inline cmpndp
,fcn
,sym recursive-map-elements list
))
84 (recursive-map-elements #',fcn
#',sym
,@args
)
88 ,@(fixup-vectorized-doc-list fcn
)
89 (declare (inline cmpndp
,fcn
,sym recursive-map-elements list
))
90 (if ,(cons 'or
(mapcar #'(lambda (x) (list 'cmpndp x
)) args
))
91 (recursive-map-elements #',fcn
#',sym
,@args
)
94 `(defun ,sym
(x &optional
(y nil has-y
) &rest args
)
95 ,@(fixup-vectorized-doc-list fcn
)
96 (declare (inline cmpndp
,fcn
,sym recursive-map-elements list
))
98 (if (or args
(cmpndp x
) (cmpndp y
))
99 (apply #'recursive-map-elements
#',fcn
#',sym x y args
)
102 (recursive-map-elements #',fcn
#',sym x
)