forked from hunter-packages/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresize.cpp
More file actions
64 lines (56 loc) · 2.37 KB
/
resize.cpp
File metadata and controls
64 lines (56 loc) · 2.37 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
64
/*******************************************************
* 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 <af/array.h>
#include <af/defines.h>
#include <err_common.hpp>
#include <handle.hpp>
#include <backend.hpp>
#include <ArrayInfo.hpp>
#include <resize.hpp>
using af::dim4;
using namespace detail;
template<typename T>
static inline af_array resize(const af_array in, const dim_t odim0, const dim_t odim1,
const af_interp_type method)
{
return getHandle(resize<T>(getArray<T>(in), odim0, odim1, method));
}
af_err af_resize(af_array *out, const af_array in, const dim_t odim0, const dim_t odim1,
const af_interp_type method)
{
try {
ArrayInfo info = getInfo(in);
af_dtype type = info.getType();
ARG_ASSERT(4, (method == AF_INTERP_BILINEAR ||
method == AF_INTERP_NEAREST ||
method == AF_INTERP_LOWER
));
DIM_ASSERT(2, odim0 > 0);
DIM_ASSERT(3, odim1 > 0);
af_array output;
switch(type) {
case f32: output = resize<float >(in, odim0, odim1, method); break;
case f64: output = resize<double >(in, odim0, odim1, method); break;
case c32: output = resize<cfloat >(in, odim0, odim1, method); break;
case c64: output = resize<cdouble>(in, odim0, odim1, method); break;
case s32: output = resize<int >(in, odim0, odim1, method); break;
case u32: output = resize<uint >(in, odim0, odim1, method); break;
case s64: output = resize<intl >(in, odim0, odim1, method); break;
case u64: output = resize<uintl >(in, odim0, odim1, method); break;
case s16: output = resize<short >(in, odim0, odim1, method); break;
case u16: output = resize<ushort >(in, odim0, odim1, method); break;
case u8: output = resize<uchar >(in, odim0, odim1, method); break;
case b8: output = resize<char >(in, odim0, odim1, method); break;
default: TYPE_ERROR(1, type);
}
std::swap(*out,output);
}
CATCHALL;
return AF_SUCCESS;
}