Skip to content

Commit

Permalink
* lapack-utils.lisp (walk-and-replace): replace by common-lisp
Browse files Browse the repository at this point in the history
	function SUBLIS
  • Loading branch information
evanmonroig committed May 11, 2008
1 parent a2e86a2 commit 0eb959a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
2008-05-11 Evan Monroig <evan.monroig@gmail.com>

* lapack-utils.lisp (walk-and-replace): replace by common-lisp
function SUBLIS

2008-05-07 Evan Monroig <evan.monroig@gmail.com>

* benchmark/lisp-vs-c-aref.lisp: same as the one on the page of
Expand Down
19 changes: 3 additions & 16 deletions lapack-utils.lisp
Expand Up @@ -3,7 +3,7 @@
;;; This file contains functions and macros to help build LAPACK
;;; wrapper methods.
;;;
;;; Time-stamp: <2008-05-04 16:39:48 Evan Monroig>
;;; Time-stamp: <2008-05-11 09:13:22 Evan Monroig>
;;;
;;;
;;;
Expand Down Expand Up @@ -134,19 +134,6 @@ BLAS and LAPACK."
(or (cdr (assoc datatype *supported-datatypes* :test #'equal))
(error "LAPACK does not support the datatype ~A" datatype)))

(defun walk-and-replace (tree alist)
"Deep-copy TREE while replacing any symbol which is the car of an
element of ALIST with the CDR of that element."
(labels ((aux (subtree)
(typecase subtree
(symbol
(let ((pair (assoc subtree alist)))
(if pair (cdr pair) subtree)))
(list
(mapcar #'aux subtree))
(t subtree))))
(aux tree)))

(defmacro def-lapack-method (name (&rest lambda-list) &body body)
"Define methods for supported datatypes for the lapack method named
NAME. The symbols !FUNCTION, !DATA-TYPE, and !MATRIX-TYPE are
Expand All @@ -168,9 +155,9 @@ See for example the definition of GEMM for how to use this macro."
(!data-type . ,type)
(!matrix-type . ,(fnv-type-to-matrix-type type :base)))))
`(defmethod ,name
,(walk-and-replace lambda-list replacements)
,(sublis replacements lambda-list)
(with-blapack
,@(walk-and-replace body replacements)))))))
,@(sublis replacements body)))))))

(defun orientation->letter (orientation)
"Return the LAPACK letter corresponding to ORIENTATION."
Expand Down

0 comments on commit 0eb959a

Please sign in to comment.