1 //=================================================================================================
2 /*!
3 //  \file blaze/math/functors/Cbrt.h
4 //  \brief Header file for the Cbrt 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_CBRT_H_
36 #define _BLAZE_MATH_FUNCTORS_CBRT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <blaze/math/constraints/SIMDPack.h>
45 #include <blaze/math/shims/Cbrt.h>
46 #include <blaze/math/simd/Cbrt.h>
47 #include <blaze/math/typetraits/HasSIMDCbrt.h>
48 #include <blaze/math/typetraits/IsLower.h>
49 #include <blaze/math/typetraits/IsStrictlyLower.h>
50 #include <blaze/math/typetraits/IsStrictlyUpper.h>
51 #include <blaze/math/typetraits/IsSymmetric.h>
52 #include <blaze/math/typetraits/IsUniform.h>
53 #include <blaze/math/typetraits/IsUniLower.h>
54 #include <blaze/math/typetraits/IsUniUpper.h>
55 #include <blaze/math/typetraits/IsUpper.h>
56 #include <blaze/math/typetraits/IsZero.h>
57 #include <blaze/math/typetraits/YieldsLower.h>
58 #include <blaze/math/typetraits/YieldsStrictlyLower.h>
59 #include <blaze/math/typetraits/YieldsStrictlyUpper.h>
60 #include <blaze/math/typetraits/YieldsSymmetric.h>
61 #include <blaze/math/typetraits/YieldsUniform.h>
62 #include <blaze/math/typetraits/YieldsUniLower.h>
63 #include <blaze/math/typetraits/YieldsUniUpper.h>
64 #include <blaze/math/typetraits/YieldsUpper.h>
65 #include <blaze/math/typetraits/YieldsZero.h>
66 #include <blaze/system/HostDevice.h>
67 #include <blaze/system/Inline.h>
68 
69 
70 namespace blaze {
71 
72 //=================================================================================================
73 //
74 //  CLASS DEFINITION
75 //
76 //=================================================================================================
77 
78 //*************************************************************************************************
79 /*!\brief Generic wrapper for the cbrt() function.
80 // \ingroup functors
81 */
82 struct Cbrt
83 {
84    //**********************************************************************************************
85    /*!\brief Returns the result of the cbrt() function for the given object/value.
86    //
87    // \param a The given object/value.
88    // \return The result of the cbrt() function for the given object/value.
89    */
90    template< typename T >
decltypeCbrt91    BLAZE_ALWAYS_INLINE BLAZE_DEVICE_CALLABLE decltype(auto) operator()( T&& a ) const
92    {
93       return cbrt( std::forward<T>( a ) );
94    }
95    //**********************************************************************************************
96 
97    //**********************************************************************************************
98    /*!\brief Returns whether SIMD is enabled for the specified data type \a T.
99    //
100    // \return \a true in case SIMD is enabled for the data type \a T, \a false if not.
101    */
102    template< typename T >
simdEnabledCbrt103    static constexpr bool simdEnabled() { return HasSIMDCbrt_v<T>; }
104    //**********************************************************************************************
105 
106    //**********************************************************************************************
107    /*!\brief Returns whether the operation supports padding, i.e. whether it can deal with zeros.
108    //
109    // \return \a true in case padding is supported, \a false if not.
110    */
paddingEnabledCbrt111    static constexpr bool paddingEnabled() { return true; }
112    //**********************************************************************************************
113 
114    //**********************************************************************************************
115    /*!\brief Returns the result of the cbrt() function for the given SIMD vector.
116    //
117    // \param a The given SIMD vector.
118    // \return The result of the cbrt() function for the given SIMD vector.
119    */
120    template< typename T >
decltypeCbrt121    BLAZE_ALWAYS_INLINE decltype(auto) load( const T& a ) const
122    {
123       BLAZE_CONSTRAINT_MUST_BE_SIMD_PACK( T );
124       return cbrt( a );
125    }
126    //**********************************************************************************************
127 };
128 //*************************************************************************************************
129 
130 
131 
132 
133 //=================================================================================================
134 //
135 //  YIELDSUNIFORM SPECIALIZATIONS
136 //
137 //=================================================================================================
138 
139 //*************************************************************************************************
140 /*! \cond BLAZE_INTERNAL */
141 template< typename T >
142 struct YieldsUniform<Cbrt,T>
143    : public IsUniform<T>
144 {};
145 /*! \endcond */
146 //*************************************************************************************************
147 
148 
149 
150 
151 //=================================================================================================
152 //
153 //  YIELDSSYMMETRIC SPECIALIZATIONS
154 //
155 //=================================================================================================
156 
157 //*************************************************************************************************
158 /*! \cond BLAZE_INTERNAL */
159 template< typename MT >
160 struct YieldsSymmetric<Cbrt,MT>
161    : public IsSymmetric<MT>
162 {};
163 /*! \endcond */
164 //*************************************************************************************************
165 
166 
167 
168 
169 //=================================================================================================
170 //
171 //  YIELDSLOWER SPECIALIZATIONS
172 //
173 //=================================================================================================
174 
175 //*************************************************************************************************
176 /*! \cond BLAZE_INTERNAL */
177 template< typename MT >
178 struct YieldsLower<Cbrt,MT>
179    : public IsLower<MT>
180 {};
181 /*! \endcond */
182 //*************************************************************************************************
183 
184 
185 
186 
187 //=================================================================================================
188 //
189 //  YIELDSUNILOWER SPECIALIZATIONS
190 //
191 //=================================================================================================
192 
193 //*************************************************************************************************
194 /*! \cond BLAZE_INTERNAL */
195 template< typename MT >
196 struct YieldsUniLower<Cbrt,MT>
197    : public IsUniLower<MT>
198 {};
199 /*! \endcond */
200 //*************************************************************************************************
201 
202 
203 
204 
205 //=================================================================================================
206 //
207 //  YIELDSSTRICTLYLOWER SPECIALIZATIONS
208 //
209 //=================================================================================================
210 
211 //*************************************************************************************************
212 /*! \cond BLAZE_INTERNAL */
213 template< typename MT >
214 struct YieldsStrictlyLower<Cbrt,MT>
215    : public IsStrictlyLower<MT>
216 {};
217 /*! \endcond */
218 //*************************************************************************************************
219 
220 
221 
222 
223 //=================================================================================================
224 //
225 //  YIELDSUPPER SPECIALIZATIONS
226 //
227 //=================================================================================================
228 
229 //*************************************************************************************************
230 /*! \cond BLAZE_INTERNAL */
231 template< typename MT >
232 struct YieldsUpper<Cbrt,MT>
233    : public IsUpper<MT>
234 {};
235 /*! \endcond */
236 //*************************************************************************************************
237 
238 
239 
240 
241 //=================================================================================================
242 //
243 //  YIELDSUNIUPPER SPECIALIZATIONS
244 //
245 //=================================================================================================
246 
247 //*************************************************************************************************
248 /*! \cond BLAZE_INTERNAL */
249 template< typename MT >
250 struct YieldsUniUpper<Cbrt,MT>
251    : public IsUniUpper<MT>
252 {};
253 /*! \endcond */
254 //*************************************************************************************************
255 
256 
257 
258 
259 //=================================================================================================
260 //
261 //  YIELDSSTRICTLYUPPER SPECIALIZATIONS
262 //
263 //=================================================================================================
264 
265 //*************************************************************************************************
266 /*! \cond BLAZE_INTERNAL */
267 template< typename MT >
268 struct YieldsStrictlyUpper<Cbrt,MT>
269    : public IsStrictlyUpper<MT>
270 {};
271 /*! \endcond */
272 //*************************************************************************************************
273 
274 
275 
276 
277 //=================================================================================================
278 //
279 //  YIELDSZERO SPECIALIZATIONS
280 //
281 //=================================================================================================
282 
283 //*************************************************************************************************
284 /*! \cond BLAZE_INTERNAL */
285 template< typename T >
286 struct YieldsZero<Cbrt,T>
287    : public IsZero<T>
288 {};
289 /*! \endcond */
290 //*************************************************************************************************
291 
292 } // namespace blaze
293 
294 #endif
295