Index: trunk/Ohana/src/opihi/cmd.data/fft1d.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/fft1d.c	(revision 7917)
+++ trunk/Ohana/src/opihi/cmd.data/fft1d.c	(revision 16094)
@@ -3,6 +3,5 @@
 int fft1d (int argc, char **argv) {
   
-  int i, Npix, ZeroImaginary;
-  float *t1, *t2, *temp;
+  int Npix, Nbit, ZeroImaginary;
   Vector *Ire, *Iim, *Ore, *Oim;
 
@@ -19,7 +18,6 @@
   }    
   if ((Ire = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
-  if ((Ore = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE);
-  if ((Oim = SelectVector (argv[5], ANYVECTOR, TRUE)) == NULL) return (FALSE);
-
+  
+  // check the input data (match lengths? binary length?)
   Npix = Ire[0].Nelements;
   if (!ZeroImaginary && (Npix != Iim[0].Nelements)) {
@@ -27,28 +25,14 @@
     return (FALSE);
   }
-
-  if (!IsBinary (Npix)) {
+  if (!IsBinary (Npix, &Nbit)) {
     gprint (GP_ERR, "Npix is not a binary number!\n");
     return (FALSE);
   }
-  
-  ALLOCATE (temp, float, 2*Npix);
-  if (ZeroImaginary) {
-    t1 = Ire[0].elements;
-    for (i = 0; i < Npix; i++, t1++) {
-      temp[2*i  ] = *t1;
-      temp[2*i+1] = 0;
-    }
-  } else {
-    t1 = Ire[0].elements;
-    t2 = Iim[0].elements;
-    for (i = 0; i < Npix; i++, t1++, t2++) {
-      temp[2*i  ] = *t1;
-      temp[2*i+1] = *t2;
-    }
-  }    
-    
-  fft (temp, Npix, 1); 
 
+  // select or create the output vectors
+  if ((Ore = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE);
+  if ((Oim = SelectVector (argv[5], ANYVECTOR, TRUE)) == NULL) return (FALSE);
+
+  // allocate sufficient output space
   Ore[0].Nelements = Npix;
   Oim[0].Nelements = Npix;
@@ -56,15 +40,16 @@
   REALLOCATE (Oim[0].elements, float, Npix);
  
-  t1 = Ore[0].elements;
-  t2 = Oim[0].elements;
-  for (i = 0; i < Npix; i++, t1++, t2++) {
-    *t1 = temp[2*i  ] / Npix;
-    *t2 = temp[2*i+1] / Npix;
+  // copy data to output vectors (fft is done in place)
+  memcpy (Ore[0].elements, Ire[0].elements, Npix*sizeof(float));
+
+  // copy imaginary vector or create a zero vector
+  if (ZeroImaginary) {
+    memset (Oim[0].elements, 0, Npix*sizeof(float));
+  } else {
+    memcpy (Oim[0].elements, Iim[0].elements, Npix*sizeof(float));
   }    
-  
-  free (temp);
+
+  fft (Ore[0].elements, Oim[0].elements, Npix, Nbit); 
   
   return (TRUE);
 }
-
-  
