12 #ifndef MLPACK_BINDINGS_GO_PRINT_INPUT_PROCESSING_HPP 13 #define MLPACK_BINDINGS_GO_PRINT_INPUT_PROCESSING_HPP 32 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
34 const typename boost::disable_if<std::is_same<T,
35 std::tuple<data::DatasetInfo, arma::mat>>>::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) <<
"(\"" 99 << d.
name <<
"\", param." << goParamName <<
")" << std::endl;
102 std::cout << prefix << prefix <<
"setPassed(\"" 103 << d.
name <<
"\")" << std::endl;
107 std::cout << prefix << prefix <<
"enableVerbose()" << std::endl;
109 std::cout << prefix <<
"}" << std::endl;
115 std::cout << prefix <<
"setParam" << GetType<T>(d) <<
"(\"" 116 << d.
name <<
"\", " << goParamName <<
")" 120 std::cout << prefix <<
"setPassed(\"" << d.
name <<
"\")" << std::endl;
122 std::cout << std::endl;
132 const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
134 const std::string prefix(indent,
' ');
138 std::string paramName = d.
name;
139 std::string goParamName = paramName;
140 if (!paramName.empty())
154 std::cout << prefix <<
"// Detect if the parameter was passed; set if so." 158 std::cout << prefix <<
"if param." << goParamName
159 <<
" != nil {" << std::endl;
162 std::cout << prefix << prefix <<
"gonumToArma" << GetType<T>(d)
163 <<
"(\"" << d.
name <<
"\", param." << goParamName
167 std::cout << prefix << prefix <<
"setPassed(\"" << d.
name <<
"\")" 169 std::cout << prefix <<
"}" << std::endl;
175 std::cout << prefix <<
"gonumToArma" << GetType<T>(d)
176 <<
"(\"" << d.
name <<
"\", " << goParamName
180 std::cout << prefix <<
"setPassed(\"" << d.
name <<
"\")" << std::endl;
182 std::cout << std::endl;
192 const typename boost::enable_if<std::is_same<T,
193 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
195 const std::string prefix(indent,
' ');
199 std::string paramName = d.
name;
200 std::string goParamName = paramName;
201 if (!paramName.empty())
215 std::cout << prefix <<
"// Detect if the parameter was passed; set if so." 219 std::cout << prefix <<
"if param." << goParamName
220 <<
" != nil {" << std::endl;
223 std::cout << prefix << prefix <<
"gonumToArmaMatWithInfo" 224 <<
"(\"" << d.
name <<
"\", param." << goParamName
228 std::cout << prefix << prefix <<
"setPassed(\"" << d.
name <<
"\")" 230 std::cout << prefix <<
"}" << std::endl;
236 std::cout << prefix <<
"gonumToArmaMatWithInfo" 237 <<
"(\"" << d.
name <<
"\", " << goParamName
241 std::cout << prefix <<
"setPassed(\"" << d.
name <<
"\")" << std::endl;
243 std::cout << std::endl;
253 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
257 std::string goStrippedType, strippedType, printedType, defaultsType;
258 StripType(d.
cppType, goStrippedType, strippedType, printedType, defaultsType);
260 const std::string prefix(indent,
' ');
264 std::string paramName = d.
name;
265 std::string goParamName = paramName;
266 if (!paramName.empty())
280 std::cout << prefix <<
"// Detect if the parameter was passed; set if so." 284 std::cout << prefix <<
"if param." << goParamName <<
" != nil {" 287 std::cout << prefix << prefix <<
"set" << strippedType <<
"(\"" 288 << d.
name <<
"\", param." << goParamName <<
")" << std::endl;
291 std::cout << prefix << prefix <<
"setPassed(\"" << d.
name <<
"\")" 293 std::cout << prefix <<
"}" << std::endl;
299 std::cout << prefix <<
"set" << strippedType <<
"(\"" << d.
name 300 <<
"\", " << goParamName <<
")" << std::endl;
303 std::cout << prefix <<
"setPassed(\"" << d.
name <<
"\")" << std::endl;
305 std::cout << std::endl;
324 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.
std::string name
Name of this parameter.
bool required
True if this option is required.
void PrintInputProcessing(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 input processing for a standard option type.
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 "$