Clip.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SHIMS_CLIP_H_
36 #define _BLAZE_MATH_SHIMS_CLIP_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/system/Inline.h>
44 #include <blaze/util/EnableIf.h>
46 
47 
48 namespace blaze {
49 
50 //=================================================================================================
51 //
52 // CLIP SHIM
53 //
54 //=================================================================================================
55 
56 //*************************************************************************************************
79 template< typename T >
80 const T clip( const T& a, const T& min, const T& max ) noexcept
81 {
82  if( a < min )
83  return min;
84  else if( max < a )
85  return max;
86  else return a;
87 }
89 //*************************************************************************************************
90 
91 } // namespace blaze
92 
93 #endif
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the EnableIf class template.
const DMatForEachExpr< MT, Clip< DT >, SO > clip(const DenseMatrix< MT, SO > &dm, const DT &min, const DT &max)
Restricts each single element of the dense matrix dm to the range .
Definition: DMatForEachExpr.h:1407
Header file for the IsBuiltin type trait.
System settings for the inline keywords.