Index: /trunk/psLib/src/Makefile.Globals
===================================================================
--- /trunk/psLib/src/Makefile.Globals	(revision 1007)
+++ /trunk/psLib/src/Makefile.Globals	(revision 1008)
@@ -5,6 +5,6 @@
 ##  Assumptions:    Variable "prefix" already defined
 ##
-##  $Revision: 1.9 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-05-28 20:26:49 $
+##  $Revision: 1.10 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-06-12 01:33:16 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -26,4 +26,8 @@
 ifndef includedir
     export includedir = $(prefix)/include
+endif
+
+ifndef testbindir
+    export testbindir = $(prefix)/bin/test
 endif
 
Index: /trunk/psLib/src/collections/psVector.c
===================================================================
--- /trunk/psLib/src/collections/psVector.c	(revision 1007)
+++ /trunk/psLib/src/collections/psVector.c	(revision 1008)
@@ -8,6 +8,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-09 18:20:01 $
+ *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-12 01:33:16 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -145,8 +145,8 @@
     }
 
-    in->data.V = psRealloc(in->data.V,nalloc*PSELEMTYPE_SIZEOF(elemType));
+    in->data.V = psRealloc(in->data.V,nalloc*PSELEMTYPE_SIZEOF(type));
 
     in->n = 0;
-    in->type.type = elemType;
+    in->type.type = type;
     in->nalloc = nalloc;
 
Index: /trunk/psLib/src/dataManip/psFFT.c
===================================================================
--- /trunk/psLib/src/dataManip/psFFT.c	(revision 1007)
+++ /trunk/psLib/src/dataManip/psFFT.c	(revision 1008)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-02 23:29:21 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-12 01:33:16 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -448,5 +448,6 @@
     numElements = in->n;
 
-    out = psVectorRecycle(out, numElements, PS_TYPE_C32);
+    out = psVectorRecycle(out, PS_TYPE_C32, numElements);
+    out->n = numElements;
 
     if (type == PS_TYPE_F32) {
@@ -504,5 +505,6 @@
         psLogMsg(__func__,PS_LOG_WARN,"Real portion of a non-Complex type called called for. "
                  "Just a vector copy was performed.");
-        out = psVectorRecycle(out,numElements,type);
+        out = psVectorRecycle(out,type,numElements);
+        out->n = numElements;
         memcpy(out->data.V,in->data.V,numElements*PSELEMTYPE_SIZEOF(type));
         return out;
@@ -513,5 +515,6 @@
         psC32* inVec = in->data.C32;
 
-        out = psVectorRecycle(out,numElements,PS_TYPE_F32);
+        out = psVectorRecycle(out,PS_TYPE_F32,numElements);
+        out->n = numElements;
         outVec = out->data.F32;
 
@@ -547,5 +550,6 @@
         psLogMsg(__func__,PS_LOG_WARN,"Imaginary portion of a non-Complex type called for. "
                  "A zeroed vector was returned.");
-        out = psVectorRecycle(out,numElements,type);
+        out = psVectorRecycle(out,type,numElements);
+        out->n = numElements;
         memset(out->data.V,0,PSELEMTYPE_SIZEOF(type)*numElements);
         return out;
@@ -556,5 +560,6 @@
         psC32* inVec = in->data.C32;
 
-        out = psVectorRecycle(out,numElements, PS_TYPE_F32);
+        out = psVectorRecycle(out,PS_TYPE_F32,numElements);
+        out->n = numElements;
         outVec = out->data.F32;
 
@@ -579,4 +584,5 @@
 
     if (real == NULL || imag == NULL) {
+        psVectorFree(out);
         return NULL;
     }
@@ -591,4 +597,5 @@
     if (imag->type.type != type) {
         psError(__func__,"The inputs to psVectorComplex must be the same type.");
+        psVectorFree(out);
         return NULL;
     }
@@ -596,4 +603,5 @@
     if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"The inputs to psVectorComplex can not be complex.");
+        psVectorFree(out);
         return NULL;
     }
@@ -604,5 +612,6 @@
         psF32* imagVec = imag->data.F32;
 
-        out = psVectorRecycle(out,numElements, PS_TYPE_C32);
+        out = psVectorRecycle(out,PS_TYPE_C32,numElements);
+        out->n = numElements;
         outVec = out->data.C32;
 
@@ -639,5 +648,6 @@
                  "Vector copy was performed instead.");
 
-        out = psVectorRecycle(out,numElements,type);
+        out = psVectorRecycle(out,type,numElements);
+        out->n = numElements;
         memcpy(out->data.V,in->data.V,PSELEMTYPE_SIZEOF(type)*numElements);
         return out;
@@ -648,5 +658,6 @@
         psC32* inVec = in->data.C32;
 
-        out = psVectorRecycle(out,numElements,PS_TYPE_C32);
+        out = psVectorRecycle(out,PS_TYPE_C32, numElements);
+        out->n = numElements;
         outVec = out->data.C32;
 
@@ -667,18 +678,24 @@
 {
     psElemType type;
-    unsigned int numElements;
-    int numElementsSquared;
+    unsigned int outNumElements;
+    unsigned int inNumElements;
+    unsigned int inHalfNumElements;
+    unsigned int inNumElementsSquared;
 
     if (in == NULL) {
-        return NULL;
-    }
-
-    type = in->type.type;
-    numElements = in->n;
-    numElementsSquared = numElements*numElements;
+        psVectorFree(out);
+        return NULL;
+    }
+
+    type = in->type.type;
+    inNumElements = in->n;
+    inNumElementsSquared = inNumElements*inNumElements;
+    inHalfNumElements = inNumElements/2;
+    outNumElements = inHalfNumElements+1;
 
     /* 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.");
+        psVectorFree(out);
         return NULL;
     }
@@ -687,16 +704,25 @@
         psF32* outVec;
         psC32* inVec = in->data.C32;
-        psF32 real;
-        psF32 imag;
-
-
-        out = psVectorRecycle(out,numElements,PS_TYPE_F32);
+        psF32 inAbs1;
+        psF32 inAbs2;
+
+        out = psVectorRecycle(out,PS_TYPE_F32,outNumElements);
+        out->n = outNumElements;
         outVec = out->data.F32;
 
-        for (unsigned int i=0;i<numElements;i++) {
-            real = crealf(inVec[i]);
-            imag = cimagf(inVec[i]);
-            outVec[i] = (real*real+imag*imag)/numElementsSquared;
-        }
+        // from ADD: P_0 = |C_0|^2/N^2
+        inAbs1 = cabsf(inVec[0]);
+        outVec[0] = inAbs1*inAbs1/inNumElementsSquared;
+
+        // from ADD: P_j = (|C_j|^2+|C_N-j|^2)/N^2, where j = 1,2,...,(N/2-1)
+        for (unsigned int i=1;i<inHalfNumElements;i++) {
+            inAbs1 = cabsf(inVec[i]);
+            inAbs2 = cabsf(inVec[inNumElements-i]);
+            outVec[i] = (inAbs1*inAbs1+inAbs2*inAbs2)/inNumElementsSquared;
+        }
+
+        // from ADD: P_N/2 = |C_N/2|^2/N^2
+        inAbs1 = cabsf(inVec[inHalfNumElements]);
+        outVec[inHalfNumElements] = inAbs1*inAbs1/inNumElementsSquared;
     } else {
         psError(__func__,"Can not power spectrum for given vector type (%d).",
Index: /trunk/psLib/src/dataManip/psVectorFFT.c
===================================================================
--- /trunk/psLib/src/dataManip/psVectorFFT.c	(revision 1007)
+++ /trunk/psLib/src/dataManip/psVectorFFT.c	(revision 1008)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-02 23:29:21 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-12 01:33:16 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -448,5 +448,6 @@
     numElements = in->n;
 
-    out = psVectorRecycle(out, numElements, PS_TYPE_C32);
+    out = psVectorRecycle(out, PS_TYPE_C32, numElements);
+    out->n = numElements;
 
     if (type == PS_TYPE_F32) {
@@ -504,5 +505,6 @@
         psLogMsg(__func__,PS_LOG_WARN,"Real portion of a non-Complex type called called for. "
                  "Just a vector copy was performed.");
-        out = psVectorRecycle(out,numElements,type);
+        out = psVectorRecycle(out,type,numElements);
+        out->n = numElements;
         memcpy(out->data.V,in->data.V,numElements*PSELEMTYPE_SIZEOF(type));
         return out;
@@ -513,5 +515,6 @@
         psC32* inVec = in->data.C32;
 
-        out = psVectorRecycle(out,numElements,PS_TYPE_F32);
+        out = psVectorRecycle(out,PS_TYPE_F32,numElements);
+        out->n = numElements;
         outVec = out->data.F32;
 
@@ -547,5 +550,6 @@
         psLogMsg(__func__,PS_LOG_WARN,"Imaginary portion of a non-Complex type called for. "
                  "A zeroed vector was returned.");
-        out = psVectorRecycle(out,numElements,type);
+        out = psVectorRecycle(out,type,numElements);
+        out->n = numElements;
         memset(out->data.V,0,PSELEMTYPE_SIZEOF(type)*numElements);
         return out;
@@ -556,5 +560,6 @@
         psC32* inVec = in->data.C32;
 
-        out = psVectorRecycle(out,numElements, PS_TYPE_F32);
+        out = psVectorRecycle(out,PS_TYPE_F32,numElements);
+        out->n = numElements;
         outVec = out->data.F32;
 
@@ -579,4 +584,5 @@
 
     if (real == NULL || imag == NULL) {
+        psVectorFree(out);
         return NULL;
     }
@@ -591,4 +597,5 @@
     if (imag->type.type != type) {
         psError(__func__,"The inputs to psVectorComplex must be the same type.");
+        psVectorFree(out);
         return NULL;
     }
@@ -596,4 +603,5 @@
     if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"The inputs to psVectorComplex can not be complex.");
+        psVectorFree(out);
         return NULL;
     }
@@ -604,5 +612,6 @@
         psF32* imagVec = imag->data.F32;
 
-        out = psVectorRecycle(out,numElements, PS_TYPE_C32);
+        out = psVectorRecycle(out,PS_TYPE_C32,numElements);
+        out->n = numElements;
         outVec = out->data.C32;
 
@@ -639,5 +648,6 @@
                  "Vector copy was performed instead.");
 
-        out = psVectorRecycle(out,numElements,type);
+        out = psVectorRecycle(out,type,numElements);
+        out->n = numElements;
         memcpy(out->data.V,in->data.V,PSELEMTYPE_SIZEOF(type)*numElements);
         return out;
@@ -648,5 +658,6 @@
         psC32* inVec = in->data.C32;
 
-        out = psVectorRecycle(out,numElements,PS_TYPE_C32);
+        out = psVectorRecycle(out,PS_TYPE_C32, numElements);
+        out->n = numElements;
         outVec = out->data.C32;
 
@@ -667,18 +678,24 @@
 {
     psElemType type;
-    unsigned int numElements;
-    int numElementsSquared;
+    unsigned int outNumElements;
+    unsigned int inNumElements;
+    unsigned int inHalfNumElements;
+    unsigned int inNumElementsSquared;
 
     if (in == NULL) {
-        return NULL;
-    }
-
-    type = in->type.type;
-    numElements = in->n;
-    numElementsSquared = numElements*numElements;
+        psVectorFree(out);
+        return NULL;
+    }
+
+    type = in->type.type;
+    inNumElements = in->n;
+    inNumElementsSquared = inNumElements*inNumElements;
+    inHalfNumElements = inNumElements/2;
+    outNumElements = inHalfNumElements+1;
 
     /* 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.");
+        psVectorFree(out);
         return NULL;
     }
@@ -687,16 +704,25 @@
         psF32* outVec;
         psC32* inVec = in->data.C32;
-        psF32 real;
-        psF32 imag;
-
-
-        out = psVectorRecycle(out,numElements,PS_TYPE_F32);
+        psF32 inAbs1;
+        psF32 inAbs2;
+
+        out = psVectorRecycle(out,PS_TYPE_F32,outNumElements);
+        out->n = outNumElements;
         outVec = out->data.F32;
 
-        for (unsigned int i=0;i<numElements;i++) {
-            real = crealf(inVec[i]);
-            imag = cimagf(inVec[i]);
-            outVec[i] = (real*real+imag*imag)/numElementsSquared;
-        }
+        // from ADD: P_0 = |C_0|^2/N^2
+        inAbs1 = cabsf(inVec[0]);
+        outVec[0] = inAbs1*inAbs1/inNumElementsSquared;
+
+        // from ADD: P_j = (|C_j|^2+|C_N-j|^2)/N^2, where j = 1,2,...,(N/2-1)
+        for (unsigned int i=1;i<inHalfNumElements;i++) {
+            inAbs1 = cabsf(inVec[i]);
+            inAbs2 = cabsf(inVec[inNumElements-i]);
+            outVec[i] = (inAbs1*inAbs1+inAbs2*inAbs2)/inNumElementsSquared;
+        }
+
+        // from ADD: P_N/2 = |C_N/2|^2/N^2
+        inAbs1 = cabsf(inVec[inHalfNumElements]);
+        outVec[inHalfNumElements] = inAbs1*inAbs1/inNumElementsSquared;
     } else {
         psError(__func__,"Can not power spectrum for given vector type (%d).",
Index: /trunk/psLib/src/fft/psVectorFFT.c
===================================================================
--- /trunk/psLib/src/fft/psVectorFFT.c	(revision 1007)
+++ /trunk/psLib/src/fft/psVectorFFT.c	(revision 1008)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-02 23:29:21 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-12 01:33:16 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -448,5 +448,6 @@
     numElements = in->n;
 
-    out = psVectorRecycle(out, numElements, PS_TYPE_C32);
+    out = psVectorRecycle(out, PS_TYPE_C32, numElements);
+    out->n = numElements;
 
     if (type == PS_TYPE_F32) {
@@ -504,5 +505,6 @@
         psLogMsg(__func__,PS_LOG_WARN,"Real portion of a non-Complex type called called for. "
                  "Just a vector copy was performed.");
-        out = psVectorRecycle(out,numElements,type);
+        out = psVectorRecycle(out,type,numElements);
+        out->n = numElements;
         memcpy(out->data.V,in->data.V,numElements*PSELEMTYPE_SIZEOF(type));
         return out;
@@ -513,5 +515,6 @@
         psC32* inVec = in->data.C32;
 
-        out = psVectorRecycle(out,numElements,PS_TYPE_F32);
+        out = psVectorRecycle(out,PS_TYPE_F32,numElements);
+        out->n = numElements;
         outVec = out->data.F32;
 
@@ -547,5 +550,6 @@
         psLogMsg(__func__,PS_LOG_WARN,"Imaginary portion of a non-Complex type called for. "
                  "A zeroed vector was returned.");
-        out = psVectorRecycle(out,numElements,type);
+        out = psVectorRecycle(out,type,numElements);
+        out->n = numElements;
         memset(out->data.V,0,PSELEMTYPE_SIZEOF(type)*numElements);
         return out;
@@ -556,5 +560,6 @@
         psC32* inVec = in->data.C32;
 
-        out = psVectorRecycle(out,numElements, PS_TYPE_F32);
+        out = psVectorRecycle(out,PS_TYPE_F32,numElements);
+        out->n = numElements;
         outVec = out->data.F32;
 
@@ -579,4 +584,5 @@
 
     if (real == NULL || imag == NULL) {
+        psVectorFree(out);
         return NULL;
     }
@@ -591,4 +597,5 @@
     if (imag->type.type != type) {
         psError(__func__,"The inputs to psVectorComplex must be the same type.");
+        psVectorFree(out);
         return NULL;
     }
@@ -596,4 +603,5 @@
     if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"The inputs to psVectorComplex can not be complex.");
+        psVectorFree(out);
         return NULL;
     }
@@ -604,5 +612,6 @@
         psF32* imagVec = imag->data.F32;
 
-        out = psVectorRecycle(out,numElements, PS_TYPE_C32);
+        out = psVectorRecycle(out,PS_TYPE_C32,numElements);
+        out->n = numElements;
         outVec = out->data.C32;
 
@@ -639,5 +648,6 @@
                  "Vector copy was performed instead.");
 
-        out = psVectorRecycle(out,numElements,type);
+        out = psVectorRecycle(out,type,numElements);
+        out->n = numElements;
         memcpy(out->data.V,in->data.V,PSELEMTYPE_SIZEOF(type)*numElements);
         return out;
@@ -648,5 +658,6 @@
         psC32* inVec = in->data.C32;
 
-        out = psVectorRecycle(out,numElements,PS_TYPE_C32);
+        out = psVectorRecycle(out,PS_TYPE_C32, numElements);
+        out->n = numElements;
         outVec = out->data.C32;
 
@@ -667,18 +678,24 @@
 {
     psElemType type;
-    unsigned int numElements;
-    int numElementsSquared;
+    unsigned int outNumElements;
+    unsigned int inNumElements;
+    unsigned int inHalfNumElements;
+    unsigned int inNumElementsSquared;
 
     if (in == NULL) {
-        return NULL;
-    }
-
-    type = in->type.type;
-    numElements = in->n;
-    numElementsSquared = numElements*numElements;
+        psVectorFree(out);
+        return NULL;
+    }
+
+    type = in->type.type;
+    inNumElements = in->n;
+    inNumElementsSquared = inNumElements*inNumElements;
+    inHalfNumElements = inNumElements/2;
+    outNumElements = inHalfNumElements+1;
 
     /* 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.");
+        psVectorFree(out);
         return NULL;
     }
@@ -687,16 +704,25 @@
         psF32* outVec;
         psC32* inVec = in->data.C32;
-        psF32 real;
-        psF32 imag;
-
-
-        out = psVectorRecycle(out,numElements,PS_TYPE_F32);
+        psF32 inAbs1;
+        psF32 inAbs2;
+
+        out = psVectorRecycle(out,PS_TYPE_F32,outNumElements);
+        out->n = outNumElements;
         outVec = out->data.F32;
 
-        for (unsigned int i=0;i<numElements;i++) {
-            real = crealf(inVec[i]);
-            imag = cimagf(inVec[i]);
-            outVec[i] = (real*real+imag*imag)/numElementsSquared;
-        }
+        // from ADD: P_0 = |C_0|^2/N^2
+        inAbs1 = cabsf(inVec[0]);
+        outVec[0] = inAbs1*inAbs1/inNumElementsSquared;
+
+        // from ADD: P_j = (|C_j|^2+|C_N-j|^2)/N^2, where j = 1,2,...,(N/2-1)
+        for (unsigned int i=1;i<inHalfNumElements;i++) {
+            inAbs1 = cabsf(inVec[i]);
+            inAbs2 = cabsf(inVec[inNumElements-i]);
+            outVec[i] = (inAbs1*inAbs1+inAbs2*inAbs2)/inNumElementsSquared;
+        }
+
+        // from ADD: P_N/2 = |C_N/2|^2/N^2
+        inAbs1 = cabsf(inVec[inHalfNumElements]);
+        outVec[inHalfNumElements] = inAbs1*inAbs1/inNumElementsSquared;
     } else {
         psError(__func__,"Can not power spectrum for given vector type (%d).",
Index: /trunk/psLib/src/mathtypes/psVector.c
===================================================================
--- /trunk/psLib/src/mathtypes/psVector.c	(revision 1007)
+++ /trunk/psLib/src/mathtypes/psVector.c	(revision 1008)
@@ -8,6 +8,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-09 18:20:01 $
+ *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-12 01:33:16 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -145,8 +145,8 @@
     }
 
-    in->data.V = psRealloc(in->data.V,nalloc*PSELEMTYPE_SIZEOF(elemType));
+    in->data.V = psRealloc(in->data.V,nalloc*PSELEMTYPE_SIZEOF(type));
 
     in->n = 0;
-    in->type.type = elemType;
+    in->type.type = type;
     in->nalloc = nalloc;
 
