-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpredict.py
More file actions
32 lines (25 loc) · 807 Bytes
/
predict.py
File metadata and controls
32 lines (25 loc) · 807 Bytes
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
from coeff import *
def pred(coeff,rho):
#Temporary function for predictions
#Directly computes trace instead of using k-RDMs
sum = 0
for P in coeff:
prod = coeff[P]
obs = 1
for i in range(len(P)):
obs = np.kron(obs,pauli_obs[int(P[i])])
sum+= prod*np.trace(obs@rho)
return sum.real
def true_value(O,U,rho):
#This function computes trace(O(U * rho * U^dag))
#O in the input is given as a dictionary
Udg = U.conjugate().transpose()
output_state = U @ rho @ Udg
sum = 0
for P in O:
prod = O[P]
obs = 1
for i in range(len(P)):
obs = np.kron(obs,pauli_obs[int(P[i])])
sum+= prod*np.trace(obs@output_state)
return sum.real