def WORMHOLE(tL, tR, beta, g, m, n): #H = qt.rand_herm(2**n) #H = rand_scrambler(n) global q, H, HL, HV, TFD, LBACK, TFD2, TFD3 global TFD4, LFORWARD, TFD5, V #H = 1j*qt.Qobj(scipy.linalg.logm(U.full())) COUPLING = (1j*g*V).expm() TFD6 = COUPLING*TFD5 TFD7 = RFORWARD*TFD6 FIN = TFD7 o = m+n+1 #print("%d should be %f" % (o, 2*np.log(2))) if False: for i in range(len(FIN.dims[0])): if i != 0: if i == o: print("*") f = FIN.ptrace((0, i)) e = qt.entropy_mutual(f, 0, 1) print ("subs 0 and %d: e = %.6f" % (i,e)) print() fin = FIN.ptrace((0, o)) e = qt.entropy_mutual(fin, 0, 1) should_be = 2*np.log(2) return "e: %f | %f" % (e, should_be)
def calculate_mutual_information(self, loud=True): self.should_be = 2 * np.log(2) self.FIN = self.FINAL.ptrace( list(range(self.m)) + list(range(2 * self.m + self.n, 3 * self.m + self.n))) self.mutual_info = qt.entropy_mutual(self.FIN, list(range(self.m)), list(range(self.m, 2 * self.m))) if loud: for i in range(self.m, self.ntotal_qubits): fin = self.FINAL.ptrace(list(range(self.m)) + [i]) mut_inf = qt.entropy_mutual(fin, list(range(self.m)), [self.m]) print("%s\te between ref and qubit %d: %.5f" % ("*" if i == self.output_index else "", i, mut_inf))
def test_EntropyMutual(): "Mutual information" # verify mutual information = S(A)+S(B) for pure state rhos = [rand_dm(25, dims=[[5, 5], [5, 5]], pure=True) for k in range(10)] for r in rhos: assert_equal(abs(entropy_mutual(r, [0], [1]) - ( entropy_vn(ptrace(r, 0)) + entropy_vn(ptrace(r, 1)))) < 1e-13, True) # check component selection rhos = [rand_dm(8, dims=[[2, 2, 2], [2, 2, 2]], pure=True) for k in range(10)] for r in rhos: assert_equal(abs(entropy_mutual(r, [0, 2], [1]) - (entropy_vn( ptrace(r, [0, 2])) + entropy_vn(ptrace(r, 1)))) < 1e-13, True)
def test_EntropyMutual(): "Entropy: Mutual information" # verify mutual information = S(A)+S(B) for pure state rhos = [rand_dm(25, dims=[[5, 5], [5, 5]], pure=True) for k in range(10)] for r in rhos: assert_equal( abs( entropy_mutual(r, [0], [1]) - (entropy_vn(ptrace(r, 0)) + entropy_vn(ptrace(r, 1)))) < 1e-13, True) # check component selection rhos = [ rand_dm(8, dims=[[2, 2, 2], [2, 2, 2]], pure=True) for k in range(10) ] for r in rhos: assert_equal( abs( entropy_mutual(r, [0, 2], [1]) - (entropy_vn(ptrace(r, [0, 2])) + entropy_vn(ptrace(r, 1)))) < 1e-13, True)
def test_component_selection(self): dm = qutip.rand_dm(8, dims=[[2, 2, 2], [2, 2, 2]], pure=True) expect = (qutip.entropy_vn(dm.ptrace([0, 2])) + qutip.entropy_vn(dm.ptrace(1))) assert abs(qutip.entropy_mutual(dm, [0, 2], [1]) - expect) < 1e-13
def test_pure_state_additive(self): # Verify mutual information = S(A) + S(B) for pure states. dm = qutip.rand_dm(25, dims=[[5, 5], [5, 5]], pure=True) expect = (qutip.entropy_vn(dm.ptrace(0)) + qutip.entropy_vn(dm.ptrace(1))) assert abs(qutip.entropy_mutual(dm, [0], [1]) - expect) < 1e-13