forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinary.cpp
More file actions
65 lines (58 loc) · 2.26 KB
/
Copy pathbinary.cpp
File metadata and controls
65 lines (58 loc) · 2.26 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
65
/*******************************************************
* 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/arith.h>
#include <af/data.h>
#include <af/gfor.h>
#include "error.hpp"
namespace af
{
#define INSTANTIATE(cppfunc, cfunc) \
array cppfunc(const array &lhs, const array &rhs) \
{ \
af_array out = 0; \
AF_THROW(cfunc(&out, lhs.get(), rhs.get(), gforGet())); \
return array(out); \
}
INSTANTIATE(min , af_minof)
INSTANTIATE(max , af_maxof)
INSTANTIATE(pow , af_pow )
INSTANTIATE(root, af_root )
INSTANTIATE(rem , af_rem )
INSTANTIATE(mod , af_mod )
INSTANTIATE(complex, af_cplx2)
INSTANTIATE(atan2, af_atan2)
INSTANTIATE(hypot, af_hypot)
#define WRAPPER(func) \
array func(const array &lhs, const double rhs) \
{ \
af::dtype ty = lhs.type(); \
if (lhs.iscomplex()) { \
ty = lhs.issingle() ? f32 : f64; \
} \
return func(lhs, constant(rhs, lhs.dims(), ty)); \
} \
array func(const double lhs, const array &rhs) \
{ \
af::dtype ty = rhs.type(); \
if (rhs.iscomplex()) { \
ty = rhs.issingle() ? f32 : f64; \
} \
return func(constant(lhs, rhs.dims(), ty), rhs); \
}
WRAPPER(min)
WRAPPER(max)
WRAPPER(pow)
WRAPPER(root)
WRAPPER(rem)
WRAPPER(mod)
WRAPPER(complex)
WRAPPER(atan2)
WRAPPER(hypot)
}