-
Notifications
You must be signed in to change notification settings - Fork 5
isomorphisms for bloch plotting #34
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
base: main
Are you sure you want to change the base?
Conversation
Convert a ket to a Bloch vector representation. | ||
""" | ||
function ket_to_bloch(ψ::AbstractVector{<:Number}) | ||
ρ = ψ * ψ' |
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.
Can we add a quick assert for the size we expect?
src/isomorphisms.jl
Outdated
# construct the quantum state | ||
ket = [cos(θ/2), exp(im * φ) * sin(θ/2)] | ||
|
||
ket = map(c -> round(real(c), digits=digits) + (isreal(c) ? 0.0 : im * round(imag(c), digits=digits)), ket) |
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.
The bloch vector should be real values, so try:
bloch_to_ket(bloch::AbstractVector{R}) where R <: Real
and then we can take a quick shortcut ket = Complex{R}[cos(θ/2), exp(im * φ) * sin(θ/2)]
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.
also, any reason for needing to round to some specific digits?
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.
this was just to get exactly 0 or exactly 1, etc when converting, not exactly necessary though, should I delete?
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.
Yeah let's switch to the alternative implementation suggested above (I think we'll just end up with tiny numerical errors for any plotting applications, which shouldn't matter)
the isomorphisms work, i had to redefine PAULIS because it wouldn't recognize them even though they are defined in PiccoloQuantumObjects |
ket_to_bloch and bloch_to_ket
TODO: