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

Added matrix_division support for QuArray. #34

Closed
wants to merge 0 commits into from

Conversation

amitjamadagni
Copy link
Contributor

A*X == B where A,X,B are AbstractQuArray.

@@ -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)))
Copy link
Contributor

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))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not coeffs?

@acroy
Copy link
Contributor

acroy commented May 18, 2015

Please add brief comments stating what the functions are doing (solving linear systems) and some simple tests.

@amitjamadagni
Copy link
Contributor Author

@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.])
Copy link
Contributor

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.

@acroy
Copy link
Contributor

acroy commented May 21, 2015

Since #33 made some changes in arraymath you will need to rebase against master before we are able to merge.

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