Skip to content

Hadamard gate on multiple wires causes error #306

@s110m

Description

@s110m

Consider the following:

# tq.QuantumState to prepare an EPR pair

# q_state = tq.QuantumState(n_wires=2)
q_state = tq.QuantumDevice(n_wires=2, bsz=2, device="cpu")
q_state.h(wires=0)
q_state.cnot(wires=[0, 1])
q_state.rx(wires=0, params=0.3)

print(q_state)
bitstring = tq.measure(q_state, n_shots=1024, draw_id=0)
print(bitstring)

Suppose I want to apply a Hadamard gate on wires 0 and 1.
When I try q_state.h(wires=[0, 1]), it gives me an error.
Of course, I can write it in two lines using:

q_state.h(wires=0)
q_state.h(wires=1)

But in the docstring, the argument is specified as wires (Union[List[int], int]): Which qubit(s) to apply the gate to.

Is my understanding correct? Or does this need correction?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions