13 #ifndef MLPACK_BINDINGS_JULIA_PRINT_PARAM_DEFN_HPP 14 #define MLPACK_BINDINGS_JULIA_PRINT_PARAM_DEFN_HPP 29 const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
42 const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
54 const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
101 std::cout <<
"import ..." << type << std::endl;
102 std::cout << std::endl;
105 std::cout <<
"# Get the value of a model pointer parameter of type " << type
107 std::cout <<
"function GetParam" << type <<
"(params::Ptr{Nothing}, " 108 <<
"paramName::String, modelPtrs::Set{Ptr{Nothing}})::" << type
110 std::cout <<
" ptr = ccall((:GetParam" << type
111 <<
"Ptr, " << programName <<
"Library), Ptr{Nothing}, (Ptr{Nothing}, " 112 <<
"Cstring,), params, paramName)" << std::endl;
113 std::cout <<
" return " << type <<
"(ptr; finalize=!(ptr in modelPtrs))" 115 std::cout <<
"end" << std::endl;
116 std::cout << std::endl;
119 std::cout <<
"# Set the value of a model pointer parameter of type " << type
121 std::cout <<
"function SetParam" << type <<
"(params::Ptr{Nothing}, " 122 <<
"paramName::String, model::" << type <<
")" << std::endl;
123 std::cout <<
" ccall((:SetParam" << type <<
"Ptr, " 124 << programName <<
"Library), Nothing, (Ptr{Nothing}, Cstring, " 125 <<
"Ptr{Nothing}), params, paramName, model.ptr)" << std::endl;
126 std::cout <<
"end" << std::endl;
127 std::cout << std::endl;
130 std::cout <<
"# Delete an instantiated model pointer." << std::endl;
131 std::cout <<
"function Delete" << type <<
"(ptr::Ptr{Nothing})" 133 std::cout <<
" ccall((:Delete" << type <<
"Ptr, " << programName
134 <<
"Library), Nothing, (Ptr{Nothing},), ptr)" << std::endl;
135 std::cout <<
"end" << std::endl;
136 std::cout << std::endl;
139 std::cout <<
"# Serialize a model to the given stream." << std::endl;
140 std::cout <<
"function serialize" << type <<
"(stream::IO, model::" << type
142 std::cout <<
" buf_len = UInt[0]" << std::endl;
143 std::cout <<
" buf_ptr = ccall((:Serialize" << type <<
"Ptr, " << programName
144 <<
"Library), Ptr{UInt8}, (Ptr{Nothing}, Ptr{UInt}), model.ptr, " 145 <<
"Base.pointer(buf_len))" << std::endl;
146 std::cout <<
" buf = Base.unsafe_wrap(Vector{UInt8}, buf_ptr, buf_len[1]; " 147 <<
"own=true)" << std::endl;
148 std::cout <<
" write(stream, buf_len[1])" << std::endl;
149 std::cout <<
" write(stream, buf)" << std::endl;
150 std::cout <<
"end" << std::endl;
153 std::cout <<
"# Deserialize a model from the given stream." << std::endl;
154 std::cout <<
"function deserialize" << type <<
"(stream::IO)::" << type
156 std::cout <<
" buf_len = read(stream, UInt)" << std::endl;
157 std::cout <<
" buffer = read(stream, buf_len)" << std::endl;
158 std::cout <<
" " << type <<
"(ccall((:Deserialize" << type <<
"Ptr, " 159 << programName <<
"Library), Ptr{Nothing}, (Ptr{UInt8}, UInt), " 160 <<
"Base.pointer(buffer), length(buffer)))" << std::endl;
161 std::cout <<
"end" << std::endl;
173 PrintParamDefn<typename std::remove_pointer<T>::type>(d,
174 *(std::string*) input);
Linear algebra utility functions, generally performed on matrices or vectors.
void PrintParamDefn(util::ParamData &, const std::string &, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0)
If the type is not serializable, print nothing.
This structure holds all of the information about a single parameter, including its value (which is s...
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...
std::string cppType
The true name of the type, as it would be written in C++.