Explorar o código

Added shorthand

Adam Kelly %!s(int64=6) %!d(string=hai) anos
pai
achega
b638922e5d
Modificáronse 1 ficheiros con 31 adicións e 2 borrados
  1. 31 2
      qcgpu/state.py

+ 31 - 2
qcgpu/state.py

@@ -1,7 +1,7 @@
 """
 Quantum Register Object
 """
-
+import qcgpu
 from qcgpu.backend import Backend
 import pyopencl as cl
 import numpy as np
@@ -109,4 +109,33 @@ class State:
         """A string representation of the state"""
 
         # TODO: Finish this method
-        return np.array_str(self.backend.buffer)
+        return np.array_str(self.backend.buffer)
+
+
+    # Gates
+    def h(self, target):
+        self.apply_gate(qcgpu.gate.h(), target)
+
+    def x(self, target):
+        self.apply_gate(qcgpu.gate.x(), target)
+
+    def y(self, target):
+        self.apply_gate(qcgpu.gate.y(), target)
+
+    def z(self, target):
+        self.apply_gate(qcgpu.gate.z(), target)
+
+    def s(self, target):
+        self.apply_gate(qcgpu.gate.s(), target)
+
+    def t(self, target):
+        self.apply_gate(qcgpu.gate.t(), target)
+
+    def sqrt_x(self, target):
+        self.apply_gate(qcgpu.gate.sqrt_x(), target)
+
+    def cx(self, control, target):
+        self.apply_gate(qcgpu.gate.x(), control, target)
+
+    def cnot(self, control, target):
+        self.apply_controlled_gate(qcgpu.gate.x(), control, target)