xerus
a general purpose tensor library
histogram.h
Go to the documentation of this file.
1 // Xerus - A General Purpose Tensor Library
2 // Copyright (C) 2014-2017 Benjamin Huber and Sebastian Wolf.
3 //
4 // Xerus is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as published
6 // by the Free Software Foundation, either version 3 of the License,
7 // or (at your option) any later version.
8 //
9 // Xerus is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
13 //
14 // You should have received a copy of the GNU Affero General Public License
15 // along with Xerus. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // For further information on Xerus visit https://libXerus.org
18 // or contact us at contact@libXerus.org.
19 
25 #pragma once
26 
27 #include <string>
28 #include <fstream>
29 #include <map>
30 
31 namespace xerus {
32  namespace misc {
33 
37  class LogHistogram {
38  public:
39  double base;
40  std::map<int, size_t> buckets;
41  size_t totalCount;
42 
43  explicit LogHistogram(const double _base);
44 
45  LogHistogram &operator+=(const LogHistogram &_other);
46  void add(double _value, size_t _count = 1);
47 
48  static LogHistogram read_from_file(const std::string &_fileName);
49  void dump_to_file(const std::string &_fileName) const;
50  };
51  }
52 }
void dump_to_file(const std::string &_fileName) const
Definition: histogram.cpp:80
The main namespace of xerus.
Definition: basic.h:37
LogHistogram & operator+=(const LogHistogram &_other)
Definition: histogram.cpp:33
static LogHistogram read_from_file(const std::string &_fileName)
Definition: histogram.cpp:49
A logarithmic histogram, i.e. the size of all buckets is given by a constant factor [x - x*base) ...
Definition: histogram.h:37
void add(double _value, size_t _count=1)
Definition: histogram.cpp:42
std::map< int, size_t > buckets
Definition: histogram.h:40
LogHistogram(const double _base)
Definition: histogram.cpp:31