-
Notifications
You must be signed in to change notification settings - Fork 0
/
realft.f90
68 lines (58 loc) · 1.39 KB
/
realft.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
module m_realft
contains
! REALFT
! taken from numerical recipes (see book for further information)
! subroutines called:
! NONE
SUBROUTINE REALFT(DATA,N,ISIGN)
use m_four1
common /vocal/ ivocal
REAL*8 WR,WI,WPR,WPI,WTEMP,THETA
real*8 DATA(*)
real*8 H1R, H1I, H2R, H2I
THETA=6.28318530717959D0/2.0D0/DBLE(N)
C1=0.5
IF (ISIGN.EQ.1) THEN
C2=-0.5
CALL FOUR1(DATA,N,+1)
ELSE
C2=0.5
THETA=-THETA
ENDIF
WPR=-2.0D0*DSIN(0.5D0*THETA)**2
WPI=DSIN(THETA)
WR=1.0D0+WPR
WI=WPI
N2P3=2*N+3
DO 11 I=2,N/2+1
I1=2*I-1
I2=I1+1
I3=N2P3-I2
I4=I3+1
WRS=SNGL(WR)
WIS=SNGL(WI)
H1R=C1*(DATA(I1)+DATA(I3))
H1I=C1*(DATA(I2)-DATA(I4))
H2R=-C2*(DATA(I2)+DATA(I4))
H2I=C2*(DATA(I1)-DATA(I3))
DATA(I1)=H1R+WRS*H2R-WIS*H2I
DATA(I2)=H1I+WRS*H2I+WIS*H2R
DATA(I3)=H1R-WRS*H2R+WIS*H2I
DATA(I4)=-H1I+WRS*H2I+WIS*H2R
WTEMP=WR
WR=WR*WPR-WI*WPI+WR
WI=WI*WPR+WTEMP*WPI+WI
11 CONTINUE
IF (ISIGN.EQ.1) THEN
H1R=DATA(1)
DATA(1)=H1R+DATA(2)
DATA(2)=H1R-DATA(2)
ELSE
H1R=DATA(1)
DATA(1)=C1*(H1R+DATA(2))
DATA(2)=C1*(H1R-DATA(2))
CALL FOUR1(DATA,N,-1)
ENDIF
RETURN
END subroutine
end module m_realft