Blaze  3.6
Bind1st.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_FUNCTORS_BIND1ST_H_
36 #define _BLAZE_MATH_FUNCTORS_BIND1ST_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 A1 > // Type of the bound argument
65 struct Bind1st
66 {
67  public:
68  //**********************************************************************************************
74  explicit inline constexpr Bind1st( const OP& op, const A1& a1 )
75  : op_( op ) // The wrapped operation.
76  , a1_( a1 ) // The 1st 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_( a1_, a );
90  }
91  //**********************************************************************************************
92 
93  //**********************************************************************************************
98  template< typename T >
99  static constexpr bool simdEnabled() { return IsSIMDEnabled_v<OP,A1,T>; }
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( set( a1_ ), a );
121  }
122  //**********************************************************************************************
123 
124  private:
125  //**Member variables****************************************************************************
126  OP op_;
127  A1 a1_;
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 A1 > // Type of the bound argument
154 inline constexpr Bind1st<OP,A1> bind1st( const OP& op, const A1& a1 )
155 {
156  return Bind1st<OP,A1>( op, a1 );
157 }
158 //*************************************************************************************************
159 
160 
161 
162 
163 //=================================================================================================
164 //
165 // YIELDSUNIFORM SPECIALIZATIONS
166 //
167 //=================================================================================================
168 
169 //*************************************************************************************************
171 template< typename OP, typename A1, typename T >
172 struct YieldsUniform<Bind1st<OP,A1>,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 A1, typename MT >
190 struct YieldsSymmetric<Bind1st<OP,A1>,MT>
191  : public YieldsSymmetric<OP,MT>
192 {};
194 //*************************************************************************************************
195 
196 } // namespace blaze
197 
198 #endif
Generic wrapper for a binary operation with fixed 1st argument.
Definition: Bind1st.h:65
#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
OP op_
The binary operation.
Definition: Bind1st.h:126
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
static constexpr bool paddingEnabled()
Returns whether the operation supports padding, i.e. whether it can deal with zeros.
Definition: Bind1st.h:107
Constraint on the data type.
decltype(auto) BLAZE_ALWAYS_INLINE load(const T &a) const
Returns the result of the wrapped operation for the given SIMD vector.
Definition: Bind1st.h:117
Header file for the SIMD set functionality.
Header file for the IsSIMDEnabled type trait.
Header file for the YieldsUniform type trait.
Header file for the YieldsSymmetric type trait.
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
A1 a1_
The 1st argument.
Definition: Bind1st.h:127
static constexpr bool simdEnabled()
Returns whether SIMD is enabled for the specified data type T.
Definition: Bind1st.h:99
System settings for the inline keywords.
constexpr Bind1st< OP, A1 > bind1st(const OP &op, const A1 &a1)
Binds the given object/value to the 1st parameter of the given binary operation.
Definition: Bind1st.h:154
constexpr Bind1st(const OP &op, const A1 &a1)
Constructor of the Bind1st functor.
Definition: Bind1st.h:74