GNU Scientific Library – Reference Manual: Searching 2D histogram ranges

Next: 2D Histogram Statistics, Previous: Updating and accessing 2D histogram elements, Up: Histograms [Index]

### 23.17 Searching 2D histogram ranges

The following functions are used by the access and update routines to locate the bin which corresponds to a given (x,y) coordinate.

Function: int gsl_histogram2d_find (const gsl_histogram2d * h, double x, double y, size_t * i, size_t * j)

  This function finds and sets the indices i and j to the bin which covers the coordinates (x,y). The bin is located using a binary search. The search includes an optimization for histograms with uniform ranges, and will return the correct bin immediately in this case. If (x,y) is found then the function sets the indices (i,j) and returns `GSL_SUCCESS`. If (x,y) lies outside the valid range of the histogram then the function returns `GSL_EDOM` and the error handler is invoked.