Procedure REALFT(var DATA:array of real; N, ISIGN:integer);
var
I,I1,I2,I3,I4,N2P3:integer;
WR,WI,C1,C2,THETA,WPR,WPI,WIS,WRS,WRI,H1R,H1I,H2R,H2I,WTEMP:real;
begin
THETA:=6.28318530717959 / 2 / N;
C1:=0.5;
If ISIGN = 1 Then
begin
C2:=-0.5;
FOUR1(DATA, N, 1);
end
Else
begin
C2:=0.5;
THETA:=-THETA;
end;
WPR:=-2* Sqr(Sin(0.5 * THETA));
WPI:=Sin(THETA);
WR:=1 + WPR;
WI:=WPI;
N2P3:= 2 * N + 3;
For I:=2 To (N div 2) + 1 do
begin
I1:=2 * I - 1;
I2:=I1 + 1;
I3:=N2P3 - I2;
I4:=I3 + 1;
WRS:=WR;
WIS:=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 * WRI + WR;
WI:=WI * WPR + WTEMP * WPI + WI;
end;
If ISIGN = 1 Then
begin
H1R:=DATA[1];
DATA[1]:=H1R + DATA[2];
DATA[2]:=H1R - DATA[2];
end
Else
begin
H1R:=DATA[1];
DATA[1]:=C1 * (H1R + DATA[2]);
DATA[2]:=C1 * (H1R - DATA[2]);
FOUR1(DATA, N, -1);
end;
end;