Blaze  3.6
Clamp.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_FUNCTORS_CLAMP_H_
36 #define _BLAZE_MATH_FUNCTORS_CLAMP_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/shims/Clamp.h>
45 #include <blaze/system/Inline.h>
46 
47 
48 namespace blaze {
49 
50 //=================================================================================================
51 //
52 // CLASS DEFINITION
53 //
54 //=================================================================================================
55 
56 //*************************************************************************************************
60 template< typename DT > // Type of the delimiters
61 struct Clamp
62 {
63  public:
64  //**********************************************************************************************
70  explicit inline Clamp( const DT& min, const DT& max )
71  : min_( min ) // The lower delimiter
72  , max_( max ) // The upper delimiter
73  {}
74  //**********************************************************************************************
75 
76  //**********************************************************************************************
82  template< typename T >
83  BLAZE_ALWAYS_INLINE BLAZE_DEVICE_CALLABLE decltype(auto) operator()( const T& a ) const
84  {
85  return clamp( a, min_, max_ );
86  }
87  //**********************************************************************************************
88 
89  private:
90  //**Member variables****************************************************************************
91  DT min_;
92  DT max_;
93  //**********************************************************************************************
94 };
95 //*************************************************************************************************
96 
97 } // namespace blaze
98 
99 #endif
Generic wrapper for the clamp() function.
Definition: Clamp.h:61
decltype(auto) clamp(const DenseMatrix< MT, SO > &dm, const DT &min, const DT &max)
Restricts each single element of the dense matrix dm to the range .
Definition: DMatMapExpr.h:1572
Header file for the clamp shim.
DT min_
The lower delimiter.
Definition: Clamp.h:91
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1162
Clamp(const DT &min, const DT &max)
Constructor of the Clamp functor.
Definition: Clamp.h:70
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1198
DT max_
The upper delimiter.
Definition: Clamp.h:92
Macro for CUDA compatibility.
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
System settings for the inline keywords.