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