File size: 1,138 Bytes
1c703f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
Compute density of states.
"""
import torch
import torch as tr
import matplotlib.pyplot as plt

from evaluate_chebyshev import chepyshev_evaluate_m
from fast_math.tensor_init import init_vrand


from memory_profiler import profile
import time


@profile()
def test_ham(t, eps, dim):
    ham = tr.zeros(size=(dim, dim), dtype=tr.complex128)
    for i in range(dim):
        ham[i][i] = eps
        if i < dim - 1:
            ham[i][i + 1] = t
        if i > 0:
            ham[i][i - 1] = t

    return ham

#
# n = 10 ** 4 + 5000  # dimension of the problem
# t = 2  # t value hiper. of hamiltonian
# eps0 = 0.3  # t value hiper. of hamiltonian7
# m = 10  # cut of if the Chebyshev polinomials
#
#
# cp_t_ = []
# i_pow=[1,2,3,4, 5, 10, 100, 200, 300,500, 1000, 1500, 2000, 2100]
# for i in i_pow:
#     n=10*i
#     phi_ = init_vrand(n)
#     ham = test_ham(t=t, eps=eps0, dim=n)
#
#     start = time.time()
#     cp = chepyshev_evaluate_m(phi_l=phi_, phi_r=phi_, ham=ham, m_limit=m)
#     end = time.time()
#     cp_t = end - start
#     print("i_pow:",i)
#     print("cp:", cp)
#     print("time:", cp_t)
#     cp_t_.append(cp_t)