forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunary.cpp
More file actions
94 lines (76 loc) · 2.19 KB
/
unary.cpp
File metadata and controls
94 lines (76 loc) · 2.19 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*******************************************************
* 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 "error.hpp"
namespace af
{
#define af_complex(...) af_cplx(__VA_ARGS__)
#define INSTANTIATE(func) \
array func(const array &in) \
{ \
af_array out = 0; \
AF_THROW(af_##func(&out, in.get())); \
return array(out); \
}
INSTANTIATE(complex)
INSTANTIATE(real )
INSTANTIATE(imag )
INSTANTIATE(arg )
INSTANTIATE(abs )
INSTANTIATE(conjg )
INSTANTIATE(sign )
INSTANTIATE(round )
INSTANTIATE(trunc )
INSTANTIATE(floor )
INSTANTIATE(ceil )
INSTANTIATE(sin )
INSTANTIATE(cos )
INSTANTIATE(tan )
INSTANTIATE(asin )
INSTANTIATE(acos )
INSTANTIATE(atan )
INSTANTIATE(sinh )
INSTANTIATE(cosh )
INSTANTIATE(tanh )
INSTANTIATE(asinh )
INSTANTIATE(acosh )
INSTANTIATE(atanh )
INSTANTIATE(pow2 )
INSTANTIATE(exp )
INSTANTIATE(expm1 )
INSTANTIATE(erf )
INSTANTIATE(erfc )
INSTANTIATE(sigmoid)
INSTANTIATE(log )
INSTANTIATE(log1p )
INSTANTIATE(log10 )
INSTANTIATE(log2 )
INSTANTIATE(sqrt )
INSTANTIATE(cbrt )
INSTANTIATE(iszero)
INSTANTIATE(factorial)
INSTANTIATE(tgamma)
INSTANTIATE(lgamma)
// isinf and isnan are defined by C++.
// Thus we need a difference nomenclature.
array isInf(const array &in)
{
af_array out = 0;
AF_THROW(af_isinf(&out, in.get()));
return array(out);
}
array isNaN(const array &in)
{
af_array out = 0;
AF_THROW(af_isnan(&out, in.get()));
return array(out);
}
}