votca 2024.2-dev
Loading...
Searching...
No Matches
histogramnew.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#ifndef VOTCA_TOOLS_HISTOGRAMNEW_H
19#define VOTCA_TOOLS_HISTOGRAMNEW_H
20
21// Standard includes
22#include <cmath>
23#include <limits>
24
25// Local VOTCA includes
26#include "table.h"
27
28namespace votca {
29namespace tools {
30
78 public:
85 void Initialize(double min, double max, Index nbins);
86
93 void Process(const double &v, double scale = 1.0);
94
98 template <typename iterator_type>
99 void ProcessRange(const iterator_type &begin, const iterator_type &end);
100
105 double getMin() const { return min_; }
106
111 double getMax() const { return max_; }
112
117 Index getNBins() const { return nbins_; }
118
123 double getMinBinVal() const;
124
129 double getMaxBinVal() const;
135 std::pair<double, double> getInterval(Index bin) const;
136
141 double getStep() const { return step_; }
142
146 void Normalize();
147
151 void Clear();
152
157 Table &data() { return data_; }
158 const Table &data() const { return data_; }
159
164 void setPeriodic(bool periodic) { periodic_ = periodic; }
165
166 private:
167 void Initialize_();
168 double min_ = 0;
169 double max_ = 0;
170 double step_ = 0;
171 bool periodic_ = false;
174};
175
176inline std::ostream &operator<<(std::ostream &out, HistogramNew &h) {
177 out << h.data();
178 return out;
179}
180
181template <typename iterator_type>
182inline void HistogramNew::ProcessRange(const iterator_type &begin,
183 const iterator_type &end) {
184 for (iterator_type iter = begin; iter != end; ++iter) {
185 Process(*iter);
186 }
187}
188} // namespace tools
189} // namespace votca
190#endif // VOTCA_TOOLS_HISTOGRAMNEW_H
class to generate histograms
double getMax() const
get the upper bound of the histogram intervaö
Index getNBins() const
Get number of grid points.
double getMin() const
get the lower bound of the histogram intervaö
void setPeriodic(bool periodic)
set whether interval is periodic
double getStep() const
get the grid of histogram
Table & data()
get access to content of histogram
const Table & data() const
double getMaxBinVal() const
Get the count of the bin with the maximum counts.
void Normalize()
normalize the histogram that the integral is 1
double getMinBinVal() const
Get the count of the bin with the fewest counts.
void Initialize(double min, double max, Index nbins)
Initialize the HistogramNew.
void Process(const double &v, double scale=1.0)
process a data point
std::pair< double, double > getInterval(Index bin) const
Given the bin number get the Inverval bounds.
void ProcessRange(const iterator_type &begin, const iterator_type &end)
process a range of data using iterator interface
void Clear()
clear all data
class to store tables like rdfs, tabulated potentials, etc
Definition table.h:36
std::ostream & operator<<(std::ostream &out, const Correlate &c)
Definition correlate.h:53
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26