/******************************************************************************* * This file is part of SWIFT. * Copyright (c) 2021 Peter W. Draper (p.w.draper@durham.ac.uk) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ #ifndef SWIFT_HISTOGRAM_H #define SWIFT_HISTOGRAM_H /* Bins in a histogram. Note this must be an even number. */ #define NHIST 65536 /** Histogram structure. */ struct histogram { /* Raw histogram. NHIST counts in hist and the value associated with a bin * is index*width+zero. */ double width; double zero; int hist[NHIST]; /* Normalized cumulative histogram. Empty bins are joined into a larger one, * so values are the bin centre, sums the sum to that bin and nvalues the * number of bins that have been populated, can be less than NHIST. */ double values[NHIST]; double sums[NHIST]; int nvalues; }; int histread(const char *file, double **values, int *nvalues); void histmake(int nvalues, double *values, struct histogram *h); #endif