Index: trunk/psLib/test/dataManip/tst_psMatrix03.c
===================================================================
--- trunk/psLib/test/dataManip/tst_psMatrix03.c	(revision 2392)
+++ trunk/psLib/test/dataManip/tst_psMatrix03.c	(revision 2683)
@@ -14,6 +14,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.10 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-11-22 21:00:21 $
+ *  @version $Revision: 1.11 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-12-10 19:11:23 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -24,20 +24,41 @@
 #include "psTest.h"
 
-#define PRINT_MATRIX(IMAGE)                     \
-for(psS32 i=IMAGE->numRows-1; i>-1; i--) {        \
-    for(psS32 j=0; j<IMAGE->numCols; j++) {       \
-        printf("%f ", IMAGE->data.F64[i][j]);   \
-    }                                           \
-    printf("\n");                               \
+#define TOLERANCE 0.000001
+
+#define CHECK_MATRIX(IMAGE)                                                                                  \
+for(psU32 i=0; i<IMAGE->numRows; i++) {                                                                  \
+    for(psU32 j=0; j<IMAGE->numCols; j++) {                                                              \
+        if(IMAGE->type.type == PS_TYPE_F64) {                                                            \
+            if(fabs(IMAGE->data.F64[i][j]-truthMatrix[i][j]) > TOLERANCE) {                              \
+                printf("Matrix values at element %d, %d don't agree %lf vs %lf\n", i, j,                 \
+                       IMAGE->data.F64[i][j], truthMatrix[i][j]);                                        \
+            }                                                                                            \
+        } else if(IMAGE->type.type == PS_TYPE_F32){                                                      \
+            if(fabs(IMAGE->data.F32[i][j]-truthMatrix[i][j]) > TOLERANCE) {                              \
+                printf("%lf\n", fabs(IMAGE->data.F32[i][j]-truthMatrix[i][j])),                              \
+                printf("Matrix values at element %d, %d don't agree %f vs %lf\n", i, j,                  \
+                       IMAGE->data.F32[i][j], truthMatrix[i][j]);                                        \
+            }                                                                                            \
+        }                                                                                                \
+    }                                                                                                    \
 }
-\
-#define PRINT_VECTOR(VECTOR)                    \
-for(psS32 i=0; i<VECTOR->n; i++) {                \
-    printf("%f\n", VECTOR->data.F64[i]);        \
+
+#define CHECK_VECTOR(VECTOR)                                                                                 \
+for(psU32 i=0; i<VECTOR->n; i++) {                                                                       \
+    if(VECTOR->type.type == PS_TYPE_F64) {                                                               \
+        if(fabs(VECTOR->data.F64[i]-truthVector[i]) > TOLERANCE) {                                       \
+            printf("Vector values at element %d don't agree %lf vs %lf\n", i,                            \
+                   VECTOR->data.F64[i], truthVector[i]);                                                 \
+        }                                                                                                \
+    } else if(VECTOR->type.type == PS_TYPE_F32){                                                         \
+        if(fabs(VECTOR->data.F32[i]-truthVector[i]) > TOLERANCE) {                                       \
+            printf("Vector values at element %d don't agree %f vs %lf\n", i,                             \
+                   VECTOR->data.F32[i], truthVector[i]);                                                 \
+        }                                                                                                \
+    }                                                                                                    \
 }
 
 
-psS32 main(psS32 argc,
-           char* argv[])
+psS32 main(psS32 argc, char* argv[])
 {
     psImage *luImage = NULL;
@@ -48,4 +69,21 @@
     psVector *outVector = NULL;
     psVector *inVector = NULL;
+    psImage *luImage32 = NULL;
+    psImage *inImage32 = NULL;
+    psImage *tempImage32 = NULL;
+    psVector *tempVector32 = NULL;
+    psVector *perm32 = NULL;
+    psVector *outVector32 = NULL;
+    psVector *inVector32 = NULL;
+
+    double truthVector[3] = {
+                                4.000000,
+                                -2.000000,
+                                3.000000
+                            };
+
+    double truthMatrix[3][3] = {{4.000000,  5.000000,  6.000000},
+                                {0.750000, -2.750000, -6.500000},
+                                {0.500000, -0.545455, -0.545455}};
 
 
@@ -70,7 +108,22 @@
     inVector->data.F64[2] =  4.0;
     inVector->n = 3;
-    PRINT_MATRIX(inImage);
-    printf("\n");
-    PRINT_VECTOR(inVector);
+    luImage32 = (psImage*)psImageAlloc(3, 3, PS_TYPE_F32);
+    perm32 = (psVector*)psVectorAlloc(3, PS_TYPE_F32);
+    outVector32 = (psVector*)psVectorAlloc(3, PS_TYPE_F32);
+    inVector32 = (psVector*)psVectorAlloc(3, PS_TYPE_F32);
+    inImage32 = (psImage*)psImageAlloc(3, 3, PS_TYPE_F32);
+    inImage32->data.F32[0][0] =  2;
+    inImage32->data.F32[0][1] =  4;
+    inImage32->data.F32[0][2] =  6;
+    inImage32->data.F32[1][0] =  4;
+    inImage32->data.F32[1][1] =  5;
+    inImage32->data.F32[1][2] =  6;
+    inImage32->data.F32[2][0] =  3;
+    inImage32->data.F32[2][1] =  1;
+    inImage32->data.F32[2][2] = -2;
+    inVector32->data.F32[0] = 18.0;
+    inVector32->data.F32[1] = 24.0;
+    inVector32->data.F32[2] =  4.0;
+    inVector32->n = 3;
     printFooter(stdout, "psMatrix", "Create input and output images and vectors", true);
 
@@ -80,11 +133,19 @@
     tempImage = luImage;
     luImage = psMatrixLUD(luImage, perm, inImage);
-    PRINT_MATRIX(luImage);
+    CHECK_MATRIX(luImage);
     if(luImage->type.dimen != PS_DIMEN_IMAGE) {
         printf("Error: Resulting image is not PS_DIMEN_IMAGE\n");
-    } else
-        if(luImage != tempImage) {
-            printf("Error: Return pointer not equal to output argument pointer\n");
-        }
+    } else if(luImage != tempImage) {
+        printf("Error: Return pointer not equal to output argument pointer\n");
+    }
+
+    tempImage32 = luImage32;
+    luImage32 = psMatrixLUD(luImage32, perm32, inImage32);
+    CHECK_MATRIX(luImage32);
+    if(luImage32->type.dimen != PS_DIMEN_IMAGE) {
+        printf("Error: Resulting image is not PS_DIMEN_IMAGE\n");
+    } else if(luImage32 != tempImage32) {
+        printf("Error: Return pointer not equal to output argument pointer\n");
+    }
     printFooter(stdout, "psMatrix", "Calculate LU matrix", true);
 
@@ -94,11 +155,19 @@
     tempVector = outVector;
     outVector = psMatrixLUSolve(outVector, luImage, inVector, perm);
-    PRINT_VECTOR(outVector);
+    CHECK_VECTOR(outVector);
     if(outVector->type.dimen != PS_DIMEN_VECTOR) {
         printf("Error: Resulting image is not PS_DIMEN_VECTOR\n");
-    } else
-        if(outVector != tempVector) {
-            printf("Error: Return pointer not equal to output argument pointer\n");
-        }
+    } else if(outVector != tempVector) {
+        printf("Error: Return pointer not equal to output argument pointer\n");
+    }
+
+    tempVector32 = outVector32;
+    outVector32 = psMatrixLUSolve(outVector32, luImage32, inVector32, perm32);
+    CHECK_VECTOR(outVector32);
+    if(outVector32->type.dimen != PS_DIMEN_VECTOR) {
+        printf("Error: Resulting image is not PS_DIMEN_VECTOR\n");
+    } else if(outVector32 != tempVector32) {
+        printf("Error: Return pointer not equal to output argument pointer\n");
+    }
     printFooter(stdout, "psMatrix", "Determine solution to matrix equation", true);
 
@@ -111,4 +180,9 @@
     psFree(outVector);
     psFree(inVector);
+    psFree(inImage32);
+    psFree(luImage32);
+    psFree(perm32);
+    psFree(outVector32);
+    psFree(inVector32);
     if( psMemCheckLeaks(0, NULL, stdout, false) ) {
         psError(PS_ERR_UNKNOWN,true,"Memory leaks detected");
