Histogram.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::Histogram
28
29Description
30 Calculates the counts per bin of a list.
31
32SourceFiles
33 Histogram.C
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef Histogram_H
38#define Histogram_H
39
40#include "labelList.H"
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44namespace Foam
45{
46
47
48/*---------------------------------------------------------------------------*\
49 Class Histogram Declaration
50\*---------------------------------------------------------------------------*/
51
52template<class List>
53class Histogram
54{
55 // Private data
56
57 //- Counts per bin
58 labelList counts_;
59
60 //- Number of <= lowest bin
61 label nLow_;
62
63 //- Number of > highest bin
64 label nHigh_;
65
66
67 // Private Member Functions
68
69 void count(const List& bins, const List& l);
70
71 //- No copy construct
72 Histogram(const Histogram&) = delete;
73
74 //- No copy assignment
75 void operator=(const Histogram&) = delete;
76
77
78public:
79
80 // Constructors
81
82 //- Construct given bin values and input list
83 Histogram(const List& bins, const List& l);
84
85 //- Construct given min, max, number of bins and input list
87 (
88 const typename List::const_reference min,
89 const typename List::const_reference max,
90 const label nBins,
91 const List& l
92 );
93
94
95 // Access
96
97 //- Return the counts per bin
98 inline const labelList& counts() const
99 {
100 return counts_;
101 }
102
103 //- Return the number of elements <= bins[0]
104 // (so inclusive lowest bin value)
105 inline label nLow() const
106 {
107 return nLow_;
108 }
109
110 //- Return the number of elements > bins[bins.size()-1]
111 // (so exclusive highest bin value)
112 inline label nHigh() const
113 {
114 return nHigh_;
115 }
116};
117
118
119// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120
121} // End namespace Foam
122
123// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124
125// #include "HistogramI.H"
126
127// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128
129#ifdef NoRepository
130 #include "Histogram.C"
131#endif
132
133// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134
135#endif
136
137// ************************************************************************* //
Calculates the counts per bin of a list.
Definition: Histogram.H:53
label nHigh() const
Return the number of elements > bins[bins.size()-1].
Definition: Histogram.H:111
const labelList & counts() const
Return the counts per bin.
Definition: Histogram.H:97
label nLow() const
Return the number of elements <= bins[0].
Definition: Histogram.H:104
unsigned int const_reference
Definition: bitSet.H:124
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33