changeset 13696:d6118a2c0644

fix indexing bug for matrices inside anonymous functions * ov-base-mat.h (octave_base_matrix<T>::do_multi_index_op): New method. * ov-fcn-handle.cc: New test.
author John W. Eaton <jwe@octave.org>
date Thu, 13 Oct 2011 11:05:30 -0400
parents 348857854c52
children 0f8ff98929b2
files src/ov-base-mat.h src/ov-fcn-handle.cc
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ov-base-mat.h	Wed Oct 12 22:25:01 2011 -0400
+++ b/src/ov-base-mat.h	Thu Oct 13 11:05:30 2011 -0400
@@ -89,6 +89,9 @@
   octave_value do_index_op (const octave_value_list& idx,
                             bool resize_ok = false);
 
+  octave_value_list do_multi_index_op (int, const octave_value_list& idx)
+    { return do_index_op (idx); }
+
   void assign (const octave_value_list& idx, const MT& rhs);
 
   void assign (const octave_value_list& idx, typename MT::element_type rhs);
--- a/src/ov-fcn-handle.cc	Wed Oct 12 22:25:01 2011 -0400
+++ b/src/ov-fcn-handle.cc	Thu Oct 13 11:05:30 2011 -0400
@@ -1956,3 +1956,12 @@
 
   return retval;
 }
+
+/*
+%!function r = f (g, i)
+%!  r = g(i);
+%!endfunction
+%!test
+%! x = [1,2;3,4];
+%! assert (f (@(i) x(:,i), 1), [1;3]);
+*/