... | ... |
@@ -1,3 +1,5 @@ |
1 |
+from functools import reduce |
|
2 |
+ |
|
1 | 3 |
from hypothesis import given |
2 | 4 |
import hypothesis.strategies as st |
3 | 5 |
import hypothesis.extra.numpy as hnp |
... | ... |
@@ -57,6 +59,12 @@ project_zero = np.array([[1, 0], [0, 0]]) |
57 | 59 |
project_one = np.array([[0, 0], [0, 1]]) |
58 | 60 |
|
59 | 61 |
|
62 |
+def product_gate(single_qubit_gates): |
|
63 |
+ # We reverse so that 'single_qubit_gates' can be indexed by the qubit |
|
64 |
+ # identifier; e.g. qubit #0 is actually the least-significant qubit |
|
65 |
+ return reduce(np.kron, reversed(single_qubit_gates)) |
|
66 |
+ |
|
67 |
+ |
|
60 | 68 |
# -- Tests -- |
61 | 69 |
|
62 | 70 |
|