-
Notifications
You must be signed in to change notification settings - Fork 0
/
quietstart.f90
143 lines (111 loc) · 2.58 KB
/
quietstart.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
module quietstart
use zone
implicit none
CONTAINS
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
real(kind=8) function bit_reversing( n )
integer :: n, deci, k, div
real(kind=8) :: miroir
!a = 0
k = 25
miroir = 0.d0
deci = n
if (deci > 33554432) then
print*,'too big > 33554432=2**25'
stop
else
do while (k >= 0)
div = 2**k
if (deci/div == 1) then
! a = a + 10**k
miroir = miroir + 2.**(-k-1)
deci = deci - div
endif
k = k-1
enddo
endif
bit_reversing = miroir
end function bit_reversing
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
real(kind=8) function trinary_reversing( n )
integer :: deci, k, div, n
real(kind=8) :: miroir
!a = 0
k = 16
miroir = 0.d0
deci = n
if (deci > 43046721) then
print*,' too big > 43046721=3**16 '
stop
else
do while (k >= 0)
div = 3**k
if (deci/div == 1) then
! a = a + 10**k
miroir = miroir + 3.**(-k-1)
deci = deci - div
else if (deci/div == 2) then
! a = a + 2 * 10**k
miroir = miroir + 2 * 3.**(-k-1)
deci = deci - 2 * div
endif
k = k-1
enddo
endif
trinary_reversing = miroir
end function trinary_reversing
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
real(kind=8) function penta_reversing( n )
integer :: deci, k, div, n
real(kind=8) :: miroir
!a = 0
k = 11
miroir = 0.d0
deci = n
if (deci > 48828125) then
print*,'too big > 48828125=5**11'
stop
else
do while (k >= 0)
div = 5**k
if (deci/div == 1) then
! a = a + 10**k
miroir = miroir + 5.**(-k-1)
deci = deci - div
else if (deci/div == 2) then
! a = a + 2 * 10**k
miroir = miroir + 2 * 5.**(-k-1)
deci = deci - 2 * div
else if (deci/div == 3) then
! a = a + 3 * 10**k
miroir = miroir + 3 * 5.**(-k-1)
deci = deci - 3 * div
else if (deci/div == 4) then
! a = a + 4 * 10**k
miroir = miroir + 4 * 5.**(-k-1)
deci = deci - 4 * div
endif
k = k-1
enddo
endif
penta_reversing = miroir
end function penta_reversing
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine dichotomie_x( a, b, R, eps )
! il faut D(a)<R<D(b), on cherche x tq R=D(x), resu dans a
real(kind = prec) :: a, b, R, eps, x, D
D = ( kx*a + alpha * sin(kx*a) ) / (2*pi)
do while ( D<R-eps .or. D>R+eps )
x = (a+b)/2
D = ( kx*x + alpha * sin(kx*x) ) / (2*pi)
if ( D<R-eps ) then
a = x
else if ( D>R+eps ) then
b = x
else
a = x
endif
end do
end subroutine dichotomie_x
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end module quietstart