Index: trunk/psLib/test/dataManip/tst_psMatrix04.c
===================================================================
--- trunk/psLib/test/dataManip/tst_psMatrix04.c	(revision 2392)
+++ trunk/psLib/test/dataManip/tst_psMatrix04.c	(revision 2686)
@@ -10,9 +10,9 @@
  *     E)  Attempt to use null input image argument
  *     F)  Attempt to use null input float argument
- *  
+ *
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-11-22 21:00:21 $
+ *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-12-10 19:59:49 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -23,15 +23,30 @@
 #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("Matrix values at element %d, %d don't agree %f vs %lf\n", i, j,                  \
+                       IMAGE->data.F32[i][j], truthMatrix[i][j]);                                        \
+            }                                                                                            \
+        }                                                                                                \
+    }                                                                                                    \
 }
 
+#define CHECK_VALUE(VALUE)                                                                                   \
+if(fabs(VALUE-truthValue) > TOLERANCE) {                                                                     \
+    printf("Values don't agree %lf vs %lf\n", VALUE, truthValue);                                            \
+}
 
-psS32 main(psS32 argc,
-           char* argv[])
+psS32 main(psS32 argc, char* argv[])
 {
     float det = 0.0f;
@@ -40,4 +55,12 @@
     psImage *inImage = NULL;
     psImage *tempImage = NULL;
+    psImage *outImage32 = NULL;
+    psImage *inImage32 = NULL;
+    psImage *tempImage32 = NULL;
+
+    double truthMatrix[3][3] = {{4.0000000, -4.333333, -2.333333},
+                                {-1.000000,  1.666667,  0.666667},
+                                {-1.000000,  0.666667,  0.666667}};
+    double truthValue = 3.0;
 
 
@@ -55,5 +78,16 @@
     inImage->data.F64[2][1] =  5;
     inImage->data.F64[2][2] =  7;
-    PRINT_MATRIX(inImage);
+
+    outImage32 = (psImage*)psImageAlloc(3, 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] =  3;
+    inImage32->data.F32[1][0] =  0;
+    inImage32->data.F32[1][1] =  1;
+    inImage32->data.F32[1][2] = -1;
+    inImage32->data.F32[2][0] =  3;
+    inImage32->data.F32[2][1] =  5;
+    inImage32->data.F32[2][2] =  7;
     printFooter(stdout, "psMatrix", "Create input and output images", true);
 
@@ -63,12 +97,21 @@
     tempImage = outImage;
     outImage = psMatrixInvert(outImage, inImage, &det);
-    PRINT_MATRIX(outImage);
-    printf("\ndet = %f\n", det);
+    CHECK_MATRIX(outImage);
+    CHECK_VALUE(det);
     if(outImage->type.dimen != PS_DIMEN_IMAGE) {
         printf("Error: Resulting image is not PS_DIMEN_IMAGE\n");
-    } else
-        if(outImage != tempImage) {
-            printf("Error: Return pointer not equal to output argument pointer\n");
-        }
+    } else if(outImage != tempImage) {
+        printf("Error: Return pointer not equal to output argument pointer\n");
+    }
+    det = 0.0f;
+    tempImage32 = outImage32;
+    outImage32 = psMatrixInvert(outImage32, inImage32, &det);
+    CHECK_MATRIX(outImage32);
+    CHECK_VALUE(det);
+    if(outImage32->type.dimen != PS_DIMEN_IMAGE) {
+        printf("Error: Resulting image is not PS_DIMEN_IMAGE\n");
+    } else if(outImage32 != tempImage32) {
+        printf("Error: Return pointer not equal to output argument pointer\n");
+    }
     printFooter(stdout, "psMatrix", "Invert matrix and calculate determinant", true);
 
@@ -77,5 +120,9 @@
     printPositiveTestHeader(stdout, "psMatrix", "Calculate determinant only");
     det2 = psMatrixDeterminant(inImage);
-    printf("det = %f\n", *det2);
+    CHECK_VALUE(*det2);
+    psFree(det2);
+    det2 = psMatrixDeterminant(inImage32);
+    CHECK_VALUE(*det2);
+    psFree(det2);
     printFooter(stdout, "psMatrix", "Calculate determinant only", true);
 
@@ -85,5 +132,6 @@
     psFree(outImage);
     psFree(inImage);
-    psFree(det2);
+    psFree(outImage32);
+    psFree(inImage32);
     if(psMemCheckLeaks(0, NULL, stdout, false) != 0 ) {
         psError(PS_ERR_UNKNOWN,true,"Memory leaks detected.");
