votca 2024.2-dev
Loading...
Searching...
No Matches
histogram.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_HISTOGRAM_H
19#define VOTCA_TOOLS_HISTOGRAM_H
20
21// Standard includes
22#include <cmath>
23#include <limits>
24#include <vector>
25
26// Local VOTCA includes
27#include "datacollection.h"
28
29namespace votca {
30namespace tools {
31
38class Histogram {
39 public:
40 struct options_t;
41
43 Histogram(const options_t &op);
47
52
54 double getMin() const { return min_; }
56 double getMax() const { return max_; }
58 Index getN() const { return options_.n_; }
59 std::vector<double> &getPdf() { return pdf_; }
60 double getInterval() const { return interval_; }
61
62 void Normalize(void);
63
64 struct options_t {
65 Index n_ = 101;
66 bool auto_interval_ = true;
67 bool extend_interval_ = false;
68 double min_ = 0;
69 double max_ = 1.;
70 bool periodic_ = false;
71 bool normalize_ = true;
72 std::string scale_ = "no";
73 };
74
75 private:
76 std::vector<double> pdf_;
77 double min_ = 0;
78 double max_ = 0;
79 double interval_;
80
82};
83
84inline std::ostream &operator<<(std::ostream &out, Histogram &h) {
85 for (Index i = 0; i < h.getN(); i++) {
86 out << h.getMin() + h.getInterval() * ((double)i + 0.0) << " "
87 << h.getPdf()[i] << std::endl;
88 }
89 return out;
90}
91
92} // namespace tools
93} // namespace votca
94
95#endif // VOTCA_TOOLS_HISTOGRAM_H
class to generate histograms
Definition histogram.h:38
double getMax() const
return the maximum value
Definition histogram.h:56
double getMin() const
returns the minimum value
Definition histogram.h:54
void ProcessData(DataCollection< double >::selection *data)
Definition histogram.cc:36
std::vector< double > pdf_
Definition histogram.h:76
double getInterval() const
Definition histogram.h:60
std::vector< double > & getPdf()
Definition histogram.h:59
Index getN() const
return the number of grid points
Definition histogram.h:58
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