help-octave
[Top][All Lists]
Advanced

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

Re: fast hist() / histogram() implementation in C++


From: Petr Mikulik
Subject: Re: fast hist() / histogram() implementation in C++
Date: Fri, 19 Nov 2004 06:28:00 -0600

> Here are the tests from hist.m in octave:

Thanks for the test. Unfortunately, it neither passed Octave (2.1.49,
2.1.55) nor Matlab. Thus, I have fixed both the test script as well as my
hist.m code to be Matlab-compatible, and documented the undocumented
difference between histc and hist: <=A(i)< vs <A(i)<=.
Here is the test:

%!test
%!  [nn,xx]=hist([1:4],3);
%!  assert(xx, [1.5,2.5,3.5]);
%!  assert(nn, [2,1,1]);
%!test
%!  [nn,xx]=hist([1:4]',3);
%!  assert(xx, [1.5,2.5,3.5]);
%!  assert(nn, [2,1,1]);
%!test
%!  [nn,xx]=hist([[1:4]',[1:4]'],3);
%!  assert(xx, [1.5,2.5,3.5]');
%!  assert(nn, [[2,1,1]',[2,1,1]']);
%!test
%!  assert(hist(1,1),1);
%!test
%!  for n = [10, 30, 100, 1000]
%!    assert( sum(hist([1:n], n)), n );
%!    assert( sum(hist([1:n], [2:n-1])), n);
%!    assert( sum(hist([1:n], [1:n])), n );
%!    assert( sum(hist([1:n], 29)), n);
%!    assert( sum(hist([1:n], 30)), n);
%!  endfor


In summary:
I've implemented histogram evaluation in C++: routine histc.cc, and its
corresponding hist.m.

Get it from here:
        http://www.physics.muni.cz/~mikulik/tmp/histc-Nov19.zip

It supports histogram of a vector and 2D matrix.
I don't know how to access dimensions for N-dim matrices. Someone can
contribute the missing code?


Petr Mikulik



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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