Allan
11-21-2006, 01:06 AM
Hi,
I can not get the same answer from realft and four1.
For example, in four1, I have data as (0., 0., 1.0, 0.0, 2.0, 0.0, 3.0, 0.0), then I call four1(data,4,1). I can get the correct answer, which are:
6.00000
0.
-2.00000
-2.00000
-2.00000
0.
-2.00000
2.00000
However, when I use realft, what I do is:
data = (0,1,2,3)
call realft(data,4,1)
what I got is as follows:
0.
2.00000
4.00000
6.00000
0.
0.
0.
0.
So the answer from realft is not correct. I think this is because the input format requirement on data that I don't know? Somebody may teach me this?
Really appreicate your help!
The coding I'm using is as follows:
program test_fft
complex testdata(4)
real testreal(8),treal(8)
do i=1,4
testreal(2*i-1) = i-1
testreal(2*i) = 0
enddo
write (*,*) '\n result of fft: \n'
call four1(testreal, 4,1)
do i=1,8
write (*,*) testreal(i)
enddo
write (*,*) '\n\n result of real\n'
do i=1,4
treal(i) = i-1
enddo
call realft(treal, 4,1)
do i=1,8
write (*,*) treal(i)
enddo
end
I can not get the same answer from realft and four1.
For example, in four1, I have data as (0., 0., 1.0, 0.0, 2.0, 0.0, 3.0, 0.0), then I call four1(data,4,1). I can get the correct answer, which are:
6.00000
0.
-2.00000
-2.00000
-2.00000
0.
-2.00000
2.00000
However, when I use realft, what I do is:
data = (0,1,2,3)
call realft(data,4,1)
what I got is as follows:
0.
2.00000
4.00000
6.00000
0.
0.
0.
0.
So the answer from realft is not correct. I think this is because the input format requirement on data that I don't know? Somebody may teach me this?
Really appreicate your help!
The coding I'm using is as follows:
program test_fft
complex testdata(4)
real testreal(8),treal(8)
do i=1,4
testreal(2*i-1) = i-1
testreal(2*i) = 0
enddo
write (*,*) '\n result of fft: \n'
call four1(testreal, 4,1)
do i=1,8
write (*,*) testreal(i)
enddo
write (*,*) '\n\n result of real\n'
do i=1,4
treal(i) = i-1
enddo
call realft(treal, 4,1)
do i=1,8
write (*,*) treal(i)
enddo
end