diff src/ov-bool-mat.cc @ 6717:b319df52ba87

[project @ 2007-06-13 20:25:53 by jwe]
author jwe
date Wed, 13 Jun 2007 20:25:53 +0000
parents 2aad75fcc93a
children 509469a21cde
line wrap: on
line diff
--- a/src/ov-bool-mat.cc	Wed Jun 13 15:40:07 2007 +0000
+++ b/src/ov-bool-mat.cc	Wed Jun 13 20:25:53 2007 +0000
@@ -204,24 +204,40 @@
 	      for (int i = 0; i < mdims; i++)
 		is >> dv(i);
 
-	      NDArray tmp(dv);
-	      is >> tmp;
+	      if (is)
+		{
+		  boolNDArray btmp (dv);
+
+		  if (btmp.is_empty ())
+		    matrix = btmp;
+		  else
+		    {
+		      NDArray tmp(dv);
+		      is >> tmp;
 
-	      if (!is)
+		      if (is)
+			{
+			  for (octave_idx_type i = 0; i < btmp.nelem (); i++)
+			    btmp.elem (i) = (tmp.elem (i) != 0.);
+
+			  matrix = btmp;
+			}
+		      else
+			{
+			  error ("load: failed to load matrix constant");
+			  success = false;
+			}
+		    }
+		}
+	      else
 		{
-		  error ("load: failed to load matrix constant");
+		  error ("load: failed to extract dimensions");
 		  success = false;
 		}
-
-	      boolNDArray btmp (dv);
-	      for (octave_idx_type i = 0; i < btmp.nelem (); i++)
-		btmp.elem (i) = (tmp.elem (i) != 0.);
-
-	      matrix = btmp;
 	    }
 	  else
 	    {
-	      error ("load: failed to extract number of rows and columns");
+	      error ("load: failed to extract number of dimensions");
 	      success = false;
 	    }
 	}
@@ -236,18 +252,20 @@
 		{
 		  Matrix tmp (nr, nc);
 		  is >> tmp;
-		  if (!is) 
+		  if (is) 
+		    {
+		      boolMatrix btmp (nr, nc);
+		      for (octave_idx_type j = 0; j < nc; j++)
+			for (octave_idx_type i = 0; i < nr; i++)
+			  btmp.elem (i,j) = (tmp.elem (i, j) != 0.);
+
+		      matrix = btmp;
+		    }
+		  else
 		    {
 		      error ("load: failed to load matrix constant");
 		      success = false;
 		    }
-
-		  boolMatrix btmp (nr, nc);
-		  for (octave_idx_type j = 0; j < nc; j++)
-		    for (octave_idx_type i = 0; i < nr; i++)
-		      btmp.elem (i,j) = (tmp.elem (i, j) != 0.);
-
-		  matrix = btmp;
 		}
 	      else if (nr == 0 || nc == 0)
 		matrix = boolMatrix (nr, nc);