1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "Histogram.H"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 void Foam::Histogram<List>::count(const List& bins, const List& l)
37 FatalErrorIn("Histogram<List>::count(const List&, const List&)")
38 << "Should have at least two values in bins. Now:" << bins
42 counts_.setSize(bins.size()-1);
50 label index = findLower(bins, l[i]);
56 else if (index == bins.size()-1)
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 Foam::Histogram<List>::Histogram(const List& bins, const List& l)
78 Foam::Histogram<List>::Histogram
80 const typename List::const_reference min,
81 const typename List::const_reference max,
88 typename List::value_type span = (max-min) / nBins;
92 for (label i = 1; i < nBins; i++)
94 bins[i] = bins[i-1] + span;
97 // Set max directly to avoid truncation errors.
104 // ************************************************************************* //