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

Support controlled gates in PyQVM #1277

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions pyquil/simulation/_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from pyquil.pyqvm import AbstractQuantumSimulator
from pyquil.quilbase import Gate
from pyquil.simulation.matrices import QUANTUM_GATES
from pyquil.simulation.tools import lifted_gate

# The following function is lovingly copied from the Cirq project
# https://github.com/quantumlib/Cirq
Expand Down Expand Up @@ -149,11 +150,7 @@ def _get_gate_tensor_and_qubits(gate: Gate) -> Tuple[np.ndarray, List[int]]:
:param gate: the instruction
:return: tensor, qubit_inds.
"""
if len(gate.params) > 0:
matrix = QUANTUM_GATES[gate.name](*gate.params)
else:
matrix = QUANTUM_GATES[gate.name]

matrix = lifted_gate(gate, n_qubits=len(gate.qubits))
qubit_inds = [q.index for q in gate.qubits]

# e.g. 2-qubit matrix is 4x4; turns into (2,2,2,2) tensor.
Expand Down