Skip to content

Commit

Permalink
Add single qubit projector.
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandMacDoland committed Nov 22, 2023
1 parent da11186 commit 4e3fb3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pyqtorch/matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
dtype=DEFAULT_MATRIX_DTYPE,
)
NMAT = torch.tensor([[0, 0], [0, 1]], dtype=DEFAULT_MATRIX_DTYPE)
PROJ0MAT = torch.tensor([[1, 0], [0, 0]], dtype=DEFAULT_MATRIX_DTYPE)
PROJ1MAT = torch.tensor([[0, 0], [0, 1]], dtype=DEFAULT_MATRIX_DTYPE)
NDIAG = torch.tensor([0, 1], dtype=DEFAULT_MATRIX_DTYPE)
ZDIAG = torch.tensor([1, -1], dtype=DEFAULT_MATRIX_DTYPE)
IDIAG = torch.tensor([1, 1], dtype=DEFAULT_MATRIX_DTYPE)
Expand Down Expand Up @@ -50,6 +52,8 @@
"SDAGGER": SDAGGERMAT,
"T": TMAT,
"N": NMAT,
"PROJ0": PROJ0MAT,
"PROJ1": PROJ1MAT,
"H": HMAT,
"SWAP": SWAPMAT,
"CSWAP": CSWAPMAT,
Expand Down
7 changes: 7 additions & 0 deletions pyqtorch/primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ def __init__(self, target: int):
super().__init__(OPERATIONS_DICT["SDAGGER"], target)


class Proj(Primitive):
def __init__(self, target: int, state: str = "1"):
if state == "0":
super().__init__(OPERATIONS_DICT["PROJ0"], target)
super()._init__(OPERATIONS_DICT["PROJ1"], target)


class N(Primitive):
def __init__(self, target: int):
super().__init__(OPERATIONS_DICT["N"], target)
Expand Down

0 comments on commit 4e3fb3f

Please sign in to comment.