forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.cpp
More file actions
63 lines (48 loc) · 1.5 KB
/
diff.cpp
File metadata and controls
63 lines (48 loc) · 1.5 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
54
55
56
57
58
59
60
61
62
63
/*******************************************************
* 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 <diff.hpp>
#include <Array.hpp>
#include <kernel/diff.hpp>
#include <platform.hpp>
#include <af/dim4.hpp>
namespace cpu {
template<typename T>
Array<T> diff1(const Array<T> &in, const int dim) {
// Decrement dimension of select dimension
af::dim4 dims = in.dims();
dims[dim]--;
Array<T> outArray = createEmptyArray<T>(dims);
getQueue().enqueue(kernel::diff1<T>, outArray, in, dim);
return outArray;
}
template<typename T>
Array<T> diff2(const Array<T> &in, const int dim) {
// Decrement dimension of select dimension
af::dim4 dims = in.dims();
dims[dim] -= 2;
Array<T> outArray = createEmptyArray<T>(dims);
getQueue().enqueue(kernel::diff2<T>, outArray, in, dim);
return outArray;
}
#define INSTANTIATE(T) \
template Array<T> diff1<T>(const Array<T> &in, const int dim); \
template Array<T> diff2<T>(const Array<T> &in, const int dim);
INSTANTIATE(float)
INSTANTIATE(double)
INSTANTIATE(cfloat)
INSTANTIATE(cdouble)
INSTANTIATE(int)
INSTANTIATE(uint)
INSTANTIATE(intl)
INSTANTIATE(uintl)
INSTANTIATE(uchar)
INSTANTIATE(char)
INSTANTIATE(ushort)
INSTANTIATE(short)
} // namespace cpu