-
Notifications
You must be signed in to change notification settings - Fork 548
Expand file tree
/
Copy pathhistogram.cpp
More file actions
53 lines (46 loc) · 1.53 KB
/
histogram.cpp
File metadata and controls
53 lines (46 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <Array.hpp>
#include <common/half.hpp>
#include <err_cuda.hpp>
#include <histogram.hpp>
#include <kernel/histogram.hpp>
#include <af/dim4.hpp>
using af::dim4;
using arrayfire::common::half;
namespace arrayfire {
namespace cuda {
template<typename T>
Array<uint> histogram(const Array<T> &in, const unsigned &nbins,
const double &minval, const double &maxval,
const bool isLinear) {
const dim4 &dims = in.dims();
dim4 outDims = dim4(nbins, 1, dims[2], dims[3]);
Array<uint> out = createValueArray<uint>(outDims, uint(0));
kernel::histogram<T>(out, in, nbins, minval, maxval, isLinear);
return out;
}
#define INSTANTIATE(T) \
template Array<uint> histogram<T>(const Array<T> &, const unsigned &, \
const double &, const double &, \
const bool);
INSTANTIATE(float)
INSTANTIATE(double)
INSTANTIATE(char)
INSTANTIATE(int)
INSTANTIATE(uint)
INSTANTIATE(schar)
INSTANTIATE(uchar)
INSTANTIATE(short)
INSTANTIATE(ushort)
INSTANTIATE(intl)
INSTANTIATE(uintl)
INSTANTIATE(half)
} // namespace cuda
} // namespace arrayfire