NumCpp  2.1.0
A C++ implementation of the Python Numpy library
clip.hpp
Go to the documentation of this file.
1 #pragma once
30 
32 #include "NumCpp/NdArray.hpp"
33 
34 #include "boost/algorithm/clamp.hpp"
35 
36 namespace nc
37 {
38  //============================================================================
39  // Method Description:
50  template<typename dtype>
51  dtype clip(dtype inValue, dtype inMinValue, dtype inMaxValue)
52  {
54 
55  return boost::algorithm::clamp(inValue, inMinValue, inMaxValue,
56  [](dtype lhs, dtype rhs) noexcept -> bool
57  {
58  return lhs < rhs;
59  });
60  }
61 
62  //============================================================================
63  // Method Description:
74  template<typename dtype>
75  NdArray<dtype> clip(const NdArray<dtype>& inArray, dtype inMinValue, dtype inMaxValue)
76  {
77  return inArray.clip(inMinValue, inMaxValue);
78  }
79 } // namespace nc
StaticAsserts.hpp
nc::clip
dtype clip(dtype inValue, dtype inMinValue, dtype inMaxValue)
Definition: clip.hpp:51
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:51
nc::NdArray< dtype >
nc::NdArray::clip
NdArray< dtype > clip(value_type inMin, value_type inMax) const
Definition: NdArrayCore.hpp:2312
NdArray.hpp
nc
Definition: Coordinate.hpp:45