Skip to content

Commit

Permalink
Update pennylane/registers.py
Browse files Browse the repository at this point in the history
Co-authored-by: Utkarsh <utkarshazad98@gmail.com>
  • Loading branch information
austingmhuang and obliviateandsurrender committed Jul 24, 2024
1 parent ade1f08 commit 69ba8d5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pennylane/registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,23 @@ def registers(register_dict):
.. code-block::
reg = qml.registers({"aux": 1, "phi": 5, "psi": 5})
dev = qml.device("default.qubit")
reg = registers({"aux": 1, "phi": 5, "psi": 5})
@qml.qnode(dev)
def circuit():
qml.Hadamard(reg["aux"])
for state in ["phi", "psi"]:
qml.BasisState([1, 1, 0, 0, 0], reg[state])
qml.Hadamard(reg["aux"])
for i in range(len(reg["phi"])):
qml.CSWAP(reg["aux"] | reg["phi"][i] | reg["psi"][i])
qml.CSWAP(reg["aux"] + reg["phi"][i] + reg["psi"][i])
qml.Hadamard(reg["aux"])
return qml.expval(qml.Z(wires=reg["aux"]))
>>> circuit()
0.9999999999999996
"""

def _registers(register_dict, _start_wire_index=0):
Expand Down

0 comments on commit 69ba8d5

Please sign in to comment.