changeset 6005:b4351cfb5659

[project @ 2006-09-26 21:38:16 by jwe]
author jwe
date Tue, 26 Sep 2006 21:38:16 +0000
parents 01556febbaaf
children 588dfb92e19e
files src/DLD-FUNCTIONS/find.cc test/test_matrix.m
diffstat 2 files changed, 7 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/find.cc	Tue Sep 26 21:16:52 2006 +0000
+++ b/src/DLD-FUNCTIONS/find.cc	Tue Sep 26 21:38:16 2006 +0000
@@ -118,6 +118,10 @@
       // Search for elements to return.  Only search the region where
       // there are elements to be found using the count that we want
       // to find.
+
+      // For compatibility, all N-d arrays are handled as if they are
+      // 2-d, with the number of columns equal to "prod (dims (2:end))".
+
       for (k = start_el; k < end_el; k++)
 	{
 	  OCTAVE_QUIT;
@@ -126,8 +130,9 @@
 	    {
 	      idx(count) = k + 1;
 
-	      i_idx(count) = i + 1;
-	      j_idx(count) = j + 1;
+	      octave_idx_type xr = k % nr;
+	      i_idx(count) = xr + 1;
+	      j_idx(count) = (k - xr) / nr + 1;
 
 	      val(count) = nda(k);
 
@@ -135,13 +140,6 @@
 	    }
 
 	  i++;
-
-	  if (i == nr)
-	    {
-	      i = 0;
-
-	      j++;
-	    }
 	}
     }
   else if (scalar_arg)
--- a/test/test_matrix.m	Tue Sep 26 21:16:52 2006 +0000
+++ b/test/test_matrix.m	Tue Sep 26 21:38:16 2006 +0000
@@ -63,9 +63,6 @@
 %% test/octave.test/matrix/find-3.m
 %!error <Invalid call to find.*> find ();
 
-%% test/octave.test/matrix/find-4.m
-%!error <Invalid call to find.*> find (1, 2);
-
 %% test/octave.test/matrix/fliplr-1.m
 %!assert((fliplr ([1, 2; 3, 4]) == [2, 1; 4, 3]
 %! && fliplr ([1, 2; 3, 4; 5, 6]) == [2, 1; 4, 3; 6, 5]