distribution.H
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::distribution 00026 00027 Description 00028 Accumulating histogram of values. Specified bin resolution 00029 automatic generation of bins. 00030 00031 SourceFiles 00032 distributionI.H 00033 distribution.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef distribution_H 00038 #define distribution_H 00039 00040 #include "Map.H" 00041 #include "Pair.H" 00042 00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00044 00045 namespace Foam 00046 { 00047 00048 /*---------------------------------------------------------------------------*\ 00049 Class distribution Declaration 00050 \*---------------------------------------------------------------------------*/ 00051 00052 class distribution 00053 : 00054 public Map<label> 00055 { 00056 // Private data 00057 00058 scalar binWidth_; 00059 00060 00061 public: 00062 00063 //- Runtime type information 00064 00065 TypeName("distribution"); 00066 00067 // Static functions 00068 00069 //- write to file 00070 00071 static void write 00072 ( 00073 const fileName& file, 00074 const List<Pair<scalar> >& pairs 00075 ); 00076 00077 00078 // Constructors 00079 00080 //- Construct null 00081 distribution(); 00082 00083 //- Construct from binWidth 00084 distribution(const scalar binWidth); 00085 00086 //- Construct as copy 00087 distribution(const distribution&); 00088 00089 00090 //- Destructor 00091 virtual ~distribution(); 00092 00093 00094 // Member Functions 00095 00096 label totalEntries() const; 00097 00098 scalar approxTotalEntries() const; 00099 00100 scalar mean() const; 00101 00102 scalar median(); 00103 00104 //- Add a value to the appropriate bin of the distribution. 00105 void add(const scalar valueToAdd); 00106 00107 void add(const label valueToAdd); 00108 00109 void insertMissingKeys(); 00110 00111 List<Pair<scalar> > normalised(); 00112 00113 List<Pair<scalar> > normalisedMinusMean(); 00114 00115 List<Pair<scalar> > normalisedShifted(scalar shiftValue); 00116 00117 List<Pair<scalar> > raw(); 00118 00119 00120 // Access 00121 00122 inline scalar binWidth() const; 00123 00124 00125 // Member Operators 00126 00127 void operator=(const distribution&); 00128 00129 00130 // IOstream Operators 00131 00132 friend Ostream& operator<<(Ostream&, const distribution&); 00133 }; 00134 00135 00136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00137 00138 } // End namespace Foam 00139 00140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00141 00142 #include "distributionI.H" 00143 00144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00145 00146 #endif 00147 00148 // ************************************************************************* //
