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

Convert qudit type CVec into type Qubits for measurement. #21

Closed
ArcaneArrowX opened this issue Apr 26, 2016 · 1 comment
Closed

Convert qudit type CVec into type Qubits for measurement. #21

ArcaneArrowX opened this issue Apr 26, 2016 · 1 comment

Comments

@ArcaneArrowX
Copy link

Hi there, so my ultimate goal is to apply certain operations on a qudit (d-level quantum states) state. For instance, multiply the amplitude of the state |4> by a scalar. e.g. |4> to -|4>. Below is a simple code to get the equal superposition of 2^n states in a qudit CVec type.

[<LQD>]
let __UserSample(n:int) =

    let k        = Ket(n)

    let qs       = k.Qubits 

    H >< qs 

    let mutable psi = k.Single()

I couldn't see how applying operations on a specific qudit state is possible by applying gates on post-Hadamard qs (type Qubits). Post Hadamard qs for n = 3 looks something like that

image

which can be expanded into

image

So applying any kinds of gate on these qubits before using the Single() command on the k will affect other qudit states that I do not want to touch. That is why I resolved to manipulating psi of CVec type which allows me to operate on a specific qudit states.

After all the operations have been done on psi, is there a pre-defined function/gate in LiQUi|> to convert this CVec type into Qubits type to be measured?

@dbwz8
Copy link

dbwz8 commented Apr 26, 2016

The Ket class is made of two parts:

  • The state vector
  • The definition of the qubits that map to the state vector.

After a ket.Single(), the CVec you get back is just a pointer to the internal storage for the Ket instance. That means that you can just use the ket.Qubits() at that point to manipulate the qubits in any way you want (e.g., apply gates to any of the qubits in the Ket).

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

No branches or pull requests

2 participants