qutech-delft / quantum-inspire-examples Goto Github PK
View Code? Open in Web Editor NEWExamples that illustrate the possibilities of the Quantum Inspire platform to run more complex algorithms
License: Apache License 2.0
Examples that illustrate the possibilities of the Quantum Inspire platform to run more complex algorithms
License: Apache License 2.0
In the Python file example_qiskit_conditional.py, the c_if
gates are used without preceding measurements. This could lead to ambiguities as the c_if
gates are conditional and depend on the state of the classical registers.
Run the following code in the Python file:
q = QuantumRegister(3, "q")
c0 = ClassicalRegister(1, "c0")
c1 = ClassicalRegister(1, "c1")
c2 = ClassicalRegister(1, "c2")
qc = QuantumCircuit(q, c0, c1, c2, name="conditional")
qc.h(q[0])
qc.h(q[1]).c_if(c0, 0) # h-gate on q[1] is executed
qc.h(q[2]).c_if(c1, 1) # h-gate on q[2] is not executed
qc.measure(q[0], c0)
qc.measure(q[1], c1)
qc.measure(q[2], c2)
I would have expected either to have preceding measurements, such as:
q = QuantumRegister(3, "q")
c0 = ClassicalRegister(1, "c0")
c1 = ClassicalRegister(1, "c1")
c2 = ClassicalRegister(1, "c2")
qc = QuantumCircuit(q, c0, c1, c2, name="conditional")
qc.h(q[0])
qc.measure(q[0], c0)
qc.h(q[1]).c_if(c0, 0) # h-gate on q[1] is executed
qc.measure(q[1], c1)
qc.h(q[2]).c_if(c1, 1) # h-gate on q[2] is not executed
qc.measure(q[0], c0)
qc.measure(q[1], c1)
qc.measure(q[2], c2)
Or to have the c_if
gates removed, such as:
q = QuantumRegister(3, "q")
c0 = ClassicalRegister(1, "c0")
c1 = ClassicalRegister(1, "c1")
c2 = ClassicalRegister(1, "c2")
qc = QuantumCircuit(q, c0, c1, c2, name="conditional")
qc.h(q[0])
qc.h(q[1])
# qc.h(q[2]) <- removed
qc.measure(q[0], c0)
qc.measure(q[1], c1)
qc.measure(q[2], c2)
To avoid ambiguity.
Thanks in advance, I wish you a happy and productive day.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.