Index: trunk/psLib/src/image/psImageFFT.c
===================================================================
--- trunk/psLib/src/image/psImageFFT.c	(revision 1625)
+++ trunk/psLib/src/image/psImageFFT.c	(revision 1840)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-25 21:10:09 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-21 22:30:19 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -22,4 +22,6 @@
 #include "psImageExtraction.h"
 
+#include "psImageErrors.h"
+
 #define P_FFTW_PLAN_RIGOR FFTW_ESTIMATE
 
@@ -42,5 +44,10 @@
 
     if ((type != PS_TYPE_F32) && (type != PS_TYPE_C32)) {
-        psError(__func__, "Input image must be a 32-bit float or complex image (type=%d)", type);
+        char* typeStr;
+        PS_TYPE_NAME(typeStr,type);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
+                   PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_psImageFFT_IMAGE_TYPE_UNSUPPORTED,
+                   typeStr);
         psFree(out);
         return NULL;
@@ -48,5 +55,10 @@
 
     if (type != PS_TYPE_C32 && direction == PS_FFT_REVERSE) {
-        psError(__func__, "Input image must be complex image for reverse FFT (type=%d).", type);
+        char* typeStr;
+        PS_TYPE_NAME(typeStr,type);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
+                   PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_psImageFFT_REVERSE_NOT_COMPLEX,
+                   typeStr);
         psFree(out);
         return NULL;
@@ -55,5 +67,10 @@
 
     if (type != PS_TYPE_F32 && direction == PS_FFT_FORWARD) {
-        psError(__func__, "Input image must be real image for forward FFT (type=%d).", type);
+        char* typeStr;
+        PS_TYPE_NAME(typeStr,type);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
+                   PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_psImageFFT_FORWARD_NOT_REAL,
+                   typeStr);
         psFree(out);
         return NULL;
@@ -69,13 +86,15 @@
     numCols = in->numCols;
 
+    // n.b. FFTW can perform a in-place transform at the same or faster than out-of-place.
     out = psImageCopy(out, in, PS_TYPE_C32);
-
     plan = fftwf_plan_dft_2d(numCols, numRows,
                              (fftwf_complex *) out->data.C32[0],
                              (fftwf_complex *) out->data.C32[0], direction, P_FFTW_PLAN_RIGOR);
 
-    /* check if a plan exists now */
+    /* check if a plan exists now -- if not, it is a real problem */
     if (plan == NULL) {
-        psError(__func__, "Failed to create FFTW plan.");
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
+                   PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_psImageFFT_FFTW_PLAN_NULL);
         psFree(out);
         return NULL;
@@ -106,9 +125,6 @@
     numRows = in->numRows;
 
-    /* if not a complex number, this is logically just a copy */
-    if (!PS_IS_PSELEMTYPE_COMPLEX(type)) {
-        // Warn user, as this is probably not expected
-        psLogMsg(__func__, PS_LOG_WARN, "Real portion of a non-Complex type called called for. "
-                 "Just an image copy was performed.");
+    /* if not a complex number, this is logically just a copy then */
+    if (!PS_IS_PSELEMTYPE_COMPLEX(type) && type != PS_TYPE_PTR) {
         return psImageCopy(out, in, type);
     }
@@ -141,5 +157,11 @@
         }
     } else {
-        psError(__func__, "Can not extract real component from given image type (%d).", type);
+        char* typeStr;
+        PS_TYPE_NAME(typeStr,type);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReal",
+                   PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                   typeStr);
+
         psFree(out);
         return NULL;
@@ -164,9 +186,6 @@
     numRows = in->numRows;
 
-    /* if not a complex number, this is logically just zeroed image of same size */
-    if (!PS_IS_PSELEMTYPE_COMPLEX(type)) {
-        // Warn user, as this is probably not expected
-        psLogMsg(__func__, PS_LOG_WARN, "Imaginary portion of a non-Complex type called for. "
-                 "A zero image was returned.");
+    /* if not a complex image type, this is logically just zeroed image of same size */
+    if (!PS_IS_PSELEMTYPE_COMPLEX(type) && type != PS_TYPE_PTR) {
         out = psImageRecycle(out, numCols, numRows, type);
         memset(out->data.V[0], 0, PSELEMTYPE_SIZEOF(type) * numCols * numRows);
@@ -201,5 +220,10 @@
         }
     } else {
-        psError(__func__, "Can not extract imaginary component from given image type (%d).", type);
+        char* typeStr;
+        PS_TYPE_NAME(typeStr,type);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageImaginary",
+                   PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                   typeStr);
         psFree(out);
         return NULL;
@@ -225,5 +249,12 @@
 
     if (imag->type.type != type) {
-        psError(__func__, "The inputs to psImageComplex must be the same type.");
+        char* typeStrReal;
+        char* typeStrImag;
+        PS_TYPE_NAME(typeStrReal,type);
+        PS_TYPE_NAME(typeStrImag,imag->type.type);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex",
+                   PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_psImageFFT_REAL_IMAG_TYPE_MISMATCH,
+                   typeStrReal,typeStrImag);
         psFree(out);
         return NULL;
@@ -231,17 +262,8 @@
 
     if (imag->numCols != numCols || imag->numRows != numRows) {
-        psError(__func__, "The inputs to psImageComplex must be the same dimensions.");
-        psFree(out);
-        return NULL;
-    }
-
-    if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
-        psError(__func__, "The inputs to psImageComplex can not be complex.");
-        psFree(out);
-        return NULL;
-    }
-
-    if (type != PS_TYPE_F32 && type != PS_TYPE_F64) {
-        psError(__func__, "The input type to psImageComplex must be a floating point.");
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex",
+                   PS_ERR_BAD_PARAMETER_VALUE, true,
+                   PS_ERRORTEXT_psImageFFT_REAL_IMAG_SIZE_MISMATCH,
+                   numCols, numRows, imag->numCols, imag->numRows);
         psFree(out);
         return NULL;
@@ -280,8 +302,14 @@
         }
     } else {
-        psError(__func__, "Can not merge real and imaginary portions for given image type (%d).", type);
-        psFree(out);
-        return NULL;
-    }
+        char* typeStr;
+        PS_TYPE_NAME(typeStr,type);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex",
+                   PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_psImageFFT_NONREAL_NOTSUPPORTED,
+                   typeStr);
+        psFree(out);
+        return NULL;
+    }
+
 
     return out;
@@ -303,9 +331,6 @@
     numRows = in->numRows;
 
-    /* if not a complex number, this is logically just a image copy */
-    if (!PS_IS_PSELEMTYPE_COMPLEX(type)) {
-        // Warn user, as this is probably not expected
-        psLogMsg(__func__, PS_LOG_WARN, "Complex Conjugate of a non-Complex type called for. "
-                 "Image copy was performed instead.");
+    /* if not a complex image, this is logically just a image copy */
+    if (!PS_IS_PSELEMTYPE_COMPLEX(type) && type != PS_TYPE_PTR) {
         return psImageCopy(out, in, type);
     }
@@ -338,5 +363,10 @@
         }
     } else {
-        psError(__func__, "Can not compute complex conjugate for given image type (%d).", type);
+        char* typeStr;
+        PS_TYPE_NAME(typeStr,type);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConjugate",
+                   PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED,
+                   typeStr);
         psFree(out);
         return NULL;
@@ -362,11 +392,4 @@
     numRows = in->numRows;
     numElementsSquared = numCols * numCols * numRows * numRows;
-
-    /* if not a complex number, this is not implemented */
-    if (!PS_IS_PSELEMTYPE_COMPLEX(type)) {
-        psError(__func__, "Power Spectrum for non-complex inputs is not implemented.");
-        psFree(out);
-        return NULL;
-    }
 
     if (type == PS_TYPE_C32) {
@@ -405,10 +428,15 @@
         }
     } else {
-        psError(__func__, "Can not power spectrum for given image type (%d).", type);
-        psFree(out);
-        return NULL;
-    }
-
-    return out;
-
-}
+        char* typeStr;
+        PS_TYPE_NAME(typeStr,type);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePowerSpectrum",
+                   PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED,
+                   typeStr);
+        psFree(out);
+        return NULL;
+    }
+
+    return out;
+
+}
