15 #ifndef MLPACK_CORE_UTIL_PARAM_HPP 16 #define MLPACK_CORE_UTIL_PARAM_HPP 22 class IncrementPolicy;
24 template<
typename PolicyType,
typename InputType>
27 using DatasetInfo = DatasetMapper<IncrementPolicy, std::string>;
39 #define JOIN(x, y) JOIN_AGAIN(x, y) 40 #define JOIN_AGAIN(x, y) x ## y 41 #define STRINGIFY(x) STRINGIFY_AGAIN(x) 42 #define STRINGIFY_AGAIN(x) #x 50 #define BINDING_FUNCTION(...) BINDING_NAME(__VA_ARGS__) 66 #define BINDING_USER_NAME(NAME) static \ 67 mlpack::util::BindingName \ 68 JOIN(io_bindingusername_dummy_object, __COUNTER__) = \ 69 mlpack::util::BindingName( \ 70 STRINGIFY(BINDING_NAME), NAME); 72 #define BINDING_USER_NAME(NAME) static \ 73 mlpack::util::BindingName \ 74 JOIN(JOIN(io_bindingusername_dummy_object, __LINE__), opt) = \ 75 mlpack::util::BindingName( \ 76 STRINGIFY(BINDING_NAME), NAME); 95 #define BINDING_SHORT_DESC(SHORT_DESC) static \ 96 mlpack::util::ShortDescription \ 97 JOIN(io_programshort_desc_dummy_object, __COUNTER__) = \ 98 mlpack::util::ShortDescription( \ 99 STRINGIFY(BINDING_NAME), SHORT_DESC); 101 #define BINDING_SHORT_DESC(SHORT_DESC) static \ 102 mlpack::util::ShortDescription \ 103 JOIN(JOIN(io_programshort_desc_dummy_object, __LINE__), opt) = \ 104 mlpack::util::ShortDescription( \ 105 STRINGIFY(BINDING_NAME), SHORT_DESC); 129 #define BINDING_LONG_DESC(LONG_DESC) static \ 130 mlpack::util::LongDescription \ 131 JOIN(io_programlong_desc_dummy_object, __COUNTER__) = \ 132 mlpack::util::LongDescription( \ 133 STRINGIFY(BINDING_NAME), []() { return std::string(LONG_DESC); }); 135 #define BINDING_LONG_DESC(LONG_DESC) static \ 136 mlpack::util::LongDescription \ 137 JOIN(JOIN(io_programlong_desc_dummy_object, __LINE__), opt) = \ 138 mlpack::util::LongDescription( \ 139 STRINGIFY(BINDING_NAME), []() { return std::string(LONG_DESC); }); 160 #define BINDING_EXAMPLE(EXAMPLE) static \ 161 mlpack::util::Example \ 162 JOIN(io_programexample_dummy_object_, __COUNTER__) = \ 163 mlpack::util::Example( \ 164 STRINGIFY(BINDING_NAME), []() { return(std::string(EXAMPLE)); }); 166 #define BINDING_EXAMPLE(EXAMPLE) static \ 167 mlpack::util::Example \ 168 JOIN(JOIN(io_programexample_dummy_object_, __LINE__), opt) = \ 169 mlpack::util::Example( \ 170 STRINGIFY(BINDING_NAME), []() { return(std::string(EXAMPLE)); }); 197 #define BINDING_SEE_ALSO(DESCRIPTION, LINK) static \ 198 mlpack::util::SeeAlso \ 199 JOIN(io_programsee_also_dummy_object_, __COUNTER__) = \ 200 mlpack::util::SeeAlso(STRINGIFY(BINDING_NAME), DESCRIPTION, LINK); 202 #define BINDING_SEE_ALSO(DESCRIPTION, LINK) static \ 203 mlpack::util::SeeAlso \ 204 JOIN(JOIN(io_programsee_also_dummy_object_, __LINE__), opt) = \ 205 mlpack::util::SeeAlso(STRINGIFY(BINDING_NAME), DESCRIPTION, LINK); 228 #define PARAM_FLAG(ID, DESC, ALIAS) \ 229 PARAM_IN(bool, ID, DESC, ALIAS, false, false); 256 #define PARAM_INT_IN(ID, DESC, ALIAS, DEF) \ 257 PARAM_IN(int, ID, DESC, ALIAS, DEF, false) 287 #define PARAM_INT_OUT(ID, DESC) \ 288 PARAM_OUT(int, ID, DESC, "", 0, false) 314 #define PARAM_DOUBLE_IN(ID, DESC, ALIAS, DEF) \ 315 PARAM_IN(double, ID, DESC, ALIAS, DEF, false) 345 #define PARAM_DOUBLE_OUT(ID, DESC) \ 346 PARAM_OUT(double, ID, DESC, "", 0.0, false) 374 #define PARAM_STRING_IN(ID, DESC, ALIAS, DEF) \ 375 PARAM_IN(std::string, ID, DESC, ALIAS, DEF, false) 406 #define PARAM_STRING_OUT(ID, DESC, ALIAS) \ 407 PARAM_OUT(std::string, ID, DESC, ALIAS, "", false) 434 #define PARAM_MATRIX_IN(ID, DESC, ALIAS) \ 435 PARAM_MATRIX(ID, DESC, ALIAS, false, true, true) 462 #define PARAM_MATRIX_IN_REQ(ID, DESC, ALIAS) \ 463 PARAM_MATRIX(ID, DESC, ALIAS, true, true, true) 495 #define PARAM_MATRIX_OUT(ID, DESC, ALIAS) \ 496 PARAM_MATRIX(ID, DESC, ALIAS, false, true, false) 524 #define PARAM_TMATRIX_IN(ID, DESC, ALIAS) \ 525 PARAM_MATRIX(ID, DESC, ALIAS, false, false, true) 554 #define PARAM_TMATRIX_IN_REQ(ID, DESC, ALIAS) \ 555 PARAM_MATRIX(ID, DESC, ALIAS, true, false, true) 589 #define PARAM_TMATRIX_OUT(ID, DESC, ALIAS) \ 590 PARAM_MATRIX(ID, DESC, ALIAS, false, false, false) 617 #define PARAM_UMATRIX_IN(ID, DESC, ALIAS) \ 618 PARAM_UMATRIX(ID, DESC, ALIAS, false, true, true) 646 #define PARAM_UMATRIX_IN_REQ(ID, DESC, ALIAS) \ 647 PARAM_UMATRIX(ID, DESC, ALIAS, true, true, true) 680 #define PARAM_UMATRIX_OUT(ID, DESC, ALIAS) \ 681 PARAM_UMATRIX(ID, DESC, ALIAS, false, true, false) 709 #define PARAM_COL_IN(ID, DESC, ALIAS) \ 710 PARAM_COL(ID, DESC, ALIAS, false, true, true) 737 #define PARAM_COL_IN_REQ(ID, DESC, ALIAS) \ 738 PARAM_COL(ID, DESC, ALIAS, true, true, true) 765 #define PARAM_ROW_IN(ID, DESC, ALIAS) \ 766 PARAM_ROW(ID, DESC, ALIAS, false, true, true) 793 #define PARAM_UCOL_IN(ID, DESC, ALIAS) \ 794 PARAM_UCOL(ID, DESC, ALIAS, false, true, true) 822 #define PARAM_UROW_IN(ID, DESC, ALIAS) \ 823 PARAM_UROW(ID, DESC, ALIAS, false, true, true) 855 #define PARAM_COL_OUT(ID, DESC, ALIAS) \ 856 PARAM_COL(ID, DESC, ALIAS, false, true, false) 888 #define PARAM_ROW_OUT(ID, DESC, ALIAS) \ 889 PARAM_ROW(ID, DESC, ALIAS, false, true, false) 921 #define PARAM_UCOL_OUT(ID, DESC, ALIAS) \ 922 PARAM_UCOL(ID, DESC, ALIAS, false, true, false) 954 #define PARAM_UROW_OUT(ID, DESC, ALIAS) \ 955 PARAM_UROW(ID, DESC, ALIAS, false, true, false) 981 #define PARAM_VECTOR_IN(T, ID, DESC, ALIAS) \ 982 PARAM_IN(std::vector<T>, ID, DESC, ALIAS, std::vector<T>(), false) 1015 #define PARAM_VECTOR_OUT(T, ID, DESC, ALIAS) \ 1016 PARAM_OUT(std::vector<T>, ID, DESC, ALIAS, std::vector<T>(), false) 1055 #define TUPLE_TYPE std::tuple<mlpack::data::DatasetInfo, arma::mat> 1056 #define PARAM_MATRIX_AND_INFO_IN(ID, DESC, ALIAS) \ 1057 PARAM(TUPLE_TYPE, ID, DESC, ALIAS, \ 1058 "std::tuple<mlpack::data::DatasetInfo, arma::mat>", false, true, true, \ 1089 #define PARAM_MODEL_IN(TYPE, ID, DESC, ALIAS) \ 1090 PARAM_MODEL(TYPE, ID, DESC, ALIAS, false, true) 1120 #define PARAM_MODEL_IN_REQ(TYPE, ID, DESC, ALIAS) \ 1121 PARAM_MODEL(TYPE, ID, DESC, ALIAS, true, true) 1145 #define PARAM_MODEL_OUT(TYPE, ID, DESC, ALIAS) \ 1146 PARAM_MODEL(TYPE, ID, DESC, ALIAS, false, false) 1170 #define PARAM_INT_IN_REQ(ID, DESC, ALIAS) \ 1171 PARAM_IN(int, ID, DESC, ALIAS, 0, true) 1195 #define PARAM_DOUBLE_IN_REQ(ID, DESC, ALIAS) \ 1196 PARAM_IN(double, ID, DESC, ALIAS, 0.0, true) 1220 #define PARAM_STRING_IN_REQ(ID, DESC, ALIAS) \ 1221 PARAM_IN(std::string, ID, DESC, ALIAS, "", true) 1247 #define PARAM_VECTOR_IN_REQ(T, ID, DESC, ALIAS) \ 1248 PARAM_IN(std::vector<T>, ID, DESC, ALIAS, std::vector<T>(), true); 1253 #define PARAM_IN(T, ID, DESC, ALIAS, DEF, REQ) \ 1254 PARAM(T, ID, DESC, ALIAS, #T, REQ, true, false, DEF); 1256 #define PARAM_OUT(T, ID, DESC, ALIAS, DEF, REQ) \ 1257 PARAM(T, ID, DESC, ALIAS, #T, REQ, false, false, DEF); 1259 #define PARAM_MATRIX(ID, DESC, ALIAS, REQ, TRANS, IN) \ 1260 PARAM(arma::mat, ID, DESC, ALIAS, "arma::mat", REQ, IN, \ 1261 TRANS, arma::mat()); 1263 #define PARAM_UMATRIX(ID, DESC, ALIAS, REQ, TRANS, IN) \ 1264 PARAM(arma::Mat<size_t>, ID, DESC, ALIAS, "arma::Mat<size_t>", \ 1265 REQ, IN, TRANS, arma::Mat<size_t>()); 1267 #define PARAM_COL(ID, DESC, ALIAS, REQ, TRANS, IN) \ 1268 PARAM(arma::vec, ID, DESC, ALIAS, "arma::vec", REQ, IN, TRANS, \ 1271 #define PARAM_UCOL(ID, DESC, ALIAS, REQ, TRANS, IN) \ 1272 PARAM(arma::Col<size_t>, ID, DESC, ALIAS, "arma::Col<size_t>", \ 1273 REQ, IN, TRANS, arma::Col<size_t>()); 1275 #define PARAM_ROW(ID, DESC, ALIAS, REQ, TRANS, IN) \ 1276 PARAM(arma::rowvec, ID, DESC, ALIAS, "arma::rowvec", REQ, IN, \ 1277 TRANS, arma::rowvec()); 1279 #define PARAM_UROW(ID, DESC, ALIAS, REQ, TRANS, IN) \ 1280 PARAM(arma::Row<size_t>, ID, DESC, ALIAS, "arma::Row<size_t>", \ 1281 REQ, IN, TRANS, arma::Row<size_t>()); 1300 #define PARAM(T, ID, DESC, ALIAS, NAME, REQ, IN, TRANS, DEF) \ 1301 static mlpack::util::Option<T> \ 1302 JOIN(io_option_dummy_object_in_, __COUNTER__) \ 1303 (DEF, ID, DESC, ALIAS, NAME, REQ, IN, !TRANS, STRINGIFY(BINDING_NAME)); 1305 #define PARAM_GLOBAL(T, ID, DESC, ALIAS, NAME, REQ, IN, TRANS, DEF) \ 1306 static mlpack::util::Option<T> \ 1307 JOIN(io_option_global_dummy_object_in_, __COUNTER__) \ 1308 (DEF, ID, DESC, ALIAS, NAME, REQ, IN, !TRANS, ""); 1312 #define PARAM_MODEL(TYPE, ID, DESC, ALIAS, REQ, IN) \ 1313 static mlpack::util::Option<TYPE*> \ 1314 JOIN(io_option_dummy_model_, __COUNTER__) \ 1315 (nullptr, ID, DESC, ALIAS, #TYPE, REQ, IN, false, \ 1316 STRINGIFY(BINDING_NAME)); 1322 #define PARAM(T, ID, DESC, ALIAS, NAME, REQ, IN, TRANS, DEF) \ 1323 static mlpack::util::Option<T> \ 1324 JOIN(JOIN(io_option_dummy_object_in_, __LINE__), opt) \ 1325 (DEF, ID, DESC, ALIAS, NAME, REQ, IN, !TRANS, STRINGIFY(BINDING_NAME)); 1327 #define PARAM_GLOBAL(T, ID, DESC, ALIAS, NAME, REQ, IN, TRANS, DEF) \ 1328 static mlpack::util::Option<T> \ 1329 JOIN(JOIN(io_option_global_dummy_object_in_, __LINE__), opt) \ 1330 (DEF, ID, DESC, ALIAS, NAME, REQ, IN, !TRANS, ""); 1332 #define PARAM_MODEL(TYPE, ID, DESC, ALIAS, REQ, IN) \ 1333 static mlpack::util::Option<TYPE*> \ 1334 JOIN(JOIN(io_option_dummy_object_model_, __LINE__), opt) \ 1335 (nullptr, ID, DESC, ALIAS, #TYPE, REQ, IN, false, \ 1336 STRINGIFY(BINDING_NAME)); Linear algebra utility functions, generally performed on matrices or vectors.
DatasetMapper< data::IncrementPolicy > DatasetInfo