1 //=================================================================================================
2 /*!
3 //  \file blaze/math/typetraits/HasSIMDCos.h
4 //  \brief Header file for the HasSIMDCos type trait
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_TYPETRAITS_HASSIMDCOS_H_
36 #define _BLAZE_MATH_TYPETRAITS_HASSIMDCOS_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/system/Vectorization.h>
44 #include <blaze/util/IntegralConstant.h>
45 #include <blaze/util/typetraits/IsDouble.h>
46 #include <blaze/util/typetraits/IsFloat.h>
47 #include <blaze/util/typetraits/RemoveCVRef.h>
48 
49 
50 namespace blaze {
51 
52 //=================================================================================================
53 //
54 //  CLASS DEFINITION
55 //
56 //=================================================================================================
57 
58 //*************************************************************************************************
59 /*! \cond BLAZE_INTERNAL */
60 /*!\brief Auxiliary alias declaration for the HasSIMDCos type trait.
61 // \ingroup math_type_traits
62 */
63 template< typename T >  // Type of the operand
64 using HasSIMDCosHelper =
65    BoolConstant< ( IsFloat_v<T> || IsDouble_v<T> ) &&
66                  ( bool( BLAZE_SVML_MODE    ) ||
67                    bool( BLAZE_SLEEF_MODE ) ) &&
68                  ( bool( BLAZE_SSE_MODE     ) ||
69                    bool( BLAZE_AVX_MODE     ) ||
70                    bool( BLAZE_MIC_MODE     ) ||
71                    bool( BLAZE_AVX512F_MODE ) ) >;
72 /*! \endcond */
73 //*************************************************************************************************
74 
75 
76 //*************************************************************************************************
77 /*!\brief Availability of a SIMD cosine operation for the given data type.
78 // \ingroup math_type_traits
79 //
80 // Depending on the available instruction set (SSE, SSE2, SSE3, SSE4, AVX, AVX2, MIC, ...) and
81 // the used compiler, this type trait provides the information whether a SIMD cosine operation
82 // exists for the given data type \a T (ignoring the cv-qualifiers). In case the SIMD operation
83 // is available, the \a value member constant is set to \a true, the nested type definition
84 // \a Type is \a TrueType, and the class derives from \a TrueType. Otherwise \a value is set
85 // to \a false, \a Type is \a FalseType, and the class derives from \a FalseType. The following
86 // example assumes that the Intel SVML is available:
87 
88    \code
89    blaze::HasSIMDCos< float >::value         // Evaluates to 1
90    blaze::HasSIMDCos< double >::Type         // Results in TrueType
91    blaze::HasSIMDCos< const double >         // Is derived from TrueType
92    blaze::HasSIMDCos< unsigned int >::value  // Evaluates to 0
93    blaze::HasSIMDCos< long double >::Type    // Results in FalseType
94    blaze::HasSIMDCos< complex<double> >      // Is derived from FalseType
95    \endcode
96 */
97 template< typename T >  // Type of the operand
98 struct HasSIMDCos
99    : public BoolConstant< HasSIMDCosHelper< RemoveCVRef_t<T> >::value >
100 {};
101 //*************************************************************************************************
102 
103 
104 //*************************************************************************************************
105 /*!\brief Auxiliary variable template for the HasSIMDCos type trait.
106 // \ingroup math_type_traits
107 //
108 // The HasSIMDCos_v variable template provides a convenient shortcut to access the nested
109 // \a value of the HasSIMDCos class template. For instance, given the type \a T the following
110 // two statements are identical:
111 
112    \code
113    constexpr bool value1 = blaze::HasSIMDCos<T>::value;
114    constexpr bool value2 = blaze::HasSIMDCos_v<T>;
115    \endcode
116 */
117 template< typename T >  // Type of the operand
118 constexpr bool HasSIMDCos_v = HasSIMDCos<T>::value;
119 //*************************************************************************************************
120 
121 } // namespace blaze
122 
123 #endif
124