octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ismember bug and fix ( i think ) octave 2.9.10


From: David Grohmann
Subject: ismember bug and fix ( i think ) octave 2.9.10
Date: Tue, 08 May 2007 16:45:24 -0500
User-agent: Thunderbird 1.5.0.10 (Windows/20070221)

bug:
-------------------------------
ismember( {'float32'}, {'adgfffffffffffffffffff'} )
error: mx_el_eq: nonconformant arguments (op1 is 0x7, op2 is 0x0)
error: evaluating binary operator `==' near line 62, column 58
error: evaluating argument list element number 1
error: evaluating assignment expression near line 62, column 16
error: evaluating if command near line 58, column 7
error: evaluating if command near line 49, column 5
error: evaluating if command near line 36, column 3
error: called from `ismember' in file `/home/grohmann/GDV/trunk/testing//ismember.m'
--------------------------------

fix: attached :-)

looks like you first checked to see if the items in each cell had the same length as the search cell. but if none had the same length then when find( [0,0,0,0...]) was called it returned an empty matrix and which was used as an index into a variable. such as c([]) which is illegal.


--
David Grohmann
Senior Student Associate
Applied Research Lab : UT Austin : ESL - S206
Office: 512-835-3237


*** oism        2007-05-08 16:40:53.000000000 -0500
--- ismember.m  2007-05-08 16:36:44.000000000 -0500
***************
*** 50,55 ****
--- 50,59 ----
        if (iscell (a) || iscell (S))
          c = cellfun ("length", a) == cellfun ("length", S);
          idx = find (c);
+         if isempty(idx)
+             c = 0;
+             return
+         end
          c(idx) = all (char (a(idx)) == repmat (char (S), length (idx), 1), 2);
        else
          c = (a == S);
***************
*** 58,63 ****
--- 62,71 ----
        if (iscell (a) || iscell (S))
          c = cellfun ("length", a) == cellfun ("length", S);
          idx = find (c);
+         if isempty(idx)
+             c = 0;
+             return
+         end
          c(idx) = all (repmat (char (a), length (idx), 1) == char (S(idx)), 2);
          c = any(c);
        else
***************
*** 108,111 ****
    endif
  
  endfunction
!   
--- 116,119 ----
    endif
  
  endfunction
! 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]