... | ... |
@@ -28,6 +28,15 @@ def unitary(n_qubits): |
28 | 28 |
) |
29 | 29 |
|
30 | 30 |
|
31 |
+def ket(n_qubits): |
|
32 |
+ size = 1 << n_qubits |
|
33 |
+ return ( |
|
34 |
+ hnp.arrays(complex, (size,), valid_complex) |
|
35 |
+ .filter(lambda v: np.linalg.norm(v) > 0) # vectors must be normalizable |
|
36 |
+ .map(lambda v: v / np.linalg.norm(v)) |
|
37 |
+ ) |
|
38 |
+ |
|
39 |
+ |
|
31 | 40 |
single_qubit_gates = unitary(1) |
32 | 41 |
two_qubit_gates = unitary(2) |
33 | 42 |
n_qubit_gates = n_qubits.flatmap(unitary) |