-
Notifications
You must be signed in to change notification settings - Fork 0
/
histogram_demo.cpp
51 lines (41 loc) · 1.17 KB
/
histogram_demo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "histogram.h"
#include "histogram_storage.h"
template <template <typename, typename...> class ContainerType,
typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...>& c) {
for (const auto& v : c) {
std::cout << v << ' ';
}
std::cout << '\n';
}
template <typename T, size_t N>
std::ostream& operator<<(std::ostream &s, const std::array<T,N> &a)
{
s << "[ ";
for (auto &v: a)
s << v << ", ";
s << ']';
return s;
}
template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a)
{
s << "[ ";
for (auto &v: a)
s << v << ", ";
s << ']';
return s;
}
int main (int argc, char const *argv[])
{
auto dim = histogram::binning::linear(0, 10, 11, "dimension");
auto dim1 = histogram::binning::general({0, 1, 2}, "general");
auto f = histogram::create("hola cabrones", dim, dim1);
f.fill(1., 1.);
std::cout << "shape: " << f.shape() << std::endl;
std::cout << "labels: " << f.labels() << std::endl;
std::cout << "binedges: " << f.binedges() << std::endl;
std::cout << "saving histogram to foo.hdf5" << std::endl;
histogram::save(f, "foo.hdf5", "/", "foo", true);
return 0;
}