forked from quil-lang/magicl
-
Notifications
You must be signed in to change notification settings - Fork 0
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
4f670ee
commit c2a9d9e
Showing
6 changed files
with
108 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
;;;; lapack-schur.lisp | ||
;;;; | ||
;;;; Author: Robert Smith | ||
|
||
(in-package #:magicl-lapack) | ||
|
||
(defmethod schur-extension ((a magicl:matrix/double-float)) | ||
(assert (magicl:square-matrix-p a)) | ||
;; TODO: This probably doesn't properly take into account the tensor | ||
;; layout, etc. | ||
(let* ((aa (magicl:deep-copy-tensor a)) | ||
(n (magicl:nrows a)) | ||
(ttr (make-array n :element-type 'double-float :initial-element 0.0d0)) | ||
(tti (make-array n :element-type 'double-float :initial-element 0.0d0)) | ||
(tt (magicl:zeros (list n n) :type '(complex double-float))) | ||
(zz (magicl:zeros (magicl:shape a) :type 'double-float)) | ||
(lwork (* 3 n)) | ||
(info 0)) | ||
(flet ((arr (i &optional (ty 'double-float)) | ||
(make-array i :element-type ty))) | ||
(declare (inline arr)) | ||
(magicl.lapack-cffi:%dgees | ||
"V" | ||
"N" | ||
0 | ||
n | ||
(magicl::storage aa) | ||
n | ||
0 | ||
ttr | ||
tti | ||
(magicl::storage zz) | ||
n | ||
(arr lwork) | ||
lwork | ||
(arr n '(signed-byte 32)) ; not referenced | ||
info) ; INFO | ||
;; TODO: we need to check info | ||
(dotimes (i n) | ||
(setf (magicl:tref tt i i) (complex (aref ttr i) (aref tti i)))) | ||
(values zz tt)))) | ||
|
||
(defmethod schur-extension ((a magicl:matrix/complex-double-float)) | ||
(assert (magicl:square-matrix-p a)) | ||
;; TODO: This probably doesn't properly take into account the tensor | ||
;; layout, etc. | ||
(let* ((aa (magicl:deep-copy-tensor a)) | ||
(n (magicl:nrows a)) | ||
(tt-diag (make-array n :element-type '(complex double-float) | ||
:initial-element #C(0.0d0 0.0d0))) | ||
(tt (magicl:zeros (list n n) :type '(complex double-float))) | ||
(zz (magicl:zeros (magicl:shape a) :type '(complex double-float))) | ||
(lwork (* 2 n)) | ||
(info 0)) | ||
(flet ((arr (i &optional (ty '(complex double-float))) | ||
(make-array i :element-type ty))) | ||
(declare (inline arr)) | ||
(magicl.lapack-cffi:%zgees | ||
"V" | ||
"N" | ||
0 | ||
n | ||
(magicl::storage aa) | ||
n | ||
0 | ||
tt-diag | ||
(magicl::storage zz) | ||
n | ||
(arr lwork) | ||
lwork | ||
(arr n 'double-float) | ||
(arr n '(signed-byte 32)) ; not referenced | ||
info) ; INFO | ||
;; TODO: we need to check info | ||
(dotimes (i n) | ||
(setf (magicl:tref tt i i) (aref tt-diag i))) | ||
(values zz tt)))) | ||
|
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 |
---|---|---|
|
@@ -175,6 +175,7 @@ | |
#:csd-blocks | ||
#:csd | ||
#:svd | ||
#:schur | ||
#:qz | ||
#:ql | ||
#:qr | ||
|
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