Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#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
You can’t perform that action at this time.