Explorar el Código

Added shorthand

Adam Kelly hace 6 años
padre
commit
b638922e5d
Se han modificado 1 ficheros con 31 adiciones y 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)