Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

s-a-s-h
Copy link

@s-a-s-h s-a-s-h commented Jun 10, 2025

ket_to_bloch and bloch_to_ket

TODO:

  • density_to_bloch
  • bloch_to_density

Convert a ket to a Bloch vector representation.
"""
function ket_to_bloch(ψ::AbstractVector{<:Number})
ρ = ψ * ψ'
Copy link
Member

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?

# 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)
Copy link
Member

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)]

Copy link
Member

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?

Copy link
Author

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?

Copy link
Member

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)

@s-a-s-h
Copy link
Author

s-a-s-h commented Jun 18, 2025

the isomorphisms work, i had to redefine PAULIS because it wouldn't recognize them even though they are defined in PiccoloQuantumObjects

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