Blaze  3.6
Bind2nd.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_FUNCTORS_BIND2ND_H_
36 #define _BLAZE_MATH_FUNCTORS_BIND2ND_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/math/simd/Set.h>
48 #include <blaze/system/Inline.h>
49 
50 
51 namespace blaze {
52 
53 //=================================================================================================
54 //
55 // CLASS DEFINITION
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
63 template< typename OP // Type of the binary operation
64  , typename A2 > // Type of the bound argument
65 struct Bind2nd
66 {
67  public:
68  //**********************************************************************************************
74  explicit inline constexpr Bind2nd( const OP& op, const A2& a2 )
75  : op_( op ) // The wrapped operation.
76  , a2_( a2 ) // The 2nd argument
77  {}
78  //**********************************************************************************************
79 
80  //**********************************************************************************************
86  template< typename T >
87  BLAZE_ALWAYS_INLINE constexpr decltype(auto) operator()( const T& a ) const
88  {
89  return op_( a, a2_ );
90  }
91  //**********************************************************************************************
92 
93  //**********************************************************************************************
98  template< typename T >
99  static constexpr bool simdEnabled() { return IsSIMDEnabled_v<OP,T,A2>; }
100  //**********************************************************************************************
101 
102  //**********************************************************************************************
107  static constexpr bool paddingEnabled() { return false; }
108  //**********************************************************************************************
109 
110  //**********************************************************************************************
116  template< typename T >
117  BLAZE_ALWAYS_INLINE decltype(auto) load( const T& a ) const
118  {
120  return op_.load( a, set( a2_ ) );
121  }
122  //**********************************************************************************************
123 
124  private:
125  //**Member variables****************************************************************************
126  OP op_;
127  A2 a2_;
128  //**********************************************************************************************
129 };
130 //*************************************************************************************************
131 
132 
133 
134 
135 //=================================================================================================
136 //
137 // GLOBAL FUNCTIONS
138 //
139 //=================================================================================================
140 
141 //*************************************************************************************************
152 template< typename OP // Type of the binary operation
153  , typename A2 > // Type of the bound argument
154 inline constexpr Bind2nd<OP,A2> bind2nd( const OP& op, const A2& a2 )
155 {
156  return Bind2nd<OP,A2>( op, a2 );
157 }
158 //*************************************************************************************************
159 
160 
161 
162 
163 //=================================================================================================
164 //
165 // YIELDSUNIFORM SPECIALIZATIONS
166 //
167 //=================================================================================================
168 
169 //*************************************************************************************************
171 template< typename OP, typename A2, typename T >
172 struct YieldsUniform<Bind2nd<OP,A2>,T>
173  : public YieldsUniform<OP,T>
174 {};
176 //*************************************************************************************************
177 
178 
179 
180 
181 //=================================================================================================
182 //
183 // YIELDSSYMMETRIC SPECIALIZATIONS
184 //
185 //=================================================================================================
186 
187 //*************************************************************************************************
189 template< typename OP, typename A2, typename MT >
190 struct YieldsSymmetric<Bind2nd<OP,A2>,MT>
191  : public YieldsSymmetric<OP,MT>
192 {};
194 //*************************************************************************************************
195 
196 } // namespace blaze
197 
198 #endif
#define BLAZE_CONSTRAINT_MUST_BE_SIMD_PACK(T)
Constraint on the data type.In case the given data type T is not a SIMD pack, a compilation error is ...
Definition: SIMDPack.h:60
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
OP op_
The binary operation.
Definition: Bind2nd.h:126
A2 a2_
The 2nd argument.
Definition: Bind2nd.h:127
decltype(auto) BLAZE_ALWAYS_INLINE load(const T &a) const
Returns the result of the wrapped operation for the given SIMD vector.
Definition: Bind2nd.h:117
constexpr Bind2nd< OP, A2 > bind2nd(const OP &op, const A2 &a2)
Binds the given object/value to the 2nd parameter of the given binary operation.
Definition: Bind2nd.h:154
Constraint on the data type.
Header file for the SIMD set functionality.
Header file for the IsSIMDEnabled type trait.
Header file for the YieldsUniform type trait.
static constexpr bool simdEnabled()
Returns whether SIMD is enabled for the specified data type T.
Definition: Bind2nd.h:99
Header file for the YieldsSymmetric type trait.
Generic wrapper for a binary operation with fixed 2nd argument.
Definition: Bind2nd.h:65
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
constexpr Bind2nd(const OP &op, const A2 &a2)
Constructor of the Bind2nd functor.
Definition: Bind2nd.h:74
static constexpr bool paddingEnabled()
Returns whether the operation supports padding, i.e. whether it can deal with zeros.
Definition: Bind2nd.h:107
System settings for the inline keywords.