deduce_hp_types.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_CORE_HPT_DEDUCE_HP_TYPES_HPP
14 #define MLPACK_CORE_HPT_DEDUCE_HP_TYPES_HPP
15 
17 
18 namespace mlpack {
19 namespace hpt {
20 
33 template<typename... Args>
35 {
36  template<typename... HPTypes>
37  struct ResultHolder
38  {
39  using TupleType = std::tuple<HPTypes...>;
40  };
41 };
42 
48 template<typename T, typename... Args>
49 struct DeduceHyperParameterTypes<T, Args...>
50 {
54  template<typename ArgumentType,
55  bool IsArithmetic = std::is_arithmetic<ArgumentType>::value>
56  struct ResultHPType;
57 
58  template<typename ArithmeticType>
59  struct ResultHPType<ArithmeticType, true>
60  {
61  using Type = ArithmeticType;
62  };
63 
68  template<typename Type>
69  struct IsCollectionType
70  {
71  using Yes = char[1];
72  using No = char[2];
73 
74  template<typename TypeToCheck>
75  static Yes& Check(typename TypeToCheck::value_type*);
76  template<typename>
77  static No& Check(...);
78 
79  static const bool value =
80  sizeof(decltype(Check<Type>(0))) == sizeof(Yes);
81  };
82 
83  template<typename CollectionType>
84  struct ResultHPType<CollectionType, false>
85  {
86  static_assert(IsCollectionType<CollectionType>::value,
87  "One of the passed arguments is neither of an arithmetic type, nor of "
88  "a collection type, nor fixed with the Fixed function.");
89 
90  using Type = typename CollectionType::value_type;
91  };
92 
93  template<typename... HPTypes>
94  struct ResultHolder
95  {
96  using TupleType = typename DeduceHyperParameterTypes<Args...>::template
97  ResultHolder<HPTypes..., typename ResultHPType<T>::Type>::TupleType;
98  };
99 
101 };
102 
108 template<typename T, typename... Args>
110 {
111  template<typename... HPTypes>
112  struct ResultHolder
113  {
114  using TupleType = typename DeduceHyperParameterTypes<Args...>::template
115  ResultHolder<HPTypes...>::TupleType;
116  };
117 
119 };
120 
125 template<typename... Args>
128 
129 } // namespace hpt
130 } // namespace mlpack
131 
132 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
typename DeduceHyperParameterTypes< Args... >::TupleType TupleOfHyperParameters
A short alias for deducing types of hyper-parameters from types of arguments in the Optimize method i...
A type function for deducing types of hyper-parameters from types of arguments in the Optimize method...
typename DeduceHyperParameterTypes< Args... >::template ResultHolder< HPTypes... >::TupleType TupleType
typename DeduceHyperParameterTypes< Args... >::template ResultHolder< HPTypes..., typename ResultHPType< T >::Type >::TupleType TupleType
A struct for marking arguments as ones that should be fixed (it can be useful for the Optimize method...
Definition: fixed.hpp:23