-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:BQSKit/bqskit into justink/sub_state
- Loading branch information
Showing
15 changed files
with
346 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""This module implements the ECRGate.""" | ||
from __future__ import annotations | ||
|
||
import math | ||
|
||
from bqskit.ir.gates.constantgate import ConstantGate | ||
from bqskit.ir.gates.qubitgate import QubitGate | ||
from bqskit.qis.unitary.unitarymatrix import UnitaryMatrix | ||
|
||
|
||
class ECRGate(ConstantGate, QubitGate): | ||
""" | ||
The echoed cross-resonance gate (ECR). | ||
The ECR gate is given by the following unitary: | ||
.. math:: | ||
\\frac{1}{\\sqrt{2}} | ||
\\begin{pmatrix} | ||
0 & 1 & 0 & i \\\\ | ||
1 & 0 & -i & 0 \\\\ | ||
0 & i & 0 & 1 \\\\ | ||
-i & 0 & 1 & 0 | ||
\\end{pmatrix} | ||
""" | ||
_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""This module implements the SqrtTGate.""" | ||
from __future__ import annotations | ||
|
||
import cmath | ||
|
||
from bqskit.ir.gates.constantgate import ConstantGate | ||
from bqskit.ir.gates.qubitgate import QubitGate | ||
from bqskit.qis.unitary.unitarymatrix import UnitaryMatrix | ||
|
||
|
||
class SqrtTGate(ConstantGate, QubitGate): | ||
""" | ||
The single-qubit square root T gate. | ||
.. math:: | ||
\\begin{pmatrix} | ||
1 & 0 \\\\ | ||
0 & e^{i\\frac{\\pi}{8}} \\\\ | ||
\\end{pmatrix} | ||
""" | ||
|
||
_num_qudits = 1 | ||
_qasm_name = 'st' | ||
_utry = UnitaryMatrix( | ||
[ | ||
[1, 0], | ||
[0, cmath.exp(1j * cmath.pi / 8)], | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.