get_printable_param.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_BINDINGS_JULIA_GET_PRINTABLE_PARAM_HPP
13 #define MLPACK_BINDINGS_JULIA_GET_PRINTABLE_PARAM_HPP
14 
15 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace bindings {
20 namespace julia {
21 
25 template<typename T>
26 std::string GetPrintableParam(
27  util::ParamData& data,
28  const typename boost::disable_if>::type* = 0,
29  const typename boost::disable_if<util::IsStdVector>::type* = 0,
30  const typename boost::disable_if<data::HasSerialize>::type* = 0,
31  const typename boost::disable_if
32  std::tuple>>::type* = 0)
33 {
34  std::ostringstream oss;
35  oss << boost::any_cast(data.value);
36  return oss.str();
37 }
38 
42 template<typename T>
43 std::string GetPrintableParam(
44  util::ParamData& data,
45  const typename boost::enable_if<util::IsStdVector>::type* = 0)
46 {
47  const T& t = boost::any_cast(data.value);
48 
49  std::ostringstream oss;
50  for (size_t i = 0; i < t.size(); ++i)
51  oss << t[i] << " ";
52  return oss.str();
53 }
54 
58 template<typename T>
59 std::string GetPrintableParam(
60  util::ParamData& data,
61  const typename boost::enable_if>::type* = 0)
62 {
63  // Get the matrix.
64  const T& matrix = boost::any_cast(data.value);
65 
66  std::ostringstream oss;
67  oss << matrix.n_rows << "x" << matrix.n_cols << " matrix";
68  return oss.str();
69 }
70 
74 template<typename T>
75 std::string GetPrintableParam(
76  util::ParamData& data,
77  const typename boost::disable_if>::type* = 0,
78  const typename boost::enable_if<data::HasSerialize>::type* = 0)
79 {
80  std::ostringstream oss;
81  oss << data.cppType << " model at " << boost::any_cast(data.value);
82  return oss.str();
83 }
84 
88 template<typename T>
89 std::string GetPrintableParam(
90  util::ParamData& data,
91  const typename boost::enable_if
92  std::tuple>>::type* = 0)
93 {
94  // Get the matrix.
95  const T& tuple = boost::any_cast(data.value);
96  const arma::mat& matrix = std::get<1>(tuple);
97 
98  std::ostringstream oss;
99  oss << matrix.n_rows << "x" << matrix.n_cols << " matrix with dimension type "
100  << "information";
101  return oss.str();
102 }
103 
113 template<typename T>
115  const void* /* input */,
116  void* output)
117 {
118  *((std::string*) output) =
119  GetPrintableParam::type>(data);
120 }
121 
122 } // namespace julia
123 } // namespace bindings
124 } // namespace mlpack
125 
126 #endif
boost::any value
The actual value that is held.
Definition: param_data.hpp:82
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
julia
Definition: CMakeLists.txt:6
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
Metaprogramming structure for vector detection.
std::string GetPrintableParam(util::ParamData &data, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, 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< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *=0)
Print an option of a simple type.
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:84