mlpack
3.4.2
mlpack-3.4.2
src
mlpack
core
data
binarize.hpp
Go to the documentation of this file.
1
13
#ifndef MLPACK_CORE_DATA_BINARIZE_HPP
14
#define MLPACK_CORE_DATA_BINARIZE_HPP
15
16
#include <
mlpack/prereqs.hpp
>
17
18
namespace
mlpack
{
19
namespace
data {
20
40
template
<
typename
T>
41
void
Binarize
(
const
arma::Mat<T>& input,
42
arma::Mat<T>& output,
43
const
double
threshold)
44
{
45
output.copy_size(input);
46
47
const
T *inPtr = input.memptr();
48
T *outPtr = output.memptr();
49
50
#pragma omp parallel for
51
for
(
omp_size_t
i = 0; i < (
omp_size_t
) input.n_elem; ++i)
52
outPtr[i] = inPtr[i] > threshold;
53
}
54
76
template
<
typename
T>
77
void
Binarize
(
const
arma::Mat<T>& input,
78
arma::Mat<T>& output,
79
const
double
threshold,
80
const
size_t
dimension)
81
{
82
output = input;
83
84
#pragma omp parallel for
85
for
(
omp_size_t
i = 0; i < (
omp_size_t
) input.n_cols; ++i)
86
output(dimension, i) = input(dimension, i) > threshold;
87
}
88
89
}
// namespace data
90
}
// namespace mlpack
91
92
#endif
prereqs.hpp
The core includes that mlpack expects; standard C++ includes and Armadillo.
mlpack
Linear algebra utility functions, generally performed on matrices or vectors.
Definition:
add_to_cli11.hpp:21
omp_size_t
#define omp_size_t
Definition:
prereqs.hpp:136
mlpack::data::Binarize
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 ...
Definition:
binarize.hpp:41
Generated by
1.8.20