Skip to content
Permalink
Browse files

Add numpy backend ccx implementation to improve performance

  • Loading branch information...
gyu-don committed Mar 29, 2019
1 parent 151f104 commit 9db46fd444f3a69d806630154b559858479878f7
Showing with 23 additions and 0 deletions.
  1. +18 −0 blueqat/backends/numpy_backend.py
  2. +5 −0 blueqat/gate.py
@@ -253,6 +253,24 @@ def gate_s(self, gate, ctx):
qubits[(i & (1 << target)) != 0] *= 1.j
return ctx

def gate_ccz(self, gate, ctx):
c1, c2, t = gate.targets
qubits = ctx.qubits
n_qubits = ctx.n_qubits
i = ctx.indices
indices = (i & (1 << c1)) != 0
indices &= (i & (1 << c2)) != 0
indices &= (i & (1 << t)) != 0
qubits[indices] *= -1
return ctx

def gate_ccx(self, gate, ctx):
c1, c2, t = gate.targets
ctx = self.gate_h(HGate(t), ctx)
ctx = self.gate_ccz(CCZGate(gate.targets), ctx)
ctx = self.gate_h(HGate(t), ctx)
return ctx

def gate_u1(self, gate, ctx):
qubits = ctx.qubits
n_qubits = ctx.n_qubits
@@ -227,6 +227,11 @@ def fallback(self, n_qubits):
]


class CCZGate(Gate):
"""2-Controlled Z gate"""
lowername = "ccz"


class U1Gate(OneQubitGate):
"""U1 gate"""
def __init__(self, targets, lambd, **kwargs):

0 comments on commit 9db46fd

Please sign in to comment.
You can’t perform that action at this time.