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 std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
33  const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
34  const typename std::enable_if<!std::is_same<T,
35  std::tuple<data::DatasetInfo, arma::mat>>::value>::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<T>(d)
49  << "(params, \"" << d.name << "\")" << std::endl;
50 }
51 
55 template<typename T>
57  util::ParamData& d,
58  const size_t indent,
59  const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
60  const typename std::enable_if<!std::is_same<T,
61  std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
62 {
63  const std::string prefix(indent, ' ');
64 
73  std::string name = d.name;
74  name = util::CamelCase(name, true);
75  std::cout << prefix << "var " << name << "Ptr mlpackArma" << std::endl;
76  std::cout << prefix << name << " := " << name
77  << "Ptr.armaToGonum" << GetType<T>(d)
78  << "(params, \"" << d.name << "\")" << std::endl;
79 }
83 template<typename T>
85  util::ParamData& d,
86  const size_t indent,
87  const typename std::enable_if<std::is_same<T,
88  std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
89 {
90  const std::string prefix(indent, ' ');
91 
100  std::string name = d.name;
101  name = util::CamelCase(name, true);
102  std::cout << prefix << "var " << name << "Ptr mlpackArma" << std::endl;
103  std::cout << prefix << name << " := " << name << "Ptr.armaToGonumWith"
104  << "Info(params, \"" << d.name << "\")" << std::endl;
105 }
106 
110 template<typename T>
112  util::ParamData& d,
113  const size_t indent,
114  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
115  const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
116 {
117  // Get the type names we need to use.
118  std::string goStrippedType, strippedType, printedType, defaultsType;
119  StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType);
120 
121  const std::string prefix(indent, ' ');
122 
130  std::string name = d.name;
131  name = util::CamelCase(name, true);
132  std::cout << prefix << "var " << name << " " << goStrippedType << std::endl;
133  std::cout << prefix << name << ".get" << strippedType
134  << "(params, \"" << d.name << "\")" << std::endl;
135 }
136 
142 template<typename T>
144  const void* /*input*/,
145  void* /* output */)
146 {
147  PrintOutputProcessing<typename std::remove_pointer<T>::type>(d, 2);
148 }
149 
150 } // namespace go
151 } // namespace bindings
152 } // namespace mlpack
153 
154 #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:7
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:51
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:55
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:80
void PrintOutputProcessing(util::ParamData &d, const size_t indent, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0, const typename std::enable_if<!std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *=0)
Print output processing for a regular parameter type.