Index: trunk/psLib/test/math/tap_psMatrix02.c
===================================================================
--- trunk/psLib/test/math/tap_psMatrix02.c	(revision 13124)
+++ trunk/psLib/test/math/tap_psMatrix02.c	(revision 17567)
@@ -12,6 +12,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-05-02 04:20:06 $
+ *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2008-05-07 23:12:13 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -28,5 +28,5 @@
 {
     psLogSetFormat("HLNM");
-    plan_tests(11);
+    plan_tests(23);
 
     // Input pointer same as output pointer
@@ -34,9 +34,8 @@
     // a requirement.  However, we should probably fix the case where the input
     // image equals the output image.
-    if (0) {
+     {
         psMemId id = psMemGetId();
         psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
-        ok(psMatrixTranspose(inImage, inImage) == NULL, "psMatrixTranspose(): inImage = outImage results in NULL");
-        ok(psMemGetRefCounter(inImage) == 1, "psMatrixTranspose(): the output image was freed on an error.");
+        ok(psMatrixTranspose(inImage, inImage) == NULL, "psMatrixTranspose(): inImage == outImage results in NULL");
         psFree(inImage);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -50,26 +49,30 @@
         psImage *nullImage = NULL;
         psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
-        psMemIncrRefCounter(outImage);
         ok(psMatrixTranspose(outImage, nullImage) == NULL, "psMatrixTranspose(): inImage = NULL results in NULL return");
-        ok(psMemGetRefCounter(outImage) == 1, "psMatrixTranspose(): the output image was freed on an error.");
         psFree(outImage);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
 
-
     // Incorrect type for input pointer
-    // Merge with tap_psMatrix01.c, get rid of this test (redundant)
     {
         psMemId id = psMemGetId();
+        psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_U8);
         psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
-        psImage *badImage1 = (psImage*)psImageAlloc(3, 3, PS_TYPE_U8);
-        psMemIncrRefCounter(outImage);
-        ok(psMatrixTranspose(outImage, badImage1) == NULL, "psMatrixTranspose(): inImage = outImage results in NULL return");
-        ok(psMemGetRefCounter(outImage) == 1, "the output image was freed on the error.");
+        ok(psMatrixTranspose(outImage, inImage) == NULL, "psMatrixTranspose(): inImage wrong type (U8) results in NULL return");
         psFree(outImage);
-        psFree(badImage1);
+        psFree(inImage);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
 
+    // Incorrect type for input pointer
+    {
+        psMemId id = psMemGetId();
+        psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_S32);
+        psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
+        ok(psMatrixTranspose(outImage, inImage) == NULL, "psMatrixTranspose(): inImage wrong type (S32) results in NULL return");
+        psFree(outImage);
+        psFree(inImage);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
 
     // Incorrect type for output pointer
@@ -77,24 +80,51 @@
         psMemId id = psMemGetId();
         psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
-        psImage *badImage1 = (psImage*)psImageAlloc(3, 3, PS_TYPE_U8);
-        badImage1 = psMatrixTranspose(badImage1, inImage);
-        ok(badImage1 != NULL, "psMatrixTranspose() results in non-NULL return");
+        psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_U8);
+        outImage = psMatrixTranspose(outImage, inImage);
+        ok(outImage != NULL, "psMatrixTranspose() results in non-NULL return");
+
         // check that the type was changed.
-        ok(badImage1->type.type == PS_TYPE_F64, "the output type was changed to F64");
+        ok(outImage->type.type == PS_TYPE_F64, "the output type was changed to F64");
         psFree(inImage);
-        psFree(badImage1);
+        psFree(outImage);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
 
-
-    // Matrix not square for output pointer
-    // XXX: We should probably do more here.
+    // output target matrix not square (Nx > Ny) for output pointer
     {
         psMemId id = psMemGetId();
         psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
-        psImage *badImage2 = (psImage*)psImageAlloc(3, 2, PS_TYPE_F64);
-        ok(psMatrixTranspose(badImage2, inImage) != NULL, "psMatrixTranspose(): non-square matrix results in non-NULL");
+        psImage *outImage = (psImage*)psImageAlloc(3, 2, PS_TYPE_F64);
+        ok(psMatrixTranspose(outImage, inImage) != NULL, "psMatrixTranspose(): non-square matrix results in non-NULL");
+        ok(outImage->numCols == 3, "psMatrixTranspose(): output matrix dimensions match input");
+        ok(outImage->numRows == 3, "psMatrixTranspose(): output matrix dimensions match input");
         psFree(inImage);
-        psFree(badImage2);
+        psFree(outImage);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+    // input matrix not square (Nx < Ny) 
+    {
+        psMemId id = psMemGetId();
+        psImage *inImage = (psImage*)psImageAlloc(2, 3, PS_TYPE_F64);
+        psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
+        ok(psMatrixTranspose(outImage, inImage) != NULL, "psMatrixTranspose(): non-square matrix results in non-NULL");
+        ok(outImage->numCols == 3, "psMatrixTranspose(): output matrix dimensions match input");
+        ok(outImage->numRows == 2, "psMatrixTranspose(): output matrix dimensions match input");
+        psFree(inImage);
+        psFree(outImage);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+    // input matrix not square (Nx > Ny) 
+    {
+        psMemId id = psMemGetId();
+        psImage *inImage = (psImage*)psImageAlloc(3, 2, PS_TYPE_F64);
+        psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
+        ok(psMatrixTranspose(outImage, inImage) != NULL, "psMatrixTranspose(): non-square matrix results in non-NULL");
+        ok(outImage->numCols == 2, "psMatrixTranspose(): output matrix dimensions match input");
+        ok(outImage->numRows == 3, "psMatrixTranspose(): output matrix dimensions match input");
+        psFree(inImage);
+        psFree(outImage);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
