mode returns a wrong answer for row vectors
Ben Abbott
bpabbott at mac.com
Sun Mar 16 18:21:41 CDT 2008
On Mar 16, 2008, at 6:53 PM, David Bateman wrote:
> 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.
Worked for me as well.
> 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?
Unfortunately, I'm unfamiliar with short_freeze ... actually I'm
unfamiliar with the c/c++ side, in general. Besides that you lost me,
with the specific indexing example. Do you have a specific input to
"mode" that illustrates the problem?
The approach I've been playing with limits xs, t, and t2 to 2-d arrays
(even thought mode will work for N-d arrays).
Would the indexing problem still exist for 2-d arrays?
If possibly, look over the one attached. If not, just ignore it.
Ben
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: changeset-mode.txt
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080316/5f233546/attachment.txt
-------------- next part --------------
More information about the Bug-octave
mailing list