print_output_processing.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_GO_PRINT_OUTPUT_PROCESSING_HPP
14 #define MLPACK_BINDINGS_GO_PRINT_OUTPUT_PROCESSING_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 #include "get_type.hpp"
18 #include "strip_type.hpp"
20 
21 namespace mlpack {
22 namespace bindings {
23 namespace go {
24 
28 template<typename T>
30  util::ParamData& d,
31  const size_t indent,
32  const typename boost::disable_if>::type* = 0,
33  const typename boost::disable_if<data::HasSerialize>::type* = 0,
34  const typename boost::disable_if
35  std::tuple>>::type* = 0)
36 {
37  const std::string prefix(indent, ' ');
38 
46  std::string name = d.name;
47  name = util::CamelCase(name, true);
48  std::cout << prefix << name << " := getParam" << GetType(d)
49  << "(\"" << d.name << "\")" << std::endl;
50 }
51 
55 template<typename T>
57  util::ParamData& d,
58  const size_t indent,
59  const typename boost::enable_if>::type* = 0,
60  const typename std::enable_if
61  std::tuple>::value>::type* = 0)
62 {
63  const std::string prefix(indent, ' ');
64 
72  std::string name = d.name;
73  name = util::CamelCase(name, true);
74  std::cout << prefix << "var " << name << "Ptr mlpackArma" << std::endl;
75  std::cout << prefix << name << " := " << name
76  << "Ptr.armaToGonum" << GetType(d)
77  << "(\"" << d.name << "\")" << std::endl;
78 }
82 template<typename T>
84  util::ParamData& d,
85  const size_t indent,
86  const typename boost::enable_if
87  std::tuple>>::type* = 0)
88 {
89  const std::string prefix(indent, ' ');
90 
98  std::string name = d.name;
99  name = util::CamelCase(name, true);
100  std::cout << prefix << "var " << name << "Ptr mlpackArma" << std::endl;
101  std::cout << prefix << name << " := " << name << "Ptr.armaToGonumWith"
102  << "Info(\"" << d.name << "\")" << std::endl;
103 }
104 
108 template<typename T>
110  util::ParamData& d,
111  const size_t indent,
112  const typename boost::disable_if>::type* = 0,
113  const typename boost::enable_if<data::HasSerialize>::type* = 0)
114 {
115  // Get the type names we need to use.
116  std::string goStrippedType, strippedType, printedType, defaultsType;
117  StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType);
118 
119  const std::string prefix(indent, ' ');
120 
128  std::string name = d.name;
129  name = util::CamelCase(name, true);
130  std::cout << prefix << "var " << name << " " << goStrippedType << std::endl;
131  std::cout << prefix << name << ".get" << strippedType
132  << "(\"" << d.name << "\")" << std::endl;
133 }
134 
140 template<typename T>
142  const void* /*input*/,
143  void* /* output */)
144 {
145  PrintOutputProcessing::type>(d, 2);
146 }
147 
148 } // namespace go
149 } // namespace bindings
150 } // namespace mlpack
151 
152 #endif
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
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
go
Definition: CMakeLists.txt:6
void PrintOutputProcessing(util::ParamData &d, const size_t indent, 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 output processing for a regular parameter type.
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
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
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