-
Notifications
You must be signed in to change notification settings - Fork 6
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
Added matrix_division support for QuArray. #34
Conversation
@@ -109,7 +109,7 @@ Base.scale(qarr::AbstractQuArray, num::Number) = scale(num, qarr) | |||
*(num::Number, qarr::AbstractQuArray) = scale(num, qarr) | |||
*(qarr::AbstractQuArray, num::Number) = scale(qarr, num) | |||
/(qarr::AbstractQuArray, num::Number) = scale(1/num, qarr) | |||
|
|||
\(qarr::AbstractQuArray, v::AbstractQuArray) = QuArray(\(coeffs(qarr), coeffs(v))) |
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.
You should determine the return type using similar_type
(see +,-,* for example). It's probably better to restrict the arguments to 2 AbstractQuMatrix
and AbstractQuMatrix
and AbstractQuVector
(so you need two separate functions). Anything else won't work.
@@ -110,6 +108,17 @@ Base.scale(qarr::AbstractQuArray, num::Number) = scale(num, qarr) | |||
*(qarr::AbstractQuArray, num::Number) = scale(qarr, num) | |||
/(qarr::AbstractQuArray, num::Number) = scale(1/num, qarr) | |||
|
|||
function \{B<:OrthonormalBasis}(qm1::AbstractQuMatrix{B}, qm2::AbstractQuMatrix{B}) | |||
div = \(rawcoeffs(qm1),rawcoeffs(qm2)) |
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.
Why not coeffs
?
Please add brief comments stating what the functions are doing (solving linear systems) and some simple tests. |
@acroy the tests seem to pass on julia 0.3 and fail on the other julia 0.4, and also I have hard coded the tests, any better way around would be really helpful. |
# tests for Matrix Division | ||
v1 = [0.5+0*im, 0.+0.*im] | ||
qv1 = normalize!(QuArray(v1)) | ||
@assert coeffs(\(sigmaz, sigmax)) == sparse([0. 1.;-1. 0.]) |
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.
Try to use full(sigmaz)
and full(sigmax)
here and in the next line. As I said via PM it might actually be better for the Pauli matrices to be dense anyways, but this can be done separately.
Since #33 made some changes in arraymath you will need to rebase against master before we are able to merge. |
A*X == B where A,X,B are
AbstractQuArray
.