-
Notifications
You must be signed in to change notification settings - Fork 549
Expand file tree
/
Copy pathclamp.cpp
More file actions
35 lines (30 loc) · 1.07 KB
/
clamp.cpp
File metadata and controls
35 lines (30 loc) · 1.07 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
/*******************************************************
* 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/arith.h>
#include <af/array.h>
#include <af/data.h>
#include <af/gfor.h>
#include "error.hpp"
namespace af {
array clamp(const array &in, const array &lo, const array &hi) {
af_array out;
AF_THROW(af_clamp(&out, in.get(), lo.get(), hi.get(), gforGet()));
return array(out);
}
array clamp(const array &in, const array &lo, const double hi) {
return clamp(in, lo, constant(hi, lo.dims(), lo.type()));
}
array clamp(const array &in, const double lo, const array &hi) {
return clamp(in, constant(lo, hi.dims(), hi.type()), hi);
}
array clamp(const array &in, const double lo, const double hi) {
return clamp(in, constant(lo, in.dims(), in.type()),
constant(hi, in.dims(), in.type()));
}
} // namespace af