Skip to content

Commit

Permalink
Merge pull request #142 from issp-center-dev/correct_float64
Browse files Browse the repository at this point in the history
correct numpy dtypes
  • Loading branch information
yomichi authored Feb 22, 2023
2 parents 237db8a + 91cc138 commit 57027e6
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 60 deletions.
4 changes: 2 additions & 2 deletions doc/tutorial/en/source/zero_temperature/vector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ For example, the following python function (``samples/tutorial-1.7/read_gs.py``)
with open(filename, "rb") as f:
f.read(4)
nelems = unpack("L", f.read(8))[0]
ret = np.zeros(nelems, dtype=np.complex)
ret = np.zeros(nelems, dtype=np.complex128)
f.read(16)
for i in range(nelems):
re = unpack("d", f.read(8))[0]
im = unpack("d", f.read(8))[0]
ret[i] = np.complex(re, im)
ret[i] = complex(re, im)
return ret

Exercise
Expand Down
4 changes: 2 additions & 2 deletions samples/tutorial_1.5/CalcSq.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def func_input(list_lat):
#[e] initialize

#[s] allocate
Sq = np.zeros([Lx+1,Ly+1],dtype=np.float)
Sq_err = np.zeros([Lx+1,Ly+1],dtype=np.float)
Sq = np.zeros([Lx+1,Ly+1],dtype=np.float64)
Sq_err = np.zeros([Lx+1,Ly+1],dtype=np.float64)
#[e] allocate
max_num = 1
for num_cg in range(0,max_num):
Expand Down
4 changes: 2 additions & 2 deletions samples/tutorial_1.7/read_gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def read_gs(*, index=0, rank=0):
with open(filename, "rb") as f:
f.read(4)
nelems = unpack("L", f.read(8))[0]
ret = np.zeros(nelems, dtype=np.complex)
ret = np.zeros(nelems, dtype=np.complex128)
f.read(16)
for i in range(nelems):
re = unpack("d", f.read(8))[0]
im = unpack("d", f.read(8))[0]
ret[i] = np.complex(re, im)
ret[i] = complex(re, im)
return ret
2 changes: 1 addition & 1 deletion samples/tutorial_2.1/Finite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
data = f.read()
data = data.split("\n")
max_eigen = len(data)-1
Energy = np.zeros([max_eigen],dtype=np.float)
Energy = np.zeros([max_eigen],dtype=np.float64)
print("max_eigen= ", max_eigen)
#[s] count not empty elements
cnt = 0
Expand Down
38 changes: 19 additions & 19 deletions samples/tutorial_2.1/Norm_TPQ.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def mainBasic(num_sample,dir_Norm):

phys_Z,phys_Ene,phys_Ene2,phys_Sz,phys_Sz2,phys_InvTemp = CalcBasic(Norm,Ene,Ene2,Sz,Sz2,InvTemp,tpq_type)

log_Z = np.zeros([num_step],dtype=np.float)
log_Z = np.zeros([num_step],dtype=np.float64)
with open("%s/Norm.dat" % (dir_Norm),'w') as f:
tmp_log_Z = -math.log(Norm[0][0])
for k in range(0,num_step):
Expand Down Expand Up @@ -79,14 +79,14 @@ def read_file(num_sample):
data = f.read()
data = data.split("\n")
num_step = int(len(data)-2)
Norm = np.zeros([num_sample,num_step],dtype=np.float)
InvTemp = np.zeros([num_sample,num_step],dtype=np.float)
Ene = np.zeros([num_sample,num_step],dtype=np.float)
Ene2 = np.zeros([num_sample,num_step],dtype=np.float)
Spc = np.zeros([num_sample,num_step],dtype=np.float)
Sz = np.zeros([num_sample,num_step],dtype=np.float)
Sz2 = np.zeros([num_sample,num_step],dtype=np.float)
chi = np.zeros([num_sample,num_step],dtype=np.float)
Norm = np.zeros([num_sample,num_step],dtype=np.float64)
InvTemp = np.zeros([num_sample,num_step],dtype=np.float64)
Ene = np.zeros([num_sample,num_step],dtype=np.float64)
Ene2 = np.zeros([num_sample,num_step],dtype=np.float64)
Spc = np.zeros([num_sample,num_step],dtype=np.float64)
Sz = np.zeros([num_sample,num_step],dtype=np.float64)
Sz2 = np.zeros([num_sample,num_step],dtype=np.float64)
chi = np.zeros([num_sample,num_step],dtype=np.float64)

for cnt_samp in range(num_sample):
in_file = "output/Norm_rand%d.dat" % (cnt_samp)
Expand Down Expand Up @@ -136,12 +136,12 @@ def CalcBasic(Norm,Ene,Ene2,Sz,Sz2,InvTemp,tpq_type):
num_sample = Norm.shape[0]
num_step = Norm.shape[1]
print(num_step)
phys_InvTemp = np.zeros([num_sample,num_step],dtype=np.float)
phys_Z = np.zeros([num_sample,num_step],dtype=np.float)
phys_Ene = np.zeros([num_sample,num_step],dtype=np.float)
phys_Ene2 = np.zeros([num_sample,num_step],dtype=np.float)
phys_Sz = np.zeros([num_sample,num_step],dtype=np.float)
phys_Sz2 = np.zeros([num_sample,num_step],dtype=np.float)
phys_InvTemp = np.zeros([num_sample,num_step],dtype=np.float64)
phys_Z = np.zeros([num_sample,num_step],dtype=np.float64)
phys_Ene = np.zeros([num_sample,num_step],dtype=np.float64)
phys_Ene2 = np.zeros([num_sample,num_step],dtype=np.float64)
phys_Sz = np.zeros([num_sample,num_step],dtype=np.float64)
phys_Sz2 = np.zeros([num_sample,num_step],dtype=np.float64)
#NB: cnt_samp=0, Z is always 1
for k in range(0,num_step):
phys_Z[0][k] = 1.0
Expand Down Expand Up @@ -214,7 +214,7 @@ def CalcPhys(IPL_Z,IPL_InvTemp,Phys,tpq_type):
num_step = Phys.shape[1]
num_phys = Phys.shape[2]
print(num_sample,num_step,num_phys)
Norm_Phys = np.zeros([num_sample,num_step,num_phys],dtype=np.float)
Norm_Phys = np.zeros([num_sample,num_step,num_phys],dtype=np.float64)
for k in range(0,num_step):
for cnt_phys in range(0,num_phys):
Norm_Phys[0][k][cnt_phys] = Phys[0][k][cnt_phys]
Expand Down Expand Up @@ -255,7 +255,7 @@ def read_phys(num_sample,dir_Phys,header):
num_phys = len(tmp)
print(num_step)
print(num_phys)
Phys = np.zeros([num_sample,num_step,num_phys],dtype=np.float)
Phys = np.zeros([num_sample,num_step,num_phys],dtype=np.float64)

for cnt_samp in range(num_sample):
in_file = "%s/%s_set%d.dat" % (dir_Phys,header,cnt_samp)
Expand All @@ -278,8 +278,8 @@ def read_Norm(num_sample,dir_Norm):
data = data.split("\n")
num_step = int(len(data)-2)
print("num_step=",num_step)
IPL_Z = np.zeros([num_sample,num_step],dtype=np.float)
IPL_InvTemp = np.zeros([num_sample,num_step],dtype=np.float)
IPL_Z = np.zeros([num_sample,num_step],dtype=np.float64)
IPL_InvTemp = np.zeros([num_sample,num_step],dtype=np.float64)

for cnt_samp in range(num_sample):
in_file = "%s/TPQ_%d.dat" % (dir_Norm,cnt_samp)
Expand Down
2 changes: 1 addition & 1 deletion samples/tutorial_2.2/Finite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
data = f.read()
data = data.split("\n")
max_eigen = len(data)-1
Energy = np.zeros([max_eigen],dtype=np.float)
Energy = np.zeros([max_eigen],dtype=np.float64)
print("max_eigen= ", max_eigen)
#[s] count not empty elements
cnt = 0
Expand Down
42 changes: 21 additions & 21 deletions test/Ave_SS.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ def main():
#[e] read modpara

#
Ref_ave_Temp = np.zeros([max_eigen],dtype=np.float)
Ref_err_Temp = np.zeros([max_eigen],dtype=np.float)
Ref_ave_Ene = np.zeros([max_eigen],dtype=np.float)
Ref_err_Ene = np.zeros([max_eigen],dtype=np.float)
Ref_ave_Temp = np.zeros([max_eigen],dtype=np.float64)
Ref_err_Temp = np.zeros([max_eigen],dtype=np.float64)
Ref_ave_Ene = np.zeros([max_eigen],dtype=np.float64)
Ref_err_Ene = np.zeros([max_eigen],dtype=np.float64)
#
ave_Temp = np.zeros([max_eigen],dtype=np.float)
err_Temp = np.zeros([max_eigen],dtype=np.float)
ave_Temp = np.zeros([max_eigen],dtype=np.float64)
err_Temp = np.zeros([max_eigen],dtype=np.float64)
#
InvTemp = np.zeros([max_set,max_eigen],dtype=np.float)
ave_InvTemp = np.zeros([max_eigen],dtype=np.float)
err_InvTemp = np.zeros([max_eigen],dtype=np.float)
Ene = np.zeros([max_set,max_eigen],dtype=np.float)
ave_Ene = np.zeros([max_eigen],dtype=np.float)
err_Ene = np.zeros([max_eigen],dtype=np.float)
Ene2 = np.zeros([max_set,max_eigen],dtype=np.float)
ave_Ene2 = np.zeros([max_eigen],dtype=np.float)
err_Ene2 = np.zeros([max_eigen],dtype=np.float)
InvTemp = np.zeros([max_set,max_eigen],dtype=np.float64)
ave_InvTemp = np.zeros([max_eigen],dtype=np.float64)
err_InvTemp = np.zeros([max_eigen],dtype=np.float64)
Ene = np.zeros([max_set,max_eigen],dtype=np.float64)
ave_Ene = np.zeros([max_eigen],dtype=np.float64)
err_Ene = np.zeros([max_eigen],dtype=np.float64)
Ene2 = np.zeros([max_set,max_eigen],dtype=np.float64)
ave_Ene2 = np.zeros([max_eigen],dtype=np.float64)
err_Ene2 = np.zeros([max_eigen],dtype=np.float64)
#
Spc = np.zeros([max_set,max_eigen],dtype=np.float)
ave_Spc = np.zeros([max_eigen],dtype=np.float)
err_Spc = np.zeros([max_eigen],dtype=np.float)
Ent = np.zeros([max_set,max_eigen-1],dtype=np.float)
ave_Ent = np.zeros([max_eigen-1],dtype=np.float)
err_Ent = np.zeros([max_eigen-1],dtype=np.float)
Spc = np.zeros([max_set,max_eigen],dtype=np.float64)
ave_Spc = np.zeros([max_eigen],dtype=np.float64)
err_Spc = np.zeros([max_eigen],dtype=np.float64)
Ent = np.zeros([max_set,max_eigen-1],dtype=np.float64)
ave_Ent = np.zeros([max_eigen-1],dtype=np.float64)
err_Ent = np.zeros([max_eigen-1],dtype=np.float64)
#

for cnt_set in range(0,max_set):
Expand Down
18 changes: 9 additions & 9 deletions tool/ExpertSpin/MakeDef.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
All_N = max_site
#[e] set input.
#[s] interaction
Ising = np.zeros([max_site,max_site],dtype=np.float)
Exchange = np.zeros([max_site,max_site],dtype=np.float)
PairLift = np.zeros([max_site,max_site],dtype=np.float)
InterAll = np.zeros([max_site,2,max_site,2,max_site,2,max_site,2],dtype=np.complex)
Ising = np.zeros([max_site,max_site],dtype=np.float64)
Exchange = np.zeros([max_site,max_site],dtype=np.float64)
PairLift = np.zeros([max_site,max_site],dtype=np.float64)
InterAll = np.zeros([max_site,2,max_site,2,max_site,2,max_site,2],dtype=np.complex128)
#[e] interaction
#[s] read pair.txt
siteI = np.zeros([num],dtype=np.int)
siteJ = np.zeros([num],dtype=np.int)
intT1 = np.zeros([num],dtype=np.unicode)
intT2 = np.zeros([num],dtype=np.unicode)
para = np.zeros([num],dtype=np.double)
siteI = np.zeros([num],dtype=np.int64)
siteJ = np.zeros([num],dtype=np.int64)
intT1 = np.zeros([num],dtype=np.unicode_)
intT2 = np.zeros([num],dtype=np.unicode_)
para = np.zeros([num],dtype=np.float64)
read.func_readpair(tmp_sdt,siteI,siteJ,intT1,intT2,para)
#[e] read pair.txt

Expand Down
2 changes: 1 addition & 1 deletion tool/FiniteT/Finite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
data = f.read()
data = data.split("\n")
max_eigen = len(data)-1
Energy = np.zeros([max_eigen],dtype=np.float)
Energy = np.zeros([max_eigen],dtype=np.float64)
print("max_eigen= ", max_eigen)
#[s] count not empty elements
cnt = 0
Expand Down
4 changes: 2 additions & 2 deletions tool/ForSq/CalcSq.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#[e] initialize

#[s] allocate
Sq = np.zeros([Lx+1,Ly+1],dtype=np.float)
Sq_err = np.zeros([Lx+1,Ly+1],dtype=np.float)
Sq = np.zeros([Lx+1,Ly+1],dtype=np.float64)
Sq_err = np.zeros([Lx+1,Ly+1],dtype=np.float64)
#[e] allocate
max_num = 1
for num_cg in range(0,max_num):
Expand Down

0 comments on commit 57027e6

Please # to comment.