annotate DEPENDENCIES/generic/include/boost/math/tools/traits.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright John Maddock 2007.
Chris@16 2
Chris@16 3 // Use, modification and distribution are subject to the
Chris@16 4 // Boost Software License, Version 1.0. (See accompanying file
Chris@16 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 /*
Chris@16 8 This header defines two traits classes, both in namespace boost::math::tools.
Chris@16 9
Chris@16 10 is_distribution<D>::value is true iff D has overloaded "cdf" and
Chris@16 11 "quantile" functions, plus member typedefs value_type and policy_type.
Chris@16 12 It's not much of a definitive test frankly,
Chris@16 13 but if it looks like a distribution and quacks like a distribution
Chris@16 14 then it must be a distribution.
Chris@16 15
Chris@16 16 is_scaled_distribution<D>::value is true iff D is a distribution
Chris@16 17 as defined above, and has member functions "scale" and "location".
Chris@16 18
Chris@16 19 */
Chris@16 20
Chris@16 21 #ifndef BOOST_STATS_IS_DISTRIBUTION_HPP
Chris@16 22 #define BOOST_STATS_IS_DISTRIBUTION_HPP
Chris@16 23
Chris@16 24 #ifdef _MSC_VER
Chris@16 25 #pragma once
Chris@16 26 #endif
Chris@16 27
Chris@16 28 #include <boost/mpl/has_xxx.hpp>
Chris@16 29 // should be the last #include
Chris@16 30 #include <boost/type_traits/detail/bool_trait_def.hpp>
Chris@16 31
Chris@16 32 namespace boost{ namespace math{ namespace tools{
Chris@16 33
Chris@16 34 namespace detail{
Chris@16 35
Chris@16 36 BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_value_type, value_type, true)
Chris@16 37 BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_policy_type, policy_type, true)
Chris@16 38
Chris@16 39 template<class D>
Chris@16 40 char cdf(const D& ...);
Chris@16 41 template<class D>
Chris@16 42 char quantile(const D& ...);
Chris@16 43
Chris@16 44 template <class D>
Chris@16 45 struct has_cdf
Chris@16 46 {
Chris@16 47 static D d;
Chris@16 48 BOOST_STATIC_CONSTANT(bool, value = sizeof(cdf(d, 0.0f)) != 1);
Chris@16 49 };
Chris@16 50
Chris@16 51 template <class D>
Chris@16 52 struct has_quantile
Chris@16 53 {
Chris@16 54 static D d;
Chris@16 55 BOOST_STATIC_CONSTANT(bool, value = sizeof(quantile(d, 0.0f)) != 1);
Chris@16 56 };
Chris@16 57
Chris@16 58 template <class D>
Chris@16 59 struct is_distribution_imp
Chris@16 60 {
Chris@16 61 BOOST_STATIC_CONSTANT(bool, value =
Chris@16 62 has_quantile<D>::value
Chris@16 63 && has_cdf<D>::value
Chris@16 64 && has_value_type<D>::value
Chris@16 65 && has_policy_type<D>::value);
Chris@16 66 };
Chris@16 67
Chris@16 68 template <class sig, sig val>
Chris@16 69 struct result_tag{};
Chris@16 70
Chris@16 71 template <class D>
Chris@16 72 double test_has_location(const volatile result_tag<typename D::value_type (D::*)()const, &D::location>*);
Chris@16 73 template <class D>
Chris@16 74 char test_has_location(...);
Chris@16 75
Chris@16 76 template <class D>
Chris@16 77 double test_has_scale(const volatile result_tag<typename D::value_type (D::*)()const, &D::scale>*);
Chris@16 78 template <class D>
Chris@16 79 char test_has_scale(...);
Chris@16 80
Chris@16 81 template <class D, bool b>
Chris@16 82 struct is_scaled_distribution_helper
Chris@16 83 {
Chris@16 84 BOOST_STATIC_CONSTANT(bool, value = false);
Chris@16 85 };
Chris@16 86
Chris@16 87 template <class D>
Chris@16 88 struct is_scaled_distribution_helper<D, true>
Chris@16 89 {
Chris@16 90 BOOST_STATIC_CONSTANT(bool, value =
Chris@16 91 (sizeof(test_has_location<D>(0)) != 1)
Chris@16 92 &&
Chris@16 93 (sizeof(test_has_scale<D>(0)) != 1));
Chris@16 94 };
Chris@16 95
Chris@16 96 template <class D>
Chris@16 97 struct is_scaled_distribution_imp
Chris@16 98 {
Chris@16 99 BOOST_STATIC_CONSTANT(bool, value = (::boost::math::tools::detail::is_scaled_distribution_helper<D, ::boost::math::tools::detail::is_distribution_imp<D>::value>::value));
Chris@16 100 };
Chris@16 101
Chris@16 102 } // namespace detail
Chris@16 103
Chris@16 104 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_distribution,T,::boost::math::tools::detail::is_distribution_imp<T>::value)
Chris@16 105 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_scaled_distribution,T,::boost::math::tools::detail::is_scaled_distribution_imp<T>::value)
Chris@16 106
Chris@16 107 }}}
Chris@16 108
Chris@16 109 #endif
Chris@16 110
Chris@16 111