NumCpp  2.3.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
clip.hpp
Go to the documentation of this file.
1 #pragma once
29 
31 #include "NumCpp/NdArray.hpp"
32 
33 #include "boost/algorithm/clamp.hpp"
34 
35 namespace nc
36 {
37  //============================================================================
38  // Method Description:
49  template<typename dtype>
50  dtype clip(dtype inValue, dtype inMinValue, dtype inMaxValue)
51  {
53 
54  return boost::algorithm::clamp(inValue, inMinValue, inMaxValue,
55  [](dtype lhs, dtype rhs) noexcept -> bool
56  {
57  return lhs < rhs;
58  });
59  }
60 
61  //============================================================================
62  // Method Description:
73  template<typename dtype>
74  NdArray<dtype> clip(const NdArray<dtype>& inArray, dtype inMinValue, dtype inMaxValue)
75  {
76  return inArray.clip(inMinValue, inMaxValue);
77  }
78 } // namespace nc
StaticAsserts.hpp
nc::clip
dtype clip(dtype inValue, dtype inMinValue, dtype inMaxValue)
Definition: clip.hpp:50
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:50
nc::NdArray< dtype >
nc::NdArray::clip
NdArray< dtype > clip(value_type inMin, value_type inMax) const
Definition: NdArrayCore.hpp:2311
NdArray.hpp
nc
Definition: Coordinate.hpp:44