mode returns a wrong answer for row vectors

David Bateman adb014 at gmail.com
Sun Mar 16 17:53:47 CDT 2008


Ben Abbott wrote:
> Thanks David. You resolved the problem a couple of hours before I'd  
> finished my approach.
> 
> I applied your changes manually to the last version of octave I am  
> able to the original 3.0.0 release (I'm unable to build from the  
> current sources).
> 
> It wasn't clear to me if your method would work for N-d arrays, so I  
> added some additional tests.

It should work with NDArrays fine. The reason it doesn't is that I got
the permutation vector incorrect. Minor change to my previous patch
attached, with your tests added.

However, while looking at the way this failed, it points to another
issue. Consider the indexing case

t = ones(3,3,3);
t(:,4)
t(true(3,1),4)

which with both Octave 3.1.x and MatlabR2007b return [1;1;1], where as

t(false(3,1),4)
t([],4)

both return a 0-by-1 matrix in MatlabR2007b, but fail with an indexing
error in Octave. My solution to this was to use the short_freeze
indexing function even if one of the indices are empty. Is there a
reason not to do this?

D.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch7698
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080316/2d97a256/attachment.ksh 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch7699
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080316/2d97a256/attachment-0001.ksh 


More information about the Bug-octave mailing list