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

Add ECR gate #234

Merged
merged 9 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions bqskit/ir/gates/constant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from bqskit.ir.gates.constant.cx import CXGate
from bqskit.ir.gates.constant.cy import CYGate
from bqskit.ir.gates.constant.cz import CZGate
from bqskit.ir.gates.constant.ecr import ECRGate
edyounis marked this conversation as resolved.
Show resolved Hide resolved
from bqskit.ir.gates.constant.h import HGate
from bqskit.ir.gates.constant.identity import IdentityGate
from bqskit.ir.gates.constant.iswap import ISwapGate
Expand Down Expand Up @@ -57,6 +58,7 @@
'CXGate',
'CYGate',
'CZGate',
'ECRGate',
'HGate',
'IdentityGate',
'ISwapGate',
Expand Down
26 changes: 26 additions & 0 deletions bqskit/ir/gates/constant/ecr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""This module implements the ECRGate."""
from bqskit.ir.gates.qubitgate import QubitGate
from bqskit.ir.gates.constantgate import ConstantGate
from bqskit.qis.unitary.unitarymatrix import UnitaryMatrix
import math

class ECRGate(ConstantGate, QubitGate):
edyounis marked this conversation as resolved.
Show resolved Hide resolved
_name = 'ecr'
_num_qudits = 2
_qasm_name = 'ecr'
_utry = UnitaryMatrix([
[0, 0, 1*1/math.sqrt(2), 1j*1/math.sqrt(2)],
[0, 0, 1j*1/math.sqrt(2), 1*1/math.sqrt(2)],
[1*1/math.sqrt(2), -1j*1/math.sqrt(2), 0, 0],
[-1j*1/math.sqrt(2), 1*1/math.sqrt(2), 0, 0]
])

def __init__(self) -> None:
pass

def get_qasm_gate_def(self) -> str:
qasm_rzx = "gate rzx(param0) q0,q1 { h q1; cx q0,q1; rz(param0) q1; cx q0,q1; h q1; }"
qasm_ecr = "gate ecr q0,q1 { rzx(pi/4) q0,q1; x q0; rzx(-pi/4) q0,q1; }"
return qasm_rzx +"\n" + qasm_ecr