13 #ifndef MLPACK_BINDINGS_PYTHON_PRINT_OUTPUT_PROCESSING_HPP    14 #define MLPACK_BINDINGS_PYTHON_PRINT_OUTPUT_PROCESSING_HPP    33     const bool onlyOutput,
    34     const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
    36     const typename std::enable_if<!std::is_same<T,
    37         std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
    39   const std::string prefix(indent, 
' ');
    48     std::cout << prefix << 
"result = " << 
"p.Get[" << GetCythonType<T>(d)
    49         << 
"](\"" << d.
name << 
"\")";
    50     if (GetCythonType<T>(d) == 
"string")
    52       std::cout << std::endl << prefix << 
"result = result.decode(\"UTF-8\")";
    54     else if (GetCythonType<T>(d) == 
"vector[string]")
    56       std::cout << std::endl << prefix
    57           << 
"result = [x.decode(\"UTF-8\") for x in result]";
    67     std::cout << prefix << 
"result['" << d.
name << 
"'] = p.Get["    68         << GetCythonType<T>(d) << 
"](\"" << d.
name << 
"\")" << std::endl;
    69     if (GetCythonType<T>(d) == 
"string")
    71       std::cout << prefix << 
"result['" << d.
name << 
"'] = result['" << d.
name    72           << 
"'].decode(\"UTF-8\")" << std::endl;
    74     else if (GetCythonType<T>(d) == 
"vector[string]")
    76       std::cout << prefix << 
"result['" << d.
name << 
"'] = [x.decode(\"UTF-8\")"    77           << 
" for x in result['" << d.
name << 
"']]" << std::endl;
    90     const bool onlyOutput,
    91     const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
    93   const std::string prefix(indent, 
' ');
   104     std::cout << prefix << 
"result = arma_numpy." << GetArmaType<T>()
   105         << 
"_to_numpy_" << GetNumpyTypeChar<T>() << 
"(p.Get["   106         << GetCythonType<T>(d) << 
"](\"" << d.
name << 
"\"))" << std::endl;
   118     std::cout << prefix << 
"result['" << d.
name   119         << 
"'] = arma_numpy." << GetArmaType<T>() << 
"_to_numpy_"   120         << GetNumpyTypeChar<T>() << 
"(p.Get[" << GetCythonType<T>(d)
   121         << 
"]('" << d.
name << 
"'))" << std::endl;
   133     const bool onlyOutput,
   134     const typename std::enable_if<std::is_same<T,
   135         std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
   137   const std::string prefix(indent, 
' ');
   148     std::cout << prefix << 
"result = arma_numpy.mat_to_numpy_"   149         << GetNumpyTypeChar<arma::mat>()
   150         << 
"(GetParamWithInfo[arma.Mat[double]](p, '" << d.
name << 
"'))"   161     std::cout << prefix << 
"result['" << d.
name   162         << 
"'] = arma_numpy.mat_to_numpy_" << GetNumpyTypeChar<arma::mat>()
   163         << 
"(GetParamWithInfo[arma.Mat[double]](p, '" << d.
name << 
"'))"   176     const bool onlyOutput,
   177     const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
   181   std::string strippedType, printedType, defaultsType;
   184   const std::string prefix(indent, 
' ');
   194     std::cout << prefix << 
"result = " << strippedType << 
"Type()" << std::endl;
   195     std::cout << prefix << 
"(<" << strippedType << 
"Type?> result).modelptr = "   196         << 
"GetParamPtr[" << strippedType << 
"](p, '" << d.
name << 
"')"   205     std::map<std::string, util::ParamData>& parameters = params.
Parameters();
   206     for (
auto it = parameters.begin(); it != parameters.end(); ++it)
   212         std::cout << prefix << 
"if (<" << strippedType
   213             << 
"Type> result).modelptr" << d.
name << 
" == (<" << strippedType
   214             << 
"Type> " << data.
name << 
").modelptr:" << std::endl;
   215         std::cout << prefix << 
"  (<" << strippedType
   216             << 
"Type> result).modelptr = <" << strippedType << 
"*> 0"   218         std::cout << prefix << 
"  result = " << data.
name << std::endl;
   222         std::cout << prefix << 
"if " << data.
name << 
" is not None:"   224         std::cout << prefix << 
"  if (<" << strippedType
   225             << 
"Type> result).modelptr" << d.
name << 
" == (<" << strippedType
   226             << 
"Type> " << data.
name << 
").modelptr:" << std::endl;
   227         std::cout << prefix << 
"    (<" << strippedType
   228             << 
"Type> result).modelptr = <" << strippedType << 
"*> 0"   230         std::cout << prefix << 
"    result = " << data.
name << std::endl;
   242     std::cout << prefix << 
"result['" << d.
name << 
"'] = " << strippedType
   243         << 
"Type()" << std::endl;
   244     std::cout << prefix << 
"(<" << strippedType << 
"Type?> result['" << d.
name   245         << 
"']).modelptr = GetParamPtr[" << strippedType << 
"](p, '" << d.
name   246         << 
"')" << std::endl;
   254     std::map<std::string, util::ParamData>& parameters = params.
Parameters();
   255     for (
auto it = parameters.begin(); it != parameters.end(); ++it)
   261         std::cout << prefix << 
"if (<" << strippedType << 
"Type> result['"   262             << d.
name << 
"']).modelptr == (<" << strippedType << 
"Type> "   263             << data.
name << 
").modelptr:" << std::endl;
   264         std::cout << prefix << 
"  (<" << strippedType << 
"Type> result['"   265             << d.
name << 
"']).modelptr = <" << strippedType << 
"*> 0"   267         std::cout << prefix << 
"  result['" << d.
name << 
"'] = " << data.
name   272         std::cout << prefix << 
"if " << data.
name << 
" is not None:"   274         std::cout << prefix << 
"  if (<" << strippedType << 
"Type> result['"   275             << d.
name << 
"']).modelptr == (<" << strippedType << 
"Type> "   276             << data.
name << 
").modelptr:" << std::endl;
   277         std::cout << prefix << 
"    (<" << strippedType << 
"Type> result['"   278             << d.
name << 
"']).modelptr = <" << strippedType << 
"*> 0"   280         std::cout << prefix << 
"    result['" << d.
name << 
"'] = " << data.
name   308   typedef std::tuple<util::Params, std::tuple<size_t, bool>> TupleType;
   309   TupleType* tuple = (TupleType*) input;
   311   PrintOutputProcessing<typename std::remove_pointer<T>::type>(std::get<0>(*tuple),
   312       d, std::get<0>(std::get<1>(*tuple)), std::get<1>(std::get<1>(*tuple)));
 
Linear algebra utility functions, generally performed on matrices or vectors. 
 
void PrintOutputProcessing(util::Params &, util::ParamData &d, const size_t indent, const bool onlyOutput, 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. 
 
The core includes that mlpack expects; standard C++ includes and Armadillo. 
 
bool input
True if this option is an input option (otherwise, it is output). 
 
std::map< std::string, ParamData > & Parameters()
Get the map of parameters. 
 
This structure holds all of the information about a single parameter, including its value (which is s...
 
std::string name
Name of this parameter. 
 
bool required
True if this option is required. 
 
void StripType(const std::string &inputType, std::string &strippedType, std::string &printedType, std::string &defaultsType)
Given an input type like, e.g., "LogisticRegression<>", return three types that can be used in Python...
 
The Params class holds all information about the parameters passed to a specific binding. 
 
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 "$