-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0a872e
commit d49024b
Showing
6 changed files
with
47 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,4 @@ | |
epsilon) | ||
(return-from =-lisp nil)))) | ||
t) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
;;;; specialized-vector.lisp | ||
;;;; | ||
;;;; Author: Robert Smith | ||
|
||
(in-package #:magicl) | ||
|
||
;;;; Here we have some functions that specialize on many types | ||
|
||
(defmacro define-common-real-vector-methods (vector-class elt-type) | ||
`(progn | ||
(defmethod dot-lisp ((vec1 ,vector-class) (vec2 ,vector-class)) | ||
(let ((size1 (size vec1)) | ||
(size2 (size vec2))) | ||
(assert (cl:= size1 size2)) | ||
(let ((s1 (storage vec1)) | ||
(s2 (storage vec2))) | ||
(declare (optimize speed) | ||
(type (simple-array ,elt-type (*)) s1 s2)) | ||
(loop :with s :of-type ,elt-type := ,(coerce 0 elt-type) | ||
:for i :of-type alexandria:array-index :below size1 | ||
:do (incf s (* (aref s1 i) (aref s2 i))) | ||
:finally (return s))))))) | ||
|
||
(defmacro define-common-complex-vector-methods (vector-class elt-type) | ||
`(progn | ||
(defmethod dot-lisp ((vec1 ,vector-class) (vec2 ,vector-class)) | ||
(let ((size1 (size vec1)) | ||
(size2 (size vec2))) | ||
(assert (cl:= size1 size2)) | ||
(let ((s1 (storage vec1)) | ||
(s2 (storage vec2))) | ||
(declare (optimize speed) | ||
(type (simple-array ,elt-type (*)) s1 s2)) | ||
(loop :with s :of-type ,elt-type := ,(coerce 0 elt-type) | ||
:for i :of-type alexandria:array-index :below size1 | ||
:do (incf s (* (aref s1 i) (conjugate (aref s2 i)))) | ||
:finally (return s))))))) | ||
|
||
(define-common-real-vector-methods vector/single-float single-float) | ||
(define-common-real-vector-methods vector/double-float double-float) | ||
(define-common-complex-vector-methods vector/complex-single-float (complex single-float)) | ||
(define-common-complex-vector-methods vector/complex-double-float (complex double-float)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters