13 #ifndef MLPACK_CORE_DATA_BINARIZE_HPP 14 #define MLPACK_CORE_DATA_BINARIZE_HPP 43 const double threshold)
45 output.copy_size(input);
47 const int totalElems =
static_cast<int>(input.n_elem);
48 const T *inPtr = input.memptr();
49 T *outPtr = output.memptr();
51 #pragma omp parallel for 52 for (
int i = 0; i < totalElems; ++i)
54 if (inPtr[i] > threshold)
85 const double threshold,
86 const size_t dimension)
89 const int totalCols =
static_cast<int>(input.n_cols);
91 #pragma omp parallel for 92 for (
int i = 0; i < totalCols; ++i)
94 if (input(dimension, i) > threshold)
95 output(dimension, i) = 1;
97 output(dimension, i) = 0;
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Binarize(const arma::Mat< T > &input, arma::Mat< T > &output, const double threshold)
Given an input dataset and threshold, set values greater than threshold to 1 and values less than or ...