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 | Copyright (C) 2011-2016 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  //- Disallow default bitwise copy construct
70  Histogram(const Histogram&);
71 
72  //- Disallow default bitwise assignment
73  void operator=(const Histogram&);
74 
75 
76 public:
77 
78  // Constructors
79 
80  //- Construct given bin values and input list
81  Histogram(const List& bins, const List& l);
82 
83  //- Construct given min, max, number of bins and input list
84  Histogram
85  (
86  const typename List::const_reference min,
87  const typename List::const_reference max,
88  const label nBins,
89  const List& l
90  );
91 
92 
93  // Access
94 
95  //- Return the counts per bin
96  inline const labelList& counts() const
97  {
98  return counts_;
99  }
100 
101  //- Return the number of elements <= bins[0]
102  // (so inclusive lowest bin value)
103  inline label nLow() const
104  {
105  return nLow_;
106  }
107 
108  //- Return the number of elements > bins[bins.size()-1]
109  // (so exclusive highest bin value)
110  inline label nHigh() const
111  {
112  return nHigh_;
113  }
114 };
115 
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 } // End namespace Foam
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 // #include "HistogramI.H"
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 #ifdef NoRepository
128  #include "Histogram.C"
129 #endif
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 #endif
134 
135 // ************************************************************************* //
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 > &)
const labelList & counts() const
Return the counts per bin.
Definition: Histogram.H:95
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
label nHigh() const
Return the number of elements > bins[bins.size()-1].
Definition: Histogram.H:109
const T & const_reference
Type that can be used for storing into.
Definition: UList.H:259
label nLow() const
Return the number of elements <= bins[0].
Definition: Histogram.H:102
Namespace for OpenFOAM.