[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #51329] nth_element / median function fail wit
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional) |
Date: |
Wed, 28 Jun 2017 20:59:22 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 |
Follow-up Comment #12, bug #51329 (project octave):
This works as we seem to expect, thanks for showing me the test command.
diff --git a/liboctave/array/Array.cc b/liboctave/array/Array.cc
--- a/liboctave/array/Array.cc
+++ b/liboctave/array/Array.cc
@@ -2337,6 +2337,30 @@ Array<T>::nth_element (const idx_vector&
mode = ASCENDING;
lo = n(0);
break;
+ case idx_vector::class_vector:
+ if (n(1) - n(0) == 1)
+ {
+ mode = ASCENDING;
+ lo = n(0);
+ }
+ else if (n(1) - n(0) == -1)
+ {
+ mode = DESCENDING;
+ lo = ns - 1 - n(0);
+ }
+ else
+ break;
+
+ for (int i = 1; i < n.length() - 1; ++i)
+ {
+ if ((mode == ASCENDING && n(i+1) - n(i) != 1) ||
+ (mode == DESCENDING && n(i+1) - n(i) != -1))
+ {
+ mode = UNSORTED;
+ break;
+ }
+ }
+ break;
case idx_vector::class_range:
{
octave_idx_type inc = n.increment ();
Provides
>> median([1,2,3,4,5,6])
ans = 3.5000
>> test('median')
PASSES 18 out of 18 tests
>> nth_element([1,2,3,4], [1,2,4])
error: nth_element: n must be a scalar or a contiguous range
- OP
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?51329>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #51329] Median fails due to nth_element in --traditional, (continued)
- [Octave-bug-tracker] [bug #51329] Median fails due to nth_element in --traditional, Carnë Draug, 2017/06/28
- [Octave-bug-tracker] [bug #51329] Median fails due to nth_element in --traditional, anonymous, 2017/06/28
- [Octave-bug-tracker] [bug #51329] Median fails due to nth_element in --traditional, Nicholas Jankowski, 2017/06/28
- [Octave-bug-tracker] [bug #51329] Median fails due to nth_element in --traditional, Avinoam Kalma, 2017/06/28
- [Octave-bug-tracker] [bug #51329] Median fails due to nth_element in --traditional, Nicholas Jankowski, 2017/06/28
- [Octave-bug-tracker] [bug #51329] Median fails due to nth_element in --traditional, Nicholas Jankowski, 2017/06/28
- [Octave-bug-tracker] [bug #51329] Median fails due to nth_element in --traditional, anonymous, 2017/06/28
- [Octave-bug-tracker] [bug #51329] Median fails due to nth_element in --traditional, Nicholas Jankowski, 2017/06/28
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), Mike Miller, 2017/06/28
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), anonymous, 2017/06/28
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional),
anonymous <=
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), Nicholas Jankowski, 2017/06/28
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), Mike Miller, 2017/06/28
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), Mike Miller, 2017/06/28
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), anonymous, 2017/06/29
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), anonymous, 2017/06/29
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), anonymous, 2017/06/29
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), Nicholas Jankowski, 2017/06/29
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), anonymous, 2017/06/29
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), anonymous, 2017/06/29
- [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional), Carnë Draug, 2017/06/29