• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

feihoo87 / waveforms-math / 7112243486

06 Dec 2023 08:46AM UTC coverage: 0.0%. First build
7112243486

push

github

feihoo87
fix

0 of 1 new or added line in 1 file covered. (0.0%)

0 of 4647 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/waveforms/quantum/clifford/seq2mat.py
1
from qlisp.simulator.matricies import synchronize_global_phase
×
NEW
2
from qlisp.simulator.simple import seq2mat as _seq2mat
×
3

4

5
def twoQubitGate(gates):
×
6
    return {
×
7
        ('CZ', 'CZ'): ('CZ', (0, 1)),
8
        ('C', 'Z'): ('CZ', (0, 1)),
9
        ('Z', 'C'): ('CZ', (0, 1)),
10
        ('CX', 'CX'): ('Cnot', (0, 1)),
11
        ('XC', 'XC'): ('Cnot', (1, 0)),
12
        ('CR', 'CR'): ('CR', (0, 1)),
13
        ('RC', 'RC'): ('CR', (1, 0)),
14
        ('C', 'X'): ('Cnot', (0, 1)),
15
        ('X', 'C'): ('Cnot', (1, 0)),
16
        ('C', 'R'): ('CR', (0, 1)),
17
        ('R', 'C'): ('CR', (1, 0)),
18
        ('iSWAP', 'iSWAP'): ('iSWAP', (0, 1)),
19
        ('SWAP', 'SWAP'): ('SWAP', (0, 1)),
20
        ('SQiSWAP', 'SQiSWAP'): ('SQiSWAP', (0, 1)),
21
    }[gates]
22

23

24
def seq2qlisp(seq, qubits):
×
25
    if len(seq) > 2:
×
26
        raise ValueError("Only support 1 or 2 bits.")
×
27
    if len(seq) != len(qubits):
×
28
        raise ValueError("seq size and qubit num mismatched.")
×
29

30
    qlisp = []
×
31
    for gates in zip(*seq):
×
32
        try:
×
33
            qlisp.append(twoQubitGate(gates))
×
34
        except:
×
35
            for gate, i in zip(gates, qubits):
×
36
                qlisp.append((gate, i))
×
37
    return qlisp
×
38

39

40
def seq2mat(seq):
×
41
    N = len(seq)
×
42
    if N > 2:
×
43
        raise ValueError("Only support 1 or 2 bits.")
×
44
    if N == 1:
×
45
        qubits = (1, )
×
46
    else:
47
        qubits = (0, 1)
×
48

49
    return synchronize_global_phase(_seq2mat(seq2qlisp(seq, qubits)))
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc