-
Notifications
You must be signed in to change notification settings - Fork 58
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
Update Magicl bindings for Magicl NG #238
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Nice to see some examples of the new-and-improved magicl in the wild. Seems like a nice usability & ergonomics improvement.
(reduce #'+ (magicl:matrix-diagonal | ||
(density-matrix (magicl:from-array prepared-state | ||
(list rows cols) | ||
:type '(complex double-float)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the compiler doesn't complain, maybe the :type
here should be qvm:cflonum
instead? ditto elsewhere below.
src/linear-algebra.lisp
Outdated
@@ -249,7 +249,7 @@ The function will just return NIL, and modify the contents of RESULT." | |||
(:method ((gate quil:simple-gate)) | |||
(make-instance 'quil:simple-gate | |||
:name (concatenate 'string (quil:gate-name gate) "*") | |||
:matrix (magicl:conjugate-entrywise (quil:gate-matrix gate)))) | |||
:matrix (magicl:map! #'conjugate (quil:gate-matrix gate)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the !
indicate mutation? I don't know if it matters here, but the old conjugate-entrywise
did not mutate the input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colescott what about this one? ok to map!
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we very much shall not mutate. You're destroying the environment aka the original gate binding matrix.
Co-Authored-By: appleby <mappleby@rigetti.com>
ddc7493
to
b7cb424
Compare
@stylewarning smash the merge button |
src/linear-algebra.lisp
Outdated
@@ -249,7 +249,7 @@ The function will just return NIL, and modify the contents of RESULT." | |||
(:method ((gate quil:simple-gate)) | |||
(make-instance 'quil:simple-gate | |||
:name (concatenate 'string (quil:gate-name gate) "*") | |||
:matrix (magicl:conjugate-entrywise (quil:gate-matrix gate)))) | |||
:matrix (magicl:map! #'conjugate (quil:gate-matrix gate)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we very much shall not mutate. You're destroying the environment aka the original gate binding matrix.
src/linear-algebra.lisp
Outdated
@@ -259,5 +259,5 @@ The function will just return NIL, and modify the contents of RESULT." | |||
:name (concatenate 'string (quil:gate-name gate) "*") | |||
:dimension (quil:gate-dimension gate) | |||
:matrix-function #'(lambda (&rest parameters) | |||
(magicl:conjugate-entrywise | |||
(apply #'quil:gate-matrix gate parameters)))))) | |||
(magicl:map! #'conjugate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no bueno
@colescott if u dont stop mutating im going to force us all to write HASKELL instead |
Promise? |
This is to update all magicl bindings to work with quil-lang/magicl#63.
Benchmarks need to be done prior to merging to make sure there is not a significant performance hit.