Adam Kelly преди 5 години
родител
ревизия
b638922e5d
променени са 1 файла, в които са добавени 31 реда и са изтрити 2 реда
  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)