]> hackdaworld.org Git - my-code/api.git/commitdiff
improved "clever way" method - seems to work now .. strange it didnt before!
authorhackbard <hackbard>
Fri, 8 Oct 2004 10:06:09 +0000 (10:06 +0000)
committerhackbard <hackbard>
Fri, 8 Oct 2004 10:06:09 +0000 (10:06 +0000)
fourier/fourier.c

index 9f810ecef37084d7d0bd4e17291688236b611752..89f42c24ce8b132c9d22cbb23646dad95eeac827 100644 (file)
@@ -220,22 +220,22 @@ int fourier_dft_2d(t_fourier *fourier) {
   }
   //  dft on index 2 of 'index 1 transformed data'
   for(x=0;x<X;x++) {
-    off_f=0;
+    off_f=x;
     for(v=0;v<Y;v++) {
       //dprintf(fourier->outfd,"[fourier] (u=%d,v=%d)\n",v,x);
-      off_r=0;
+      off_r=x;
       for(y=0;y<Y;y++) {
         arg=-2.0*M_PI*v*y/Y;
-        fourier->ftdata[off_f+x].r+=(cos(arg)*data[off_r+x].r-sin(arg)*data[off_r+x].i);
-        fourier->ftdata[off_f+x].r+=(sin(arg)*data[off_r+x].r+cos(arg)*data[off_r+x].i);
+        fourier->ftdata[off_f].r+=(cos(arg)*data[off_r].r-sin(arg)*data[off_r].i);
+        fourier->ftdata[off_f].r+=(sin(arg)*data[off_r].r+cos(arg)*data[off_r].i);
         off_r+=X;
       }
-      fourier->ftdata[off_f+x].r/=Y;
-      fourier->ftdata[off_f+x].i/=Y;
+      fourier->ftdata[off_f].r/=Y;
+      fourier->ftdata[off_f].i/=Y;
       off_f+=X;
     }
   }
-
   free(data);
 
   return F_SUCCESS;