make_profile.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright 2018 Hans Dembinski
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_HISTOGRAM_MAKE_PROFILE_HPP
  7. #define BOOST_HISTOGRAM_MAKE_PROFILE_HPP
  8. #include <boost/histogram/accumulators/mean.hpp>
  9. #include <boost/histogram/accumulators/weighted_mean.hpp>
  10. #include <boost/histogram/fwd.hpp>
  11. #include <boost/histogram/make_histogram.hpp>
  12. /**
  13. \file boost/histogram/make_profile.hpp
  14. Collection of factory functions to conveniently create profiles.
  15. Profiles are histograms which accept an additional sample and compute the mean of the
  16. sample in each cell.
  17. */
  18. namespace boost {
  19. namespace histogram {
  20. /**
  21. Make profle from compile-time axis configuration.
  22. @param axis First axis instance.
  23. @param axes Other axis instances.
  24. */
  25. template <class Axis, class... Axes, class = detail::requires_axis<Axis>>
  26. auto make_profile(Axis&& axis, Axes&&... axes) {
  27. return make_histogram_with(profile_storage(), std::forward<Axis>(axis),
  28. std::forward<Axes>(axes)...);
  29. }
  30. /**
  31. Make profle from compile-time axis configuration which accepts weights.
  32. @param axis First axis instance.
  33. @param axes Other axis instances.
  34. */
  35. template <class Axis, class... Axes, class = detail::requires_axis<Axis>>
  36. auto make_weighted_profile(Axis&& axis, Axes&&... axes) {
  37. return make_histogram_with(weighted_profile_storage(), std::forward<Axis>(axis),
  38. std::forward<Axes>(axes)...);
  39. }
  40. /**
  41. Make profile from iterable range.
  42. @param iterable Iterable range of axis objects.
  43. */
  44. template <class Iterable, class = detail::requires_sequence_of_any_axis<Iterable>>
  45. auto make_profile(Iterable&& iterable) {
  46. return make_histogram_with(profile_storage(), std::forward<Iterable>(iterable));
  47. }
  48. /**
  49. Make profile from iterable range which accepts weights.
  50. @param iterable Iterable range of axis objects.
  51. */
  52. template <class Iterable, class = detail::requires_sequence_of_any_axis<Iterable>>
  53. auto make_weighted_profile(Iterable&& iterable) {
  54. return make_histogram_with(weighted_profile_storage(),
  55. std::forward<Iterable>(iterable));
  56. }
  57. /**
  58. Make profile from iterator interval.
  59. @param begin Iterator to range of axis objects.
  60. @param end Iterator to range of axis objects.
  61. */
  62. template <class Iterator, class = detail::requires_iterator<Iterator>>
  63. auto make_profile(Iterator begin, Iterator end) {
  64. return make_histogram_with(profile_storage(), begin, end);
  65. }
  66. /**
  67. Make profile from iterator interval which accepts weights.
  68. @param begin Iterator to range of axis objects.
  69. @param end Iterator to range of axis objects.
  70. */
  71. template <class Iterator, class = detail::requires_iterator<Iterator>>
  72. auto make_weighted_profile(Iterator begin, Iterator end) {
  73. return make_histogram_with(weighted_profile_storage(), begin, end);
  74. }
  75. } // namespace histogram
  76. } // namespace boost
  77. #endif