-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunique_freqs.py
110 lines (72 loc) · 2.01 KB
/
unique_freqs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import itertools
import time
import plotly.graph_objects as go
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
def get_positive_spectrum_gaps(eigenvalues, unique=True):
eigenvalues = list((sorted(eigenvalues, reverse=True)))
gaps = []
for i in range(0, len(eigenvalues) - 1):
for j in range(i + 1, len(eigenvalues)):
gap = eigenvalues[i] - eigenvalues[j]
if gap > 1e-5:
gaps.append(gap)
else:
print(f"Gap was too small {gap}")
if unique:
return list(set(gaps))
else:
return gaps
num_unique_gaps = []
num_unique_eigenvalues = []
# For simple feature maps, where the eigenvalues of the generator are qubit independent
max_n = 10
for n_qubits in range(1, max_n + 1):
single_qubit_eigenvalues = [[-1 / 2.0, 1 / 2.0] for n in range(1, n_qubits + 1)]
all_eigenvalues = [
sum(element) for element in itertools.product(*single_qubit_eigenvalues)
]
unique_eigenvalues = set(all_eigenvalues)
gaps = get_positive_spectrum_gaps(unique_eigenvalues)
print(gaps)
num_unique_gaps.append(len(gaps))
num_unique_eigenvalues.append(len(all_eigenvalues))
print(num_unique_gaps)
fig = go.Figure()
fig.add_trace(
go.Scatter(
# x=range(1, max_n + 1),
y=num_unique_gaps,
mode="lines+markers",
name="# of Unique Gaps",
marker=dict(
size=10,
color="#009682",
),
)
)
fig.add_trace(
go.Scatter(
# x=range(1, max_n + 1),
y=num_unique_eigenvalues,
mode="lines+markers",
name="# of Unique Eigenvalues",
marker=dict(
size=10,
color="#4664AA",
),
)
)
fig.update_layout(
xaxis=dict(
title="# of Qubits (n)",
),
yaxis=dict(
# title="Unique Eigenvalues",
type="log",
),
template="simple_white",
legend=dict(yanchor="top", y=0.99, xanchor="left", x=0.01),
)
fig.show()