fwd.hpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. // Copyright 2015-2019 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_FWD_HPP
  7. #define BOOST_HISTOGRAM_FWD_HPP
  8. /**
  9. \file boost/histogram/fwd.hpp
  10. Forward declarations, tag types and type aliases.
  11. */
  12. #include <boost/config.hpp> // BOOST_ATTRIBUTE_NODISCARD
  13. #include <boost/core/use_default.hpp>
  14. #include <tuple>
  15. #include <type_traits>
  16. #include <vector>
  17. namespace boost {
  18. namespace histogram {
  19. /// Tag type to indicate use of a default type
  20. using boost::use_default;
  21. namespace axis {
  22. /// Integral type for axis indices
  23. using index_type = int;
  24. /// Real type for axis indices
  25. using real_index_type = double;
  26. /// Empty metadata type
  27. struct null_type {
  28. template <class Archive>
  29. void serialize(Archive&, unsigned /* version */) {}
  30. };
  31. /// Another alias for an empty metadata type
  32. using empty_type = null_type;
  33. // some forward declarations must be hidden from doxygen to fix the reference docu :(
  34. #ifndef BOOST_HISTOGRAM_DOXYGEN_INVOKED
  35. namespace transform {
  36. struct id;
  37. struct log;
  38. struct sqrt;
  39. struct pow;
  40. } // namespace transform
  41. template <class Value = double, class Transform = use_default,
  42. class MetaData = use_default, class Options = use_default>
  43. class regular;
  44. template <class Value = int, class MetaData = use_default, class Options = use_default>
  45. class integer;
  46. template <class Value = double, class MetaData = use_default, class Options = use_default,
  47. class Allocator = std::allocator<Value>>
  48. class variable;
  49. template <class Value = int, class MetaData = use_default, class Options = use_default,
  50. class Allocator = std::allocator<Value>>
  51. class category;
  52. template <class MetaData = use_default>
  53. class boolean;
  54. template <class... Ts>
  55. class variant;
  56. #endif // BOOST_HISTOGRAM_DOXYGEN_INVOKED
  57. } // namespace axis
  58. #ifndef BOOST_HISTOGRAM_DOXYGEN_INVOKED
  59. template <class T>
  60. struct weight_type;
  61. template <class T>
  62. struct sample_type;
  63. namespace accumulators {
  64. template <class ValueType = double, bool ThreadSafe = false>
  65. class count;
  66. template <class ValueType = double>
  67. class fraction;
  68. template <class ValueType = double>
  69. class sum;
  70. template <class ValueType = double>
  71. class weighted_sum;
  72. template <class ValueType = double>
  73. class mean;
  74. template <class ValueType = double>
  75. class weighted_mean;
  76. } // namespace accumulators
  77. struct unsafe_access;
  78. template <class Allocator = std::allocator<char>>
  79. class unlimited_storage;
  80. template <class T>
  81. class storage_adaptor;
  82. #endif // BOOST_HISTOGRAM_DOXYGEN_INVOKED
  83. /// Vector-like storage for fast zero-overhead access to cells.
  84. template <class T, class A = std::allocator<T>>
  85. using dense_storage = storage_adaptor<std::vector<T, A>>;
  86. /// Default storage, optimized for unweighted histograms
  87. using default_storage = unlimited_storage<>;
  88. /// Dense storage which tracks sums of weights and a variance estimate.
  89. using weight_storage = dense_storage<accumulators::weighted_sum<>>;
  90. /// Dense storage which tracks means of samples in each cell.
  91. using profile_storage = dense_storage<accumulators::mean<>>;
  92. /// Dense storage which tracks means of weighted samples in each cell.
  93. using weighted_profile_storage = dense_storage<accumulators::weighted_mean<>>;
  94. // some forward declarations must be hidden from doxygen to fix the reference docu :(
  95. #ifndef BOOST_HISTOGRAM_DOXYGEN_INVOKED
  96. template <class Axes, class Storage = default_storage>
  97. class BOOST_ATTRIBUTE_NODISCARD histogram;
  98. #endif // BOOST_HISTOGRAM_DOXYGEN_INVOKED
  99. namespace utility {
  100. template <class ValueType = double>
  101. class clopper_pearson_interval;
  102. template <class ValueType = double>
  103. class jeffreys_interval;
  104. template <class ValueType = double>
  105. class wald_interval;
  106. template <class ValueType = double>
  107. class wilson_interval;
  108. } // namespace utility
  109. namespace detail {
  110. /*
  111. Most of the histogram code is generic and works for any number of axes. Buffers with a
  112. fixed maximum capacity are used in some places, which have a size equal to the rank of
  113. a histogram. The buffers are allocated from the stack to improve performance, which
  114. means in C++ that they need a preset maximum capacity. 32 seems like a safe upper limit
  115. for the rank. You can nevertheless increase it with the compile-time flag
  116. BOOST_HISTOGRAM_DETAIL_AXES_LIMIT, if necessary.
  117. */
  118. #ifndef BOOST_HISTOGRAM_DETAIL_AXES_LIMIT
  119. #define BOOST_HISTOGRAM_DETAIL_AXES_LIMIT 32
  120. #endif
  121. template <class T>
  122. struct buffer_size_impl
  123. : std::integral_constant<std::size_t, BOOST_HISTOGRAM_DETAIL_AXES_LIMIT> {};
  124. template <class... Ts>
  125. struct buffer_size_impl<std::tuple<Ts...>>
  126. : std::integral_constant<std::size_t, sizeof...(Ts)> {};
  127. template <class T>
  128. using buffer_size = typename buffer_size_impl<T>::type;
  129. } // namespace detail
  130. } // namespace histogram
  131. } // namespace boost
  132. #endif