Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BLOCK-DIAG, MAP-BLOCKS, and PARTIAL-TRACE #104

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

notmgsk
Copy link
Member

@notmgsk notmgsk commented Apr 17, 2020

And BLOCK-MATRIX-P

@@ -219,6 +219,11 @@ ELEMENT-TYPE, CAST, COPY-TENSOR, DEEP-COPY-TENSOR, TREF, SETF TREF)"
"Whether MATRIX is a unitary matrix"
(= matrix (conjugate-transpose matrix) epsilon))

(defun block-matrix-p (matrix)
Copy link
Contributor

@braised-babbage braised-babbage Apr 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the general usage is that a "block matrix" is a matrix with an associated decomposition, e.g.

[[A, B, C],
 [D, E, F]]

would be a valid block decomposition if nrows(A) = nrows(B) = nrows(C), ncols(A) = ncols(D), and so on. In this usage, the matrix doesn't have to be square. I'd suggest changing the name of your defun and adding a docstring if you want to keep the current behavior.

@@ -379,6 +384,17 @@ If fast is t then just change layout. Fast can cause problems when you want to m
(loop :for i :below rows
:collect (tref matrix i i))))))

(defgeneric block-diag (matrix)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here -- seems like you have in mind specifically 2x2 block decompositions.

(policy-cond:with-expectations (> speed safety)
((assertion (block-matrix-p matrix)))
(let* ((dim (floor (sqrt (nrows matrix))))
(freiche (zeros (list dim dim) :type type)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yum

@@ -146,6 +148,7 @@
#:orthonormalize
#:orthonormalize!
#:trace
#:partial-trace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants