realft input/output data format


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

Allan
11-21-2006, 01:12 AM
My second question is on the input format of four1

If my data is real, say from 0.0 to 3.0 with increament 1.0.

Then do I have to put data as:
(0.0,0.0,0.0,1.0,0.0,2.0,0.0,3.0) so that tell four1 the imaginary part is 0?

Do I have a simple way as my input, sth like (0,1,3,4)?

Thanks a lot!

avenjl
12-15-2006, 02:52 AM
Good question. This may be the problem that I am having as well with their code.