1 /* gsl_histogram2d_maxval.c
2 * Copyright (C) 2000 Simone Piccardi
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 /***************************************************************
21 * File gsl_histogram2d_maxval.c:
22 * Routine to find maximum and minumum content of a 2D hisogram.
23 * Need GSL library and header.
24 * Contains the routines:
25 * gsl_histogram2d_max_val find max content values
26 * gsl_histogram2d_min_val find min content values
27 * gsl_histogram2d_bin_max find coordinates of max contents bin
28 * gsl_histogram2d_bin_min find coordinates of min contents bin
33 ***************************************************************/
35 #include <gsl/gsl_errno.h>
36 #include <gsl/gsl_histogram2d.h>
38 * Return the maximum contents value of a 2D histogram
41 gsl_histogram2d_max_val (const gsl_histogram2d * h)
43 const size_t nx = h->nx;
44 const size_t ny = h->ny;
46 double max = h->bin[0 * ny + 0];
48 for (i = 0; i < nx * ny; i++)
59 * Find the bin index for maximum value of a 2D histogram
63 gsl_histogram2d_max_bin (const gsl_histogram2d * h, size_t * imax_out, size_t * jmax_out)
65 const size_t nx = h->nx;
66 const size_t ny = h->ny;
67 size_t imax = 0, jmax = 0, i, j;
68 double max = h->bin[0 * ny + 0];
70 for (i = 0; i < nx; i++)
72 for (j = 0; j < ny; j++)
74 double x = h->bin[i * ny + j];
90 * Return the minimum contents value of a 2D histogram
94 gsl_histogram2d_min_val (const gsl_histogram2d * h)
96 const size_t nx = h->nx;
97 const size_t ny = h->ny;
99 double min = h->bin[0 * ny + 0];
101 for (i = 0; i < nx * ny; i++)
112 * Find the bin index for minimum value of a 2D histogram
115 gsl_histogram2d_min_bin (const gsl_histogram2d * h, size_t * imin_out, size_t * jmin_out)
117 const size_t nx = h->nx;
118 const size_t ny = h->ny;
119 size_t imin = 0, jmin = 0, i, j;
120 double min = h->bin[0 * ny + 0];
122 for (i = 0; i < nx; i++)
124 for (j = 0; j < ny; j++)
126 double x = h->bin[i * ny + j];