Index: /trunk/psLib/test/dataManip/tst_psMinimize05.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMinimize05.c	(revision 1799)
+++ /trunk/psLib/test/dataManip/tst_psMinimize05.c	(revision 1799)
@@ -0,0 +1,83 @@
+/*****************************************************************************
+    This routine must ensure that psMinimizePowell() works correctly.
+ *****************************************************************************/
+#include <stdio.h>
+#include "pslib.h"
+#include "psTest.h"
+#include <math.h>
+#define N 2
+#define MIN_VALUE 20.0
+#define NUM_PARAMS 10
+float expectedParm[NUM_PARAMS];
+
+/*****************************************************************************
+myFunc(): This routine subtracts the associate value in expectedParm[] from
+each parameter and then squares it, then sums that for all parameters, then
+adds MIN_VALUE to it.  The minimum for this function will be MIN_VALUE, and
+will occur when each parameter equals the associated value in expectedParm[].
+ *****************************************************************************/
+float myFunc(psVector *myParams,
+             psArray *myCoords)
+{
+    float sum = 0.0;
+    int i;
+
+    sum = 0.0;
+    for (i=0;i<NUM_PARAMS;i++) {
+        sum+= (myParams->data.F32[i] - expectedParm[i]) * (myParams->data.F32[i] - expectedParm[i]);
+    }
+    sum = MIN_VALUE + (sum * sum);
+
+    return(sum);
+}
+
+
+int main()
+{
+    int currentId = psMemGetId();
+    int testStatus = true;
+    int memLeaks = 0;
+    int i = 0;
+    psArray *myCoords;
+    psVector *myParams;
+    psVector *myParamMask;
+    psMinimization *min;
+
+    psTraceSetLevel(".psLib", 0);
+    /**************************************************************************
+     *************************************************************************/
+    myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32);
+    myParamMask = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32);
+    min = psMinimizationAlloc(100, 0.01);
+
+    myCoords = psArrayAlloc(N);
+    for (i=0;i<N;i++) {
+        myCoords->data[i] = (psPTR *) psVectorAlloc(2, PS_TYPE_F32);
+        ((psVector *) (myCoords->data[i]))->data.F32[0] = (float) i;
+        ((psVector *) (myCoords->data[i]))->data.F32[1] = (float) i;
+    }
+    for (i=0;i<NUM_PARAMS;i++) {
+        expectedParm[i] = 2.32 + (float) (2 * i);
+        myParams->data.F32[i] = 0.0;
+        myParamMask->data.U8[i] = 0;
+    }
+
+    psMinimizePowell(min, myParams, myParamMask, myCoords, (psMinimizePowellFunc) myFunc);
+    printf("\nThe minimum is %f (expected: %f)\n", min->value, MIN_VALUE);
+    for (i=0;i<NUM_PARAMS;i++) {
+        printf("Parameter %d at the minimum is %f (expected: %f)\n", i,
+               myParams->data.F32[i], expectedParm[i]);
+    }
+
+    psFree(myCoords);
+    psFree(myParams);
+    psFree(myParamMask);
+    psFree(min);
+
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+    return (!testStatus);
+}
