NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
clip.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <algorithm>
31
34#include "NumCpp/NdArray.hpp"
35
36namespace nc
37{
38 //============================================================================
39 // Method Description:
49 template<typename dtype>
51 {
53
54#ifdef __cpp_lib_clamp
55 const auto comparitor = [](dtype lhs, dtype rhs) noexcept -> bool { return lhs < rhs; };
56
57 return std::clamp(inValue, inMinValue, inMaxValue, comparitor);
58#else
59 if (inValue < inMinValue)
60 {
61 return inMinValue;
62 }
63 else if (inValue > inMaxValue)
64 {
65 return inMaxValue;
66 }
67
68 return inValue;
69#endif
70 }
71
72 //============================================================================
73 // Method Description:
83 template<typename dtype>
88} // namespace nc
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition StaticAsserts.hpp:56
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
self_type clip(value_type inMin, value_type inMax) const
Definition NdArrayCore.hpp:2449
Definition Cartesian.hpp:40
dtype clip(dtype inValue, dtype inMinValue, dtype inMaxValue)
Definition clip.hpp:50
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59