1 //=================================================================================================
2 /*!
3 //  \file blaze/math/functors/MakePair.h
4 //  \brief Header file for the MakePair functor
5 //
6 //  Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved
7 //
8 //  This file is part of the Blaze library. You can redistribute it and/or modify it under
9 //  the terms of the New (Revised) BSD License. Redistribution and use in source and binary
10 //  forms, with or without modification, are permitted provided that the following conditions
11 //  are met:
12 //
13 //  1. Redistributions of source code must retain the above copyright notice, this list of
14 //     conditions and the following disclaimer.
15 //  2. Redistributions in binary form must reproduce the above copyright notice, this list
16 //     of conditions and the following disclaimer in the documentation and/or other materials
17 //     provided with the distribution.
18 //  3. Neither the names of the Blaze development group nor the names of its contributors
19 //     may be used to endorse or promote products derived from this software without specific
20 //     prior written permission.
21 //
22 //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
23 //  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 //  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 //  SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 //  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 //  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 //  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 //  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 //  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 //  DAMAGE.
32 */
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_FUNCTORS_MAKEPAIR_H_
36 #define _BLAZE_MATH_FUNCTORS_MAKEPAIR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <blaze/math/typetraits/IsHermitian.h>
45 #include <blaze/math/typetraits/IsLower.h>
46 #include <blaze/math/typetraits/IsStrictlyLower.h>
47 #include <blaze/math/typetraits/IsStrictlyUpper.h>
48 #include <blaze/math/typetraits/IsSymmetric.h>
49 #include <blaze/math/typetraits/IsUniform.h>
50 #include <blaze/math/typetraits/IsUniLower.h>
51 #include <blaze/math/typetraits/IsUniUpper.h>
52 #include <blaze/math/typetraits/IsUpper.h>
53 #include <blaze/math/typetraits/IsZero.h>
54 #include <blaze/math/typetraits/YieldsHermitian.h>
55 #include <blaze/math/typetraits/YieldsLower.h>
56 #include <blaze/math/typetraits/YieldsStrictlyLower.h>
57 #include <blaze/math/typetraits/YieldsStrictlyUpper.h>
58 #include <blaze/math/typetraits/YieldsSymmetric.h>
59 #include <blaze/math/typetraits/YieldsUniform.h>
60 #include <blaze/math/typetraits/YieldsUniLower.h>
61 #include <blaze/math/typetraits/YieldsUniUpper.h>
62 #include <blaze/math/typetraits/YieldsUpper.h>
63 #include <blaze/math/typetraits/YieldsZero.h>
64 #include <blaze/system/HostDevice.h>
65 #include <blaze/system/Inline.h>
66 #include <blaze/util/IntegralConstant.h>
67 
68 
69 namespace blaze {
70 
71 //=================================================================================================
72 //
73 //  CLASS DEFINITION
74 //
75 //=================================================================================================
76 
77 //*************************************************************************************************
78 /*!\brief Generic wrapper for the make_pair() function.
79 // \ingroup functors
80 */
81 struct MakePair
82 {
83    //**********************************************************************************************
84    /*!\brief Returns the result of the make_pair() function for the given objects/values.
85    //
86    // \param a The left-hand side object/value.
87    // \param b The right-hand side object/value.
88    // \return The result of the make_pair() function for the given objects/values.
89    */
90    template< typename T1, typename T2 >
decltypeMakePair91    BLAZE_ALWAYS_INLINE BLAZE_DEVICE_CALLABLE decltype(auto) operator()( T1&& a, T2&& b ) const
92    {
93       using std::make_pair;
94       return make_pair( std::forward<T1>( a ), std::forward<T2>( b ) );
95    }
96    //**********************************************************************************************
97 
98    //**********************************************************************************************
99    /*!\brief Returns whether SIMD is enabled for the specified data types \a T1 and \a T2.
100    //
101    // \return \a true in case SIMD is enabled for the data types \a T1 and \a T2, \a false if not.
102    */
103    template< typename T1, typename T2 >
simdEnabledMakePair104    static constexpr bool simdEnabled() { return true; }
105    //**********************************************************************************************
106 
107    //**********************************************************************************************
108    /*!\brief Returns whether the operation supports padding, i.e. whether it can deal with zeros.
109    //
110    // \return \a true in case padding is supported, \a false if not.
111    */
paddingEnabledMakePair112    static constexpr bool paddingEnabled() { return true; }
113    //**********************************************************************************************
114 
115    //**********************************************************************************************
116    /*!\brief Returns the result of the make_pair() function for the given SIMD vectors.
117    //
118    // \param a The left-hand side SIMD vector.
119    // \param b The right-hand side SIMD vector.
120    // \return The result of the make_pair() function for the given SIMD vectors.
121    */
122    template< typename T1, typename T2 >
decltypeMakePair123    BLAZE_ALWAYS_INLINE decltype(auto) load( T1&& a, T2&& b ) const
124    {
125       using std::make_pair;
126       return make_pair( std::forward<T1>( a ), std::forward<T2>( b ) );
127    }
128    //**********************************************************************************************
129 };
130 //*************************************************************************************************
131 
132 
133 
134 
135 //=================================================================================================
136 //
137 //  YIELDSUNIFORM SPECIALIZATIONS
138 //
139 //=================================================================================================
140 
141 //*************************************************************************************************
142 /*! \cond BLAZE_INTERNAL */
143 template< typename T1, typename T2 >
144 struct YieldsUniform<MakePair,T1,T2>
145    : public BoolConstant< IsUniform_v<T1> && IsUniform_v<T2> >
146 {};
147 /*! \endcond */
148 //*************************************************************************************************
149 
150 
151 
152 
153 //=================================================================================================
154 //
155 //  YIELDSSYMMETRIC SPECIALIZATIONS
156 //
157 //=================================================================================================
158 
159 //*************************************************************************************************
160 /*! \cond BLAZE_INTERNAL */
161 template< typename MT1, typename MT2 >
162 struct YieldsSymmetric<MakePair,MT1,MT2>
163    : public BoolConstant< IsSymmetric_v<MT1> && IsSymmetric_v<MT2> >
164 {};
165 /*! \endcond */
166 //*************************************************************************************************
167 
168 
169 
170 
171 //=================================================================================================
172 //
173 //  YIELDSHERMITIAN SPECIALIZATIONS
174 //
175 //=================================================================================================
176 
177 //*************************************************************************************************
178 /*! \cond BLAZE_INTERNAL */
179 template< typename MT1, typename MT2 >
180 struct YieldsHermitian<MakePair,MT1,MT2>
181    : public BoolConstant< IsHermitian_v<MT1> && IsHermitian_v<MT2> >
182 {};
183 /*! \endcond */
184 //*************************************************************************************************
185 
186 
187 
188 
189 //=================================================================================================
190 //
191 //  YIELDSLOWER SPECIALIZATIONS
192 //
193 //=================================================================================================
194 
195 //*************************************************************************************************
196 /*! \cond BLAZE_INTERNAL */
197 template< typename MT1, typename MT2 >
198 struct YieldsLower<MakePair,MT1,MT2>
199    : public BoolConstant< IsLower_v<MT1> && IsLower_v<MT2> >
200 {};
201 /*! \endcond */
202 //*************************************************************************************************
203 
204 
205 
206 
207 //=================================================================================================
208 //
209 //  YIELDSUNILOWER SPECIALIZATIONS
210 //
211 //=================================================================================================
212 
213 //*************************************************************************************************
214 /*! \cond BLAZE_INTERNAL */
215 template< typename MT1, typename MT2 >
216 struct YieldsUniLower<MakePair,MT1,MT2>
217    : public BoolConstant< IsUniLower_v<MT1> && IsUniLower_v<MT2> >
218 {};
219 /*! \endcond */
220 //*************************************************************************************************
221 
222 
223 
224 
225 //=================================================================================================
226 //
227 //  YIELDSSTRICTLYLOWER SPECIALIZATIONS
228 //
229 //=================================================================================================
230 
231 //*************************************************************************************************
232 /*! \cond BLAZE_INTERNAL */
233 template< typename MT1, typename MT2 >
234 struct YieldsStrictlyLower<MakePair,MT1,MT2>
235    : public BoolConstant< IsStrictlyLower_v<MT1> && IsStrictlyLower_v<MT2> >
236 {};
237 /*! \endcond */
238 //*************************************************************************************************
239 
240 
241 
242 
243 //=================================================================================================
244 //
245 //  YIELDSUPPER SPECIALIZATIONS
246 //
247 //=================================================================================================
248 
249 //*************************************************************************************************
250 /*! \cond BLAZE_INTERNAL */
251 template< typename MT1, typename MT2 >
252 struct YieldsUpper<MakePair,MT1,MT2>
253    : public BoolConstant< IsUpper_v<MT1> && IsUpper_v<MT2> >
254 {};
255 /*! \endcond */
256 //*************************************************************************************************
257 
258 
259 
260 
261 //=================================================================================================
262 //
263 //  YIELDSUNIUPPER SPECIALIZATIONS
264 //
265 //=================================================================================================
266 
267 //*************************************************************************************************
268 /*! \cond BLAZE_INTERNAL */
269 template< typename MT1, typename MT2 >
270 struct YieldsUniUpper<MakePair,MT1,MT2>
271    : public BoolConstant< IsUniUpper_v<MT1> && IsUniUpper_v<MT2> >
272 {};
273 /*! \endcond */
274 //*************************************************************************************************
275 
276 
277 
278 
279 //=================================================================================================
280 //
281 //  YIELDSSTRICTLYUPPER SPECIALIZATIONS
282 //
283 //=================================================================================================
284 
285 //*************************************************************************************************
286 /*! \cond BLAZE_INTERNAL */
287 template< typename MT1, typename MT2 >
288 struct YieldsStrictlyUpper<MakePair,MT1,MT2>
289    : public BoolConstant< IsStrictlyUpper_v<MT1> && IsStrictlyUpper_v<MT2> >
290 {};
291 /*! \endcond */
292 //*************************************************************************************************
293 
294 
295 
296 
297 //=================================================================================================
298 //
299 //  YIELDSZERO SPECIALIZATIONS
300 //
301 //=================================================================================================
302 
303 //*************************************************************************************************
304 /*! \cond BLAZE_INTERNAL */
305 template< typename T1, typename T2 >
306 struct YieldsZero<MakePair,T1,T2>
307    : public BoolConstant< IsZero_v<T1> && IsZero_v<T2> >
308 {};
309 /*! \endcond */
310 //*************************************************************************************************
311 
312 } // namespace blaze
313 
314 #endif
315