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