Skip to content

Instantly share code, notes, and snippets.

@wangleiphy
Created May 3, 2015 19:43
Show Gist options
  • Save wangleiphy/b7346ebe3cd877b1cb49 to your computer and use it in GitHub Desktop.
Save wangleiphy/b7346ebe3cd877b1cb49 to your computer and use it in GitHub Desktop.
#here we generate a Ham and simulate the weight to see if they are negative
from numpy import array, bmat, zeros , dot , diag , eye, ones , sort , prod
from numpy.random import rand
from scipy.linalg import det , expm, eig , logm
import numpy as np
np.set_printoptions(suppress=True, precision=2, linewidth=100)
def build_Ham(n):
B = (rand(n/2, n/2)-0.5)*4.
Ham = bmat([[zeros((n/2,n/2),float), B], [B.transpose(), zeros((n/2,n/2),float)]])
return Ham
Ns = 6 #size of the A matrix
N = 4 #number of the A matrices
for itry in range(1):
tmp = expm(build_Ham(Ns))
for i in range(N):
tmp = dot( expm(build_Ham(Ns)) , tmp)
res = eye(Ns) + tmp
print "det(1+e^{A}...e^{A}): ", det(res) #>=0 according to the conjecture
M = logm(tmp)
print "M = log(e^{A}...e^{A}):\n", M
w, v = eig(M)
print "eig(M): ", w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment