Skip to content

Instantly share code, notes, and snippets.

View wangleiphy's full-sized avatar

Lei Wang wangleiphy

View GitHub Profile
@wangleiphy
wangleiphy / spinglass.jl
Last active July 19, 2020 07:33
spin glass ground state energy and entropy
using Yao, LinearAlgebra
# define tropical numbers with the following property.
# x ⊕ y := max(x ,y)
# x ⊗ y := x + y
struct Tropical{T} <: Number
n::T
c::T
end
Tropical(x::Real) = Tropical(x,one(x))
#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):
from numpy import bmat, zeros , array , eye , dot
from scipy.linalg import det , expm
B1 = array([[2, 1, 1, 3, 2],
[1, 2, 1, 3, 1],
[2, 3, 1, 2, 2],
[1, 3, 1, 3, 1],
[2, 3, 3, 1, 3]]
)