From help-octave-request at bevo dot che dot wisc dot edu Mon May 11 12:20:40 1998 Subject: Does your machine also FFT like mine? From: "John W. Eaton" To: wskdpl at pukrs12 dot puk dot ac dot za Cc: help-octave at bevo dot che dot wisc dot edu Date: Mon, 11 May 1998 12:19:23 -0500 (CDT) On 11-May-1998, Dirk Laurie wrote: | Encouraged by the prompt responses to my plot question -- thanks | everyone! -- let me rephrase the FFT one to which nobody replied. | | On my Linux/586 machine, I get | | > ifft(fft([1 1 0 0 1])) | ans = | 1.0000e+00 1.0000e+00 -1.4682e-08 -1.4682e-08 1.0000e+00 | | This is only single precision accurate. Unfortunately the other | machines I have access to have the same architecture and use the | same binary and not surprisingly gives the same result. | | What happens on your machine? I was getting the same as you, but then I made the following changes and the problem seems to be fixed. :-) For people who are using g77 and tried this test and got the double precision accuracy, what version of g77 do you have? I think the problem is that older versions of g77 (I am using 0.5.19.1) handle things like double precision foo data foo /3.14159265358979/ by first constructing a single precision number (if you just look at the number, there is nothing to tell you that it should be double), then initializing the double variable foo with that. I seem to remember some heated debates on comp.lang.fortran about what the proper interpretation should be. In any case, I'd guess that g77's default behavior has changed. (Or were people who got the more accurate result were using f2c?) In any case, we can force double precision constants anyway, so I did that for the next release of Octave by making the changes below. If you apply this patch, be sure to also remove the libcruft.a file to ensure that the new .o files are inserted (there is a small problem with the libcruft makefiles, but fixing it would make the default build process much slower). Thanks, jwe *** libcruft/fftpack/passb3.f.orig Thu Jul 18 20:29:15 1996 --- libcruft/fftpack/passb3.f Mon May 11 12:03:13 1998 *************** *** 2,8 **** implicit double precision (a-h,o-z) dimension cc(ido,3,l1) ,ch(ido,l1,3) , 1 wa1(1) ,wa2(1) ! data taur,taui /-.5,.866025403784439/ if (ido .ne. 2) go to 102 do 101 k=1,l1 tr2 = cc(1,2,k)+cc(1,3,k) --- 2,8 ---- implicit double precision (a-h,o-z) dimension cc(ido,3,l1) ,ch(ido,l1,3) , 1 wa1(1) ,wa2(1) ! data taur,taui /-.5,.866025403784439d0/ if (ido .ne. 2) go to 102 do 101 k=1,l1 tr2 = cc(1,2,k)+cc(1,3,k) *** libcruft/fftpack/passb5.f.orig Thu Jul 18 20:29:15 1996 --- libcruft/fftpack/passb5.f Mon May 11 12:03:13 1998 *************** *** 2,9 **** implicit double precision (a-h,o-z) dimension cc(ido,5,l1) ,ch(ido,l1,5) , 1 wa1(1) ,wa2(1) ,wa3(1) ,wa4(1) ! data tr11,ti11,tr12,ti12 /.309016994374947,.951056516295154, ! 1-.809016994374947,.587785252292473/ if (ido .ne. 2) go to 102 do 101 k=1,l1 ti5 = cc(2,2,k)-cc(2,5,k) --- 2,9 ---- implicit double precision (a-h,o-z) dimension cc(ido,5,l1) ,ch(ido,l1,5) , 1 wa1(1) ,wa2(1) ,wa3(1) ,wa4(1) ! data tr11,ti11,tr12,ti12 /.309016994374947d0,.951056516295154d0, ! 1-.809016994374947d0,.587785252292473d0/ if (ido .ne. 2) go to 102 do 101 k=1,l1 ti5 = cc(2,2,k)-cc(2,5,k) *** libcruft/fftpack/passf3.f.orig Thu Jul 18 20:29:15 1996 --- libcruft/fftpack/passf3.f Mon May 11 12:03:13 1998 *************** *** 2,8 **** implicit double precision (a-h,o-z) dimension cc(ido,3,l1) ,ch(ido,l1,3) , 1 wa1(1) ,wa2(1) ! data taur,taui /-.5,-.866025403784439/ if (ido .ne. 2) go to 102 do 101 k=1,l1 tr2 = cc(1,2,k)+cc(1,3,k) --- 2,8 ---- implicit double precision (a-h,o-z) dimension cc(ido,3,l1) ,ch(ido,l1,3) , 1 wa1(1) ,wa2(1) ! data taur,taui /-.5d0,-.866025403784439d0/ if (ido .ne. 2) go to 102 do 101 k=1,l1 tr2 = cc(1,2,k)+cc(1,3,k) *** libcruft/fftpack/passf5.f.orig Thu Jul 18 20:29:15 1996 --- libcruft/fftpack/passf5.f Mon May 11 12:03:13 1998 *************** *** 2,9 **** implicit double precision (a-h,o-z) dimension cc(ido,5,l1) ,ch(ido,l1,5) , 1 wa1(1) ,wa2(1) ,wa3(1) ,wa4(1) ! data tr11,ti11,tr12,ti12 /.309016994374947,-.951056516295154, ! 1-.809016994374947,-.587785252292473/ if (ido .ne. 2) go to 102 do 101 k=1,l1 ti5 = cc(2,2,k)-cc(2,5,k) --- 2,9 ---- implicit double precision (a-h,o-z) dimension cc(ido,5,l1) ,ch(ido,l1,5) , 1 wa1(1) ,wa2(1) ,wa3(1) ,wa4(1) ! data tr11,ti11,tr12,ti12 /.309016994374947d0,-.951056516295154d0, ! 1-.809016994374947d0,-.587785252292473d0/ if (ido .ne. 2) go to 102 do 101 k=1,l1 ti5 = cc(2,2,k)-cc(2,5,k)