Index: /branches/eam_branches/20091201/psLib/src/math/psMatrix.c
===================================================================
--- /branches/eam_branches/20091201/psLib/src/math/psMatrix.c	(revision 26345)
+++ /branches/eam_branches/20091201/psLib/src/math/psMatrix.c	(revision 26346)
@@ -1151,7 +1151,10 @@
 // dimensionality of A. 
 // XXX there is no error handling for the gsl functions (anywhere in psMatrix.c)
-bool psMatrixSVD(psImage *U, psVector *w, psImage *V, const psImage *A)
+bool psMatrixSVD(psImage **U, psVector **w, psImage **V, const psImage *A)
 {
     // Error checks  Missing one for eval
+    PS_ASSERT_PTR_NON_NULL(*U, false);
+    PS_ASSERT_PTR_NON_NULL(*w, false);
+    PS_ASSERT_PTR_NON_NULL(*V, false);
     PS_ASSERT_GENERAL_IMAGE_NON_NULL(A, false);
     PS_CHECK_POINTERS(A, evec, false);
@@ -1167,7 +1170,7 @@
     int numCols = A->numCols;
 
-    U = psImageRecycle(U,  numCols, numRows, A->type.type);
-    V = psImageRecycle(V,  numCols, numCols, A->type.type);
-    w = psVectorRecycle(w, numCols, A->type.type);
+    *U = psImageRecycle(*U,  numCols, numRows, A->type.type);
+    *V = psImageRecycle(*V,  numCols, numCols, A->type.type);
+    *w = psVectorRecycle(*w, numCols, A->type.type);
 
     gsl_matrix *Agsl = gsl_matrix_alloc(numRows, numCols);
@@ -1183,12 +1186,12 @@
 
     // Copy GSL matrix data to psImage data
-    matrixGSLtoPS(V, Vgsl);
-    matrixGSLtoPS(U, Agsl);  // gsl_linalg_SV_decomp replaces A with U
-    vectorGSLtoPS(S, Sgsl);
+    matrixGSLtoPS(*V, Vgsl);
+    matrixGSLtoPS(*U, Agsl);  // gsl_linalg_SV_decomp replaces A with U
+    vectorGSLtoPS(*w, Sgsl);
 
     // Free GSL data
-    gsl_matrix_free(A);
-    gsl_matrix_free(V);
-    gsl_vector_free(S);
+    gsl_matrix_free(Agsl);
+    gsl_matrix_free(Vgsl);
+    gsl_vector_free(Sgsl);
     gsl_vector_free(work);
 
