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

Bug Report: unexpected behavior when combining QuantumModulus and QuantumBool #40

Open
diehoq opened this issue Apr 3, 2024 · 0 comments

Comments

@diehoq
Copy link
Contributor

diehoq commented Apr 3, 2024

When trying to evaluate a conditional statement depending of a superposition state of QuantumModulus, the result is wrong and not in superposition.
Here is a code snippet showing the issue and the expected behavior with QuantumFloat

import qrisp

qf = qrisp.QuantumModulus(10)

qrisp.h(qf[3])

print(qf)

q_bool_3 = (qf <=  4)

print(q_bool_3)

Output:
{0: 0.5, 8: 0.5}
{True: 1.0}

import qrisp 

qf = qrisp.QuantumFloat(10)

qrisp.h(qf[3])

print(qf)

q_bool_3 = (qf <=  4)

print(q_bool_3)

Output: Simulating 10 qubits.. | | [ 0%]
{0: 0.5, 8: 0.5}
{False: 0.5, True: 0.5}

For the time being a first solution proposed by @positr0nium is the following:

import qrisp

qf = qrisp.QuantumModulus(10)

qrisp.h(qf[3])

print(qf)

qf.__class__ = qrisp.QuantumFloat

qbl = qf >= 4

qf.__class__ = qrisp.QuantumModulus

print(qbl)

Output:
{0: 0.5, 8: 0.5}
{False: 0.5, True: 0.5}

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

1 participant