mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-10 07:14:05 +00:00
huge refactor, various speed improvements, potential for further improvements and parallelization
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
// Copyright 2015-2018 Hans Dembinski
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
// (See accompanying file LICENSE_1_0.txt
|
|
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//[ guide_histogram_streaming
|
|
|
|
#include <boost/histogram.hpp>
|
|
#include <boost/histogram/ostream.hpp>
|
|
#include <cassert>
|
|
#include <iostream>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
int main() {
|
|
using namespace boost::histogram;
|
|
namespace tr = axis::transform;
|
|
|
|
auto h = make_histogram(axis::regular<>(2, -1.0, 1.0, "axis 1"),
|
|
axis::category<std::string>({"red", "blue"}, "axis 2"));
|
|
|
|
std::ostringstream os;
|
|
os << h;
|
|
|
|
std::cout << os.str() << std::endl;
|
|
|
|
assert(os.str() ==
|
|
"histogram(\n"
|
|
" regular(2, -1, 1, metadata=\"axis 1\", options=underflow | overflow),\n"
|
|
" category(\"red\", \"blue\", metadata=\"axis 2\", options=overflow),\n"
|
|
" 0: 0\n"
|
|
" 1: 0\n"
|
|
" 2: 0\n"
|
|
" 3: 0\n"
|
|
" 4: 0\n"
|
|
" 5: 0\n"
|
|
" 6: 0\n"
|
|
" 7: 0\n"
|
|
" 8: 0\n"
|
|
" 9: 0\n"
|
|
" 10: 0\n"
|
|
" 11: 0\n"
|
|
")");
|
|
}
|
|
|
|
//]
|