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