diff src/DLD-FUNCTIONS/find.cc @ 9544:df0abc63c230

cache/use cached index vector on full find in logical masks
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 19 Aug 2009 07:55:31 +0200
parents e2344f4af0cb
children b4fdfee405b5
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/find.cc
+++ b/src/DLD-FUNCTIONS/find.cc
@@ -480,6 +480,12 @@
 	    retval = find_nonzero_elem_idx (v, nargout, 
 					    n_to_find, direction);
         }
+      else if (nargout <= 1 && n_to_find == -1 && direction == 1)
+        {
+          // This case is equivalent to extracting indices from a logical
+          // matrix. Try to reuse the possibly cached index vector.
+          retval(0) = arg.index_vector ();
+        }
       else
         {
           boolNDArray v = arg.bool_array_value ();