Index: trunk/psLib/src/fft/psVectorFFT.c
===================================================================
--- trunk/psLib/src/fft/psVectorFFT.c	(revision 1864)
+++ trunk/psLib/src/fft/psVectorFFT.c	(revision 2080)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-23 18:31:49 $
+ *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-13 20:46:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,38 +43,4 @@
     type = in->type.type;
 
-    if ((type != PS_TYPE_F32) && (type != PS_TYPE_C32)) {
-        char* typeStr;
-        PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_IMAGE_TYPE_UNSUPPORTED,
-                   typeStr);
-        psFree(out);
-        return NULL;
-    }
-
-    if ((type != PS_TYPE_C32) && (direction == PS_FFT_REVERSE)) {
-        char* typeStr;
-        PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_REVERSE_NOT_COMPLEX,
-                   typeStr);
-        psFree(out);
-        return NULL;
-
-    }
-
-    if ((type != PS_TYPE_F32) && (direction == PS_FFT_FORWARD)) {
-        char* typeStr;
-        PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_FORWARD_NOT_REAL,
-                   typeStr);
-        psFree(out);
-        return NULL;
-    }
-
     /* make sure the system-level wisdom information is imported. */
     if (!p_fftwWisdomImported) {
@@ -85,27 +51,22 @@
     numElements = in->n;
 
-    out = psVectorRecycle(out, numElements, PS_TYPE_C32);
+    out = psVectorCopy(out, in, PS_TYPE_C32);
     out->n = numElements;
 
-    if (type == PS_TYPE_F32) {
-        // need to convert to complex
-        psC32* outVec = out->data.C32;
-        psF32* inVec = in->data.F32;
-
-        for (unsigned int i = 0; i < numElements; i++) {
-            outVec[i] = inVec[i];
-        }
-    } else {
-        psC32* outVec = out->data.C32;
-        psC32* inVec = in->data.C32;
-
-        for (unsigned int i = 0; i < numElements; i++) {
-            outVec[i] = inVec[i];
-        }
-    }
-
-    plan = fftwf_plan_dft_1d(numElements,
-                             (fftwf_complex *) out->data.C32,
-                             (fftwf_complex *) out->data.C32, direction, P_FFTW_PLAN_RIGOR);
+    if ((direction & PS_FFT_FORWARD) != 0) {
+        plan = fftwf_plan_dft_1d(numElements,
+                                 (fftwf_complex *) out->data.C32,
+                                 (fftwf_complex *) out->data.C32, FFTW_FORWARD, P_FFTW_PLAN_RIGOR);
+    } else if ((direction & PS_FFT_REVERSE) != 0) {
+        plan = fftwf_plan_dft_1d(numElements,
+                                 (fftwf_complex *) out->data.C32,
+                                 (fftwf_complex *) out->data.C32, FFTW_BACKWARD, P_FFTW_PLAN_RIGOR);
+    } else {
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
+                   PS_ERR_BAD_PARAMETER_VALUE, true,
+                   PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET);
+        psFree(out);
+        return NULL;
+    }
 
     /* check if a plan exists now */
@@ -122,4 +83,12 @@
 
     fftwf_destroy_plan(plan);
+
+    if ((direction & PS_FFT_REAL_RESULT) != 0) {
+        for (int i = 0; i < numElements; i++) {
+            out->data.F32[i] = out->data.C32[i];
+        }
+        out->type.type = PS_TYPE_F32;
+        out->data.V = psRealloc(out->data.V,PSELEMTYPE_SIZEOF(PS_TYPE_F32)*out->nalloc);
+    }
 
     return out;
