Index: /trunk/Ohana/src/opihi/cmd.data/gaussj.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/gaussj.c	(revision 24081)
+++ /trunk/Ohana/src/opihi/cmd.data/gaussj.c	(revision 24082)
@@ -47,13 +47,16 @@
   status = dgaussjordan (a, b, N, 1);
 
-  // output vector needs to be float, so re-cast it
-  ResetVector (B, OPIHI_FLT, N);
-  vf = B[0].elements.Flt;
+  // if dgaussjordan succeeds, replace the input values with the results
+  if (status) {
+    // output vector needs to be float, so re-cast it
+    ResetVector (B, OPIHI_FLT, N);
+    vf = B[0].elements.Flt;
 
-  for (i = 0; i < N; i++) {
-    for (j = 0; j < N; j++) {
-       m[i+j*N] = a[i][j];
+    for (i = 0; i < N; i++) {
+      for (j = 0; j < N; j++) {
+	m[i+j*N] = a[i][j];
+      }
+      vf[i] = b[i][0]; 
     }
-    vf[i] = b[i][0]; 
   }
 
@@ -66,5 +69,5 @@
 
   if (!status && !QUIET) {
-      gprint (GP_ERR, "failure in matrix solution\n");
+      gprint (GP_ERR, "gaussjordan: ill-conditioned matrix; input values are retained\n");
   }
   return (status);
