-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from GenericP3rson/reformatting_ops
Reformatting ops
- Loading branch information
Showing
33 changed files
with
1,325 additions
and
1,105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from .op_types import Operation | ||
from abc import ABCMeta | ||
from ..macro import C_DTYPE | ||
import torchquantum as tq | ||
import torch | ||
from torchquantum.functional import mat_dict | ||
import torchquantum.functional.functionals as tqf | ||
|
||
|
||
class ECR(Operation, metaclass=ABCMeta): | ||
"""Class for Echoed Cross Resonance Gate.""" | ||
|
||
num_params = 0 | ||
num_wires = 2 | ||
matrix = mat_dict["ecr"] | ||
func = staticmethod(tqf.ecr) | ||
|
||
@classmethod | ||
def _matrix(cls, params): | ||
return cls.matrix | ||
|
||
|
||
EchoedCrossResonance = 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,19 @@ | ||
from .op_types import Operation | ||
from abc import ABCMeta | ||
from ..macro import C_DTYPE | ||
import torchquantum as tq | ||
import torch | ||
from torchquantum.functional import mat_dict | ||
import torchquantum.functional.functionals as tqf | ||
|
||
|
||
class GlobalPhase(Operation, metaclass=ABCMeta): | ||
"""Class for Global Phase gate.""" | ||
|
||
num_params = 1 | ||
num_wires = 0 | ||
func = staticmethod(tqf.globalphase) | ||
|
||
@classmethod | ||
def _matrix(cls, params): | ||
return tqf.globalphase_matrix(params) |
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,28 @@ | ||
from .op_types import Observable | ||
from abc import ABCMeta | ||
from ..macro import C_DTYPE | ||
import torchquantum as tq | ||
import torch | ||
from torchquantum.functional import mat_dict | ||
import torchquantum.functional.functionals as tqf | ||
|
||
|
||
class I(Observable, metaclass=ABCMeta): | ||
"""Class for Identity Gate.""" | ||
|
||
num_params = 0 | ||
num_wires = 1 | ||
eigvals = torch.tensor([1, 1], dtype=C_DTYPE) | ||
matrix = mat_dict["i"] | ||
func = staticmethod(tqf.i) | ||
|
||
@classmethod | ||
def _matrix(cls, params): | ||
return cls.matrix | ||
|
||
@classmethod | ||
def _eigvals(cls, params): | ||
return cls.eigvals | ||
|
||
def diagonalizing_gates(self): | ||
return [] |
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,20 @@ | ||
from .op_types import Operation | ||
from abc import ABCMeta | ||
from ..macro import C_DTYPE | ||
import torchquantum as tq | ||
import torch | ||
from torchquantum.functional import mat_dict | ||
import torchquantum.functional.functionals as tqf | ||
|
||
|
||
class ISWAP(Operation, metaclass=ABCMeta): | ||
"""Class for ISWAP Gate.""" | ||
|
||
num_params = 0 | ||
num_wires = 2 | ||
matrix = mat_dict["iswap"] | ||
func = staticmethod(tqf.iswap) | ||
|
||
@classmethod | ||
def _matrix(cls, params): | ||
return cls.matrix |
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.