1
1
import numpy as np
2
2
3
3
from opensquirrel .Common import Can1
4
- from opensquirrel .Gates import MultiQubitMatrixSemantic , SingleQubitAxisAngleSemantic , Semantic
4
+ from opensquirrel .Gates import MultiQubitMatrixSemantic , Semantic , SingleQubitAxisAngleSemantic
5
5
6
6
7
7
# This should only be used for testing and on circuits with low number of qubits.
@@ -11,8 +11,7 @@ def getBigMatrix(semantic: Semantic, qubitOperands, totalQubits):
11
11
12
12
axis , angle , phase = semantic .axis , semantic .angle , semantic .phase
13
13
result = np .kron (
14
- np .kron (np .eye (1 << (totalQubits - whichQubit - 1 )), Can1 (axis , angle , phase )), np .eye (1 <<
15
- whichQubit )
14
+ np .kron (np .eye (1 << (totalQubits - whichQubit - 1 )), Can1 (axis , angle , phase )), np .eye (1 << whichQubit )
16
15
)
17
16
assert result .shape == (1 << totalQubits , 1 << totalQubits )
18
17
return result
@@ -28,8 +27,7 @@ def getBigMatrix(semantic: Semantic, qubitOperands, totalQubits):
28
27
for input in range (1 << totalQubits ):
29
28
smallMatrixCol = 0
30
29
for i in range (len (qubitOperands )):
31
- smallMatrixCol |= ((input & (1 << qubitOperands [i ])) >> qubitOperands [i ]) << (len (qubitOperands ) -
32
- 1 - i )
30
+ smallMatrixCol |= ((input & (1 << qubitOperands [i ])) >> qubitOperands [i ]) << (len (qubitOperands ) - 1 - i )
33
31
34
32
col = m [:, smallMatrixCol ]
35
33
0 commit comments