get_type.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_GO_GET_TYPE_HPP
14 #define MLPACK_BINDINGS_GO_GET_TYPE_HPP
15 
16 #include <mlpack/prereqs.hpp>
19 
20 namespace mlpack {
21 namespace bindings {
22 namespace go {
23 
24 template<typename T>
25 inline std::string GetType(
26  util::ParamData& /* d */,
27  const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
28  const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
29  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
30 {
31  return "unknown";
32 }
33 
34 template<>
35 inline std::string GetType<int>(
36  util::ParamData& /* d */,
37  const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
38  const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
39  const typename std::enable_if<!arma::is_arma_type<int>::value>::type*)
40 {
41  return "Int";
42 }
43 
44 template<>
45 inline std::string GetType<float>(
46  util::ParamData& /* d */,
47  const typename std::enable_if<!util::IsStdVector<float>::value>::type*,
48  const typename std::enable_if<!data::HasSerialize<float>::value>::type*,
49  const typename std::enable_if<!arma::is_arma_type<float>::value>::type*)
50 {
51  return "Float";
52 }
53 
54 template<>
55 inline std::string GetType<double>(
56  util::ParamData& /* d */,
57  const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
58  const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
59  const typename std::enable_if<!arma::is_arma_type<double>::value>::type*)
60 {
61  return "Double";
62 }
63 
64 template<>
65 inline std::string GetType<std::string>(
66  util::ParamData& /* d */,
67  const typename std::enable_if<
69  const typename std::enable_if<
71  const typename std::enable_if<
72  !arma::is_arma_type<std::string>::value>::type*)
73 {
74  return "String";
75 }
76 
77 template<>
78 inline std::string GetType<bool>(
79  util::ParamData& /* d */,
80  const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
81  const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
82  const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*)
83 {
84  return "Bool";
85 }
86 
87 template<typename T>
88 inline std::string GetType(
89  util::ParamData& d,
90  const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
91 {
92  return "Vec" + GetType<typename T::value_type>(d);
93 }
94 
95 template<typename T>
96 inline std::string GetType(
97  util::ParamData& /* d */,
98  const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
99 {
100  std::string type = "";
101  if (std::is_same<typename T::elem_type, double>::value)
102  {
103  if (T::is_row)
104  type = "Row";
105  else if (T::is_col)
106  type = "Col";
107  else
108  type = "Mat";
109  }
110  else if (std::is_same<typename T::elem_type, size_t>::value)
111  {
112  if (T::is_row)
113  type = "Urow";
114  else if (T::is_col)
115  type = "Ucol";
116  else
117  type = "Umat";
118  }
119 
120  return type;
121 }
122 
123 template<typename T>
124 inline std::string GetType(
125  util::ParamData& d,
126  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
127  const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
128 {
129  return d.cppType + "*";
130 }
131 
142 template<typename T>
143 void GetType(util::ParamData& d,
144  const void* /* input */,
145  void* output)
146 {
147  *((std::string*) output) =
148  GetType<typename std::remove_pointer<T>::type>(d);
149 }
150 
151 } // namespace go
152 } // namespace bindings
153 } // namespace mlpack
154 
155 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes, Armadillo, cereal, and a few basic mlpa...
go
Definition: CMakeLists.txt:7
std::string GetType< bool >(util::ParamData &, const typename std::enable_if<!util::IsStdVector< bool >::value >::type *, const typename std::enable_if<!data::HasSerialize< bool >::value >::type *, const typename std::enable_if<!arma::is_arma_type< bool >::value >::type *)
Definition: get_type.hpp:78
std::string GetType(util::ParamData &, const typename std::enable_if<!util::IsStdVector< T >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0)
Definition: get_type.hpp:25
std::string GetType< float >(util::ParamData &, const typename std::enable_if<!util::IsStdVector< float >::value >::type *, const typename std::enable_if<!data::HasSerialize< float >::value >::type *, const typename std::enable_if<!arma::is_arma_type< float >::value >::type *)
Definition: get_type.hpp:45
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:38
Metaprogramming structure for vector detection.
std::string GetType< int >(util::ParamData &, const typename std::enable_if<!util::IsStdVector< int >::value >::type *, const typename std::enable_if<!data::HasSerialize< int >::value >::type *, const typename std::enable_if<!arma::is_arma_type< int >::value >::type *)
Definition: get_type.hpp:35
std::string GetType< double >(util::ParamData &, const typename std::enable_if<!util::IsStdVector< double >::value >::type *, const typename std::enable_if<!data::HasSerialize< double >::value >::type *, const typename std::enable_if<!arma::is_arma_type< double >::value >::type *)
Definition: get_type.hpp:55
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:67