Document store directive#5129
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
…d-store-directive
…d-store-directive
|
One or more of the following people are relevant to this code:
|
abbycross
left a comment
There was a problem hiding this comment.
I did a copyedit scan. Does anyone need to look with a technical eye? I know Becky's already been working closely with the SMEs on this
I'll share it with some experts! |
There was a problem hiding this comment.
@beckykd we should update the code example to:
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.circuit.classical import expr
qregs = QuantumRegister(4, "q")
creg = ClassicalRegister(3, "c")
# temp is a plain ClassicalRegister used as the store target
temp = ClassicalRegister(3, "temp")
qc = QuantumCircuit(qregs, creg, temp)
qc.h([0, 1, 2])
qc.measure([0, 1, 2], creg)
# Store bit-NOT of the full 3-bit register into temp
qc.store(temp, expr.bit_not(creg))
# Compute parity of temp using bit-indexed XOR
parity = expr.bit_xor(
expr.bit_xor(expr.index(temp, 0), expr.index(temp, 1)),
expr.index(temp, 2),
)
# Flip q3 if parity of ~creg is 1
with qc.if_test(parity):
qc.x(3)
qc.measure([0, 1, 2], creg)
qc.draw("mpl")due to an internal issue with the compiler. We can update it later in a separate issue once that's fixed.
just a reminder to update https://qiskit.github.io/documentation/pr-5129/docs/guides/execute-dynamic-circuits#store as per the discussion
Pages to review: https://qiskit.github.io/documentation/pr-5129/docs/guides/classical-feedforward-and-control-flow https://qiskit.github.io/documentation/pr-5129/docs/guides/execute-dynamic-circuits https://qiskit.github.io/documentation/pr-5129/docs/guides/executor-options#feature-compatibility https://qiskit.github.io/documentation/pr-5129/docs/guides/estimator-options#feature-compatibility --------- Co-authored-by: ABBY CROSS <across@us.ibm.com> Co-authored-by: Fran Cabrera <francabrera@users.noreply.github.com>
Pages to review:
https://qiskit.github.io/documentation/pr-5129/docs/guides/classical-feedforward-and-control-flow
https://qiskit.github.io/documentation/pr-5129/docs/guides/execute-dynamic-circuits
https://qiskit.github.io/documentation/pr-5129/docs/guides/executor-options#feature-compatibility
https://qiskit.github.io/documentation/pr-5129/docs/guides/estimator-options#feature-compatibility