mlpack 3.4.2
print_defn_input.hpp
Go to the documentation of this file.
1
13#ifndef MLPACK_BINDINGS_GO_PRINT_DEFN_INPUT_HPP
14#define MLPACK_BINDINGS_GO_PRINT_DEFN_INPUT_HPP
15
16#include <mlpack/prereqs.hpp>
18#include "get_go_type.hpp"
19#include "strip_type.hpp"
20
21namespace mlpack {
22namespace bindings {
23namespace go {
24
28template<typename T>
31 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
32 const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
33 const typename boost::disable_if<std::is_same<T,
34 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
35{
36 if (d.required)
37 {
38 std::string name = d.name;
39 std::cout << util::CamelCase(name, true) << " " << GetGoType<T>(d);
40 }
41}
42
46template<typename T>
49 const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
50{
51 // param_name *mat.Dense
52 if (d.required)
53 {
54 std::string name = d.name;
55 std::cout << util::CamelCase(name, true) << " *" << GetGoType<T>(d);
56 }
57}
58
62template<typename T>
65 const typename boost::enable_if<std::is_same<T,
66 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
67{
68 // param_name *DataWithInfo
69 if (d.required)
70 {
71 std::string name = d.name;
72 std::cout << util::CamelCase(name, true) << " *" << GetGoType<T>(d);
73 }
74}
75
79template<typename T>
82 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
83 const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
84{
85 // Get the type names we need to use.
86 std::string goStrippedType, strippedType, printedType, defaultsType;
87 StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType);
88
89 // param_name *ModelName
90 if (d.required)
91 {
92 std::string name = d.name;
93 std::cout << util::CamelCase(name, true) << " *" << goStrippedType;
94 }
95}
96
111template<typename T>
113 const void* /* input */,
114 void* /* output */)
115{
116 PrintDefnInput<typename std::remove_pointer<T>::type>(d);
117}
118
119} // namespace go
120} // namespace bindings
121} // namespace mlpack
122
123#endif
go
Definition: CMakeLists.txt:6
void StripType(const std::string &inputType, std::string &goStrippedType, std::string &strippedType, std::string &printedType, std::string &defaultsType)
Given an input type like, e.g., "LogisticRegression<>", return four types that can be used in Go code...
Definition: strip_type.hpp:30
void PrintDefnInput(util::ParamData &d, const typename boost::disable_if< arma::is_arma_type< 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 input in method definition for a regular parameter type.
std::string CamelCase(std::string s, bool lower)
Given an snake_case like, e.g., "logistic_regression", return CamelCase(e.g.
Definition: camel_case.hpp:26
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.
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:53
bool required
True if this option is required.
Definition: param_data.hpp:71
std::string name
Name of this parameter.
Definition: param_data.hpp:56
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:84