forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.cpp
More file actions
41 lines (32 loc) · 1.01 KB
/
math.cpp
File metadata and controls
41 lines (32 loc) · 1.01 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
/*******************************************************
* 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 <common/defines.hpp>
#include <math.hpp>
#include <complex>
namespace cpu {
uint abs(uint val) { return val; }
uchar abs(uchar val) { return val; }
uintl abs(uintl val) { return val; }
cfloat scalar(float val) {
cfloat cval = {val, 0};
return cval;
}
cdouble scalar(double val) {
cdouble cval = {val, 0};
return cval;
}
cfloat min(cfloat lhs, cfloat rhs) { return abs(lhs) < abs(rhs) ? lhs : rhs; }
cdouble min(cdouble lhs, cdouble rhs) {
return abs(lhs) < abs(rhs) ? lhs : rhs;
}
cfloat max(cfloat lhs, cfloat rhs) { return abs(lhs) > abs(rhs) ? lhs : rhs; }
cdouble max(cdouble lhs, cdouble rhs) {
return abs(lhs) > abs(rhs) ? lhs : rhs;
}
} // namespace cpu