-
Notifications
You must be signed in to change notification settings - Fork 0
/
dedekind_eta_function.f90
119 lines (97 loc) · 3.19 KB
/
dedekind_eta_function.f90
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
module dedekind_eta_function
USE typedef
implicit none
complex(kind=dpc) :: tau_stored,eta_stored,log_eta_stored
logical :: eta_set=.FALSE.
private
public dedekind_eta
public log_dedekind_eta
contains
complex(KIND=dpc) function dedekind_eta(tau) result(eta)
complex(KIND=dpc), intent(IN) :: tau
eta = do_dedekind_eta(tau,.false.)
end function dedekind_eta
complex(KIND=C_DOUBLE_COMPLEX) function log_dedekind_eta(tau) result(eta) bind(c)
use ISO_C_BINDING
complex(KIND=C_DOUBLE_COMPLEX), intent(IN) :: tau
eta = do_dedekind_eta(tau,.true.)
end function log_dedekind_eta
complex(KIND=dpc) function do_dedekind_eta(tau,logged) result(eta)
!!Comptes the eta_function if needed
!!If already computed lopoks it up
complex(KIND=dpc), intent(IN) :: tau
logical, intent(IN) :: logged
if(eta_set)then
!write(*,*) 'Eta already set'
if(tau_stored.eq.tau)then
!write(*,*) 'with correct tau'
!!Set eta to the strored one
if(logged)then
eta=log_eta_stored
else
eta=eta_stored
end if
else
!write(*,*) 'with wrong tau'
eta=compute_store_eta(tau,logged)
end if
else
!write(*,*) 'Eta not set'
eta=compute_store_eta(tau,logged)
end if
end function do_dedekind_eta
complex(KIND=dpc) function compute_store_eta(tau,logged) result(eta)
complex(KIND=dpc), intent(IN) :: tau
logical, intent(IN) :: logged
!!Compute eta and store the value
!write(*,*) 'Compute and store with tau=',tau
eta=dedekind_eta_compute(tau)
eta_set=.TRUE.
eta_stored=eta
tau_stored=tau
log_eta_stored=log(eta)
if(logged)then
eta=log(eta)
end if
end function compute_store_eta
complex(KIND=dpc) function dedekind_eta_compute(tau) result(eta)
!!Computes the dedekind eta function
complex(KIND=dpc), intent(IN) :: tau
if(aimag(tau).ge.1.d0)then
eta=do_dedekind_eta_compute(tau)
else
eta=sqrt(iunit/tau)*do_dedekind_eta_compute(-1.d0/tau)
end if
end function dedekind_eta_compute
complex(KIND=dpc) function do_dedekind_eta_compute(tau) result(eta)
!!Computes the dedekind eta function
complex(KIND=dpc), intent(IN) :: tau
complex(KIND=dpc) :: q,q24 !The nome
complex(KIND=dpc) :: increment !!
integer :: n !!Incerement index
!!Eta start
!write(*,*) 'tau in:',tau
q=exp(iunit*2*pi*tau) !!The nome
q24=exp(iunit*pi*tau/12) !!A 24th of the nome
eta=1.d0+0*iunit
!write(*,*) 'Nome;',q
!write(*,*) 'Nome/24;',q24
n=1
do
!write(*,*) 'n=',n
increment = (-1)**n * (q**(((n**2)*3+n)/2)+q**(((n**2)*3-n)/2))
!write(*,*) 'increment:',increment
!write(*,*) 'quotient:',increment/eta
eta = eta+increment
!write(*,*) 'eta_n:',eta
!!if((abs(increment/eta)).lt.(1d-30))then
if((eta-increment).eq.eta)then
!write(*,*) 'DONE'
exit !! the quotient is small enought
end if
n=n+1
end do
eta=eta*q24
!write(*,*) 'eta out:',eta
end function do_dedekind_eta_compute
end module dedekind_eta_function