[changeset] histc

Jaroslav Hajek highegg at gmail.com
Sun Mar 8 13:14:58 CDT 2009


On Sun, Mar 8, 2009 at 6:50 PM, Søren Hauberg <soren at hauberg.org> wrote:
> Hi All
>
> I just needed the 'histc' function, so I decided to write it.
>
> I'm attaching a changeset that adds this function.
>
> Okay to push?
>
> Søren
>

Several comments:

1. your test for sortedness will gripe for descending arrays. I think
it can simply go like this

if (! issorted (edges))
  warn (...)
  edges = sort (edges);
endif

I think the best possible m-file implementation of histc is to combine
lookup (which gives you idx directly) and accumarray (which can count
the numbers of indices in idx). Currently, accumarray uses a general
approach based on sorting the index array, i.e. O(N log N). I intend
to specialize it for certain standard reductions, such as sum, prod,
min, max to get an efficient linear-time implementation, but I thought
I won't make it until 3.2. Do you have a good reason why you wnat this
function in 3.2? I think it's not much work, I just postponed because
we already entered the "feature freeze" state.
Of course, we may also go with this implementation and I'll contribute
a more optimal one after 3.2.

cheers

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



More information about the Octave-maintainers mailing list