[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## fast hist() / histogram() implementation in C++

**From**: |
Petr Mikulik |

**Subject**: |
fast hist() / histogram() implementation in C++ |

**Date**: |
Thu, 27 May 2004 11:07:53 -0500 |

It seems that the M-language does not provide an efficient way to implement
histogram function. It is order(s) of magnitude worse than ndat*log2(nbins)
efficiency of a loop-friendly language, like C/C++. As an example, try the
following histograming code for a 2048x2048 image:
n=2048;
nbins=100;
a=1./hilb(n);
imagesc(a);
tic; [y,x]=hist(a(:),nbins); toc
I'm using my own function called "histogram" with this syntax:
[ [x, ] h ] = histogram ( image [, bins [, zfrom, zto] [, do_log ]] )
I've put its M and well as C++ (=>.oct) code to
http://www.sci.muni.cz/~mikulik/tmp/pmhist4octave.zip
It would be great if someone uses its code (...or his own code) for a C++
(thus => .oct routine) implementation of
histc(data, edges)
function for calculating histogram based on given vector of bin edges. Then,
hist() function should call this histc.oct instead of its current inefficient
M-language implementation.
Looking forward to histc.cc.
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
-------------------------------------------------------------

**fast hist() / histogram() implementation in C++**,
*Petr Mikulik* **<=**