12 #ifndef MLPACK_BINDINGS_GO_PRINT_INPUT_PROCESSING_HPP 13 #define MLPACK_BINDINGS_GO_PRINT_INPUT_PROCESSING_HPP 32 const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
34 const typename std::enable_if<!std::is_same<T,
35 std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
37 const std::string prefix(indent,
' ');
39 std::string def =
"nil";
40 if (std::is_same<T, bool>::value)
45 std::string paramName = d.
name;
46 std::string goParamName = paramName;
47 if (!paramName.empty())
61 std::cout << prefix <<
"// Detect if the parameter was passed; set if so." 65 std::cout << prefix <<
"if param." << goParamName <<
" != ";
70 std::string value = boost::any_cast<std::string>(d.
value);
71 std::cout <<
"\"" << value <<
"\"";
75 double value = boost::any_cast<
double>(d.
value);
80 int value = boost::any_cast<
int>(d.
value);
85 bool value = boost::any_cast<
bool>(d.
value);
91 else if (GetType<T>(d) ==
"VecString" || GetType<T>(d) ==
"VecInt")
97 std::cout <<
" {" << std::endl;
98 std::cout << prefix << prefix <<
"setParam" << GetType<T>(d) <<
"(params, " 99 <<
"\"" << d.
name <<
"\", param." << goParamName <<
")" 103 std::cout << prefix << prefix <<
"setPassed(params, \"" 104 << d.
name <<
"\")" << std::endl;
108 std::cout << prefix << prefix <<
"enableVerbose()" << std::endl;
110 std::cout << prefix <<
"}" << std::endl;
116 std::cout << prefix <<
"setParam" << GetType<T>(d) <<
"(params, \"" 117 << d.
name <<
"\", " << goParamName <<
")" 121 std::cout << prefix <<
"setPassed(params, \"" << d.
name <<
"\")" 124 std::cout << std::endl;
134 const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
136 const std::string prefix(indent,
' ');
140 std::string paramName = d.
name;
141 std::string goParamName = paramName;
142 if (!paramName.empty())
156 std::cout << prefix <<
"// Detect if the parameter was passed; set if so." 160 std::cout << prefix <<
"if param." << goParamName
161 <<
" != nil {" << std::endl;
164 std::cout << prefix << prefix <<
"gonumToArma" << GetType<T>(d)
165 <<
"(params, \"" << d.
name <<
"\", param." << goParamName
169 std::cout << prefix << prefix <<
"setPassed(params, \"" << d.
name <<
"\")" 171 std::cout << prefix <<
"}" << std::endl;
177 std::cout << prefix <<
"gonumToArma" << GetType<T>(d)
178 <<
"(params, \"" << d.
name <<
"\", " << goParamName
182 std::cout << prefix <<
"setPassed(params, \"" << d.
name <<
"\")" 185 std::cout << std::endl;
195 const typename std::enable_if<std::is_same<T,
196 std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
198 const std::string prefix(indent,
' ');
202 std::string paramName = d.
name;
203 std::string goParamName = paramName;
204 if (!paramName.empty())
218 std::cout << prefix <<
"// Detect if the parameter was passed; set if so." 222 std::cout << prefix <<
"if param." << goParamName
223 <<
" != nil {" << std::endl;
226 std::cout << prefix << prefix <<
"gonumToArmaMatWithInfo" 227 <<
"(params, \"" << d.
name <<
"\", param." << goParamName
231 std::cout << prefix << prefix <<
"setPassed(params, \"" << d.
name <<
"\")" 233 std::cout << prefix <<
"}" << std::endl;
239 std::cout << prefix <<
"gonumToArmaMatWithInfo" 240 <<
"(params, \"" << d.
name <<
"\", " << goParamName
244 std::cout << prefix <<
"setPassed(params, \"" << d.
name <<
"\")" 247 std::cout << std::endl;
257 const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
261 std::string goStrippedType, strippedType, printedType, defaultsType;
262 StripType(d.
cppType, goStrippedType, strippedType, printedType, defaultsType);
264 const std::string prefix(indent,
' ');
268 std::string paramName = d.
name;
269 std::string goParamName = paramName;
270 if (!paramName.empty())
284 std::cout << prefix <<
"// Detect if the parameter was passed; set if so." 288 std::cout << prefix <<
"if param." << goParamName <<
" != nil {" 291 std::cout << prefix << prefix <<
"set" << strippedType <<
"(params, \"" 292 << d.
name <<
"\", param." << goParamName <<
")" << std::endl;
295 std::cout << prefix << prefix <<
"setPassed(params, \"" << d.
name <<
"\")" 297 std::cout << prefix <<
"}" << std::endl;
303 std::cout << prefix <<
"set" << strippedType <<
"(params, \"" << d.
name 304 <<
"\", " << goParamName <<
")" << std::endl;
307 std::cout << prefix <<
"setPassed(params, \"" << d.
name <<
"\")" 310 std::cout << std::endl;
329 PrintInputProcessing<typename std::remove_pointer<T>::type>(d,
boost::any value
The actual value that is held.
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...
Linear algebra utility functions, generally performed on matrices or vectors.
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...
std::string CamelCase(std::string s, bool lower)
Given an snake_case like, e.g., "logistic_regression", return CamelCase(e.g.
void PrintInputProcessing(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 input processing for a standard option type.
std::string name
Name of this parameter.
bool required
True if this option is required.
std::string cppType
The true name of the type, as it would be written in C++.
if(NOT BUILD_GO_SHLIB) macro(add_go_binding name) endmacro() return() endif() endmacro() macro(post_go_setup) if(BUILD_GO_BINDINGS) file(APPEND "$