histogram/test/utility_histogram.hpp
Hans Dembinski ecd142080d
speed improvements for 1d and 2d histograms
* rename get_size to axes_rank and move axes buffer to axes.hpp
* added fill experiments
* faster and simpler fill_impl
* faster specializations for linearize_value
2019-05-26 23:51:15 +02:00

54 lines
1.4 KiB
C++

// Copyright 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)
#ifndef BOOST_HISTOGRAM_TEST_UTILITY_HISTOGRAM_HPP
#define BOOST_HISTOGRAM_TEST_UTILITY_HISTOGRAM_HPP
#include <boost/histogram/axis.hpp>
#include <boost/histogram/axis/ostream.hpp>
#include <boost/histogram/make_histogram.hpp>
#include <boost/histogram/ostream.hpp>
#include <boost/mp11/algorithm.hpp>
#include <type_traits>
#include <vector>
namespace boost {
namespace histogram {
template <typename... Ts>
auto make_axis_vector(const Ts&... ts) {
using Var = boost::mp11::mp_unique<axis::variant<Ts...>>;
return std::vector<Var>({Var(ts)...});
}
using static_tag = std::false_type;
using dynamic_tag = std::true_type;
template <typename... Axes>
auto make(static_tag, const Axes&... axes) {
return make_histogram(axes...);
}
template <typename S, typename... Axes>
auto make_s(static_tag, S&& s, const Axes&... axes) {
return make_histogram_with(s, axes...);
}
template <typename... Axes>
auto make(dynamic_tag, const Axes&... axes) {
return make_histogram(make_axis_vector(axes...));
}
template <typename S, typename... Axes>
auto make_s(dynamic_tag, S&& s, const Axes&... axes) {
return make_histogram_with(s, make_axis_vector(axes...));
}
} // namespace histogram
} // namespace boost
#endif