mlpack 3.4.2
print_input_processing.hpp
Go to the documentation of this file.
1
12#ifndef MLPACK_BINDINGS_R_PRINT_INPUT_PROCESSING_IMPL_HPP
13#define MLPACK_BINDINGS_R_PRINT_INPUT_PROCESSING_IMPL_HPP
14
16#include "get_type.hpp"
17#include <mlpack/prereqs.hpp>
18
19namespace mlpack {
20namespace bindings {
21namespace r {
22
26template<typename T>
29 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
30 const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
31 const typename boost::disable_if<std::is_same<T,
32 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
33{
34 if (!d.required)
35 {
43 MLPACK_COUT_STREAM << " if (!identical(" << d.name;
44 if (d.cppType == "bool")
45 {
46 MLPACK_COUT_STREAM << ", FALSE)) {" << std::endl;
47 }
48 else
49 {
50 MLPACK_COUT_STREAM << ", NA)) {" << std::endl;
51 }
52 MLPACK_COUT_STREAM << " IO_SetParam" << GetType<T>(d) << "(\""
53 << d.name << "\", " << d.name << ")" << std::endl;
54 MLPACK_COUT_STREAM << " }" << std::endl; // Closing brace.
55 }
56 else
57 {
63 MLPACK_COUT_STREAM << " IO_SetParam" << GetType<T>(d) << "(\""
64 << d.name << "\", " << d.name << ")" << std::endl;
65 }
66 MLPACK_COUT_STREAM << std::endl; // Extra line is to clear up the code a bit.
67}
68
72template<typename T>
75 const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
76{
77 if (!d.required)
78 {
86 MLPACK_COUT_STREAM << " if (!identical(" << d.name << ", NA)) {"
87 << std::endl;
88 MLPACK_COUT_STREAM << " IO_SetParam" << GetType<T>(d) << "(\""
89 << d.name << "\", to_matrix(" << d.name << "))" << std::endl;
90 MLPACK_COUT_STREAM << " }" << std::endl; // Closing brace.
91 }
92 else
93 {
99 MLPACK_COUT_STREAM << " IO_SetParam" << GetType<T>(d) << "(\""
100 << d.name << "\", to_matrix(" << d.name << "))" << std::endl;
101 }
102 MLPACK_COUT_STREAM << std::endl; // Extra line is to clear up the code a bit.
103}
104
108template<typename T>
111 const typename boost::enable_if<std::is_same<T,
112 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
113{
114 if (!d.required)
115 {
125 MLPACK_COUT_STREAM << " if (!identical(" << d.name << ", NA)) {"
126 << std::endl;
127 MLPACK_COUT_STREAM << " " << d.name << " <- to_matrix_with_info("
128 << d.name << ")" << std::endl;
129 MLPACK_COUT_STREAM << " IO_SetParam" << GetType<T>(d) << "(\""
130 << d.name << "\", " << d.name << "$info, " << d.name
131 << "$data)" << std::endl;
132 MLPACK_COUT_STREAM << " }" << std::endl; // Closing brace.
133 }
134 else
135 {
143 MLPACK_COUT_STREAM << " " << d.name << " <- to_matrix_with_info("
144 << d.name << ")" << std::endl;
145 MLPACK_COUT_STREAM << " IO_SetParam" << GetType<T>(d) << "(\""
146 << d.name << "\", " << d.name << "$info, " << d.name
147 << "$data)" << std::endl;
148 }
149 MLPACK_COUT_STREAM << std::endl; // Extra line is to clear up the code a bit.
150}
151
155template<typename T>
158 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
159 const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
160{
161 if (!d.required)
162 {
170 MLPACK_COUT_STREAM << " if (!identical(" << d.name << ", NA)) {"
171 << std::endl;
172 MLPACK_COUT_STREAM << " IO_SetParam" << util::StripType(d.cppType)
173 << "Ptr(\"" << d.name << "\", " << d.name << ")" << std::endl;
174 MLPACK_COUT_STREAM << " }" << std::endl; // Closing brace.
175 }
176 else
177 {
183 MLPACK_COUT_STREAM << " IO_SetParam" << util::StripType(d.cppType)
184 << "Ptr(\"" << d.name << "\", " << d.name << ")" << std::endl;
185 }
186 MLPACK_COUT_STREAM << std::endl; // Extra line is to clear up the code a bit.
187}
188
194template<typename T>
196 const void* /* input */,
197 void* /* output */)
198{
199 PrintInputProcessing<typename std::remove_pointer<T>::type>(d);
200}
201
202} // namespace r
203} // namespace bindings
204} // namespace mlpack
205
206#endif
void PrintInputProcessing(util::ParamData &d, 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 StripType(std::string cppType)
Given a C++ type name, turn it into something that has no special characters that can simply be print...
Definition: strip_type.hpp:27
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.
#define MLPACK_COUT_STREAM
Definition: prereqs.hpp:45
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:53
bool required
True if this option is required.
Definition: param_data.hpp:71
std::string name
Name of this parameter.
Definition: param_data.hpp:56
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:84