1 //=================================================================================================
2 /*!
3 //  \file blaze/math/simd/Tan.h
4 //  \brief Header file for the SIMD tangent functionality
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_SIMD_TAN_H_
36 #define _BLAZE_MATH_SIMD_TAN_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #if BLAZE_SLEEF_MODE
44 #  include <sleef.h>
45 #endif
46 #include <blaze/math/simd/BasicTypes.h>
47 #include <blaze/system/Inline.h>
48 #include <blaze/system/Vectorization.h>
49 
50 
51 namespace blaze {
52 
53 //=================================================================================================
54 //
55 //  32-BIT FLOATING POINT SIMD TYPES
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
60 /*!\brief Tangent of a vector of single precision floating point values.
61 // \ingroup simd
62 //
63 // \param a The vector of single precision floating point values.
64 // \return The resulting vector.
65 //
66 // This operation is only available via the SVML or SLEEF for SSE, AVX, MIC, and AVX-512.
67 */
68 template< typename T >  // Type of the operand
tan(const SIMDf32<T> & a)69 BLAZE_ALWAYS_INLINE const SIMDfloat tan( const SIMDf32<T>& a ) noexcept
70 #if BLAZE_SVML_MODE
71 #  if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
72 {
73    return _mm512_tan_ps( (*a).eval().value );
74 }
75 #  elif BLAZE_AVX_MODE
76 {
77    return _mm256_tan_ps( (*a).eval().value );
78 }
79 #  elif BLAZE_SSE_MODE
80 {
81    return _mm_tan_ps( (*a).eval().value );
82 }
83 #  endif
84 #elif BLAZE_SLEEF_MODE
85 #  if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
86 {
87    return Sleef_tanf16_u10( (*a).eval().value );
88 }
89 #  elif BLAZE_AVX_MODE
90 {
91    return Sleef_tanf8_u10( (*a).eval().value );
92 }
93 #  elif BLAZE_SSE_MODE
94 {
95    return Sleef_tanf4_u10( (*a).eval().value );
96 }
97 #  endif
98 #else
99 = delete;
100 #endif
101 //*************************************************************************************************
102 
103 
104 
105 
106 //=================================================================================================
107 //
108 //  64-BIT FLOATING POINT SIMD TYPES
109 //
110 //=================================================================================================
111 
112 //*************************************************************************************************
113 /*!\brief Tangent of a vector of double precision floating point values.
114 // \ingroup simd
115 //
116 // \param a The vector of double precision floating point values.
117 // \return The resulting vector.
118 //
119 // This operation is only available via the SVML or SLEEF for SSE, AVX, MIC, and AVX-512.
120 */
121 template< typename T >  // Type of the operand
tan(const SIMDf64<T> & a)122 BLAZE_ALWAYS_INLINE const SIMDdouble tan( const SIMDf64<T>& a ) noexcept
123 #if BLAZE_SVML_MODE
124 #  if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
125 {
126    return _mm512_tan_pd( (*a).eval().value );
127 }
128 #  elif BLAZE_AVX_MODE
129 {
130    return _mm256_tan_pd( (*a).eval().value );
131 }
132 #  elif BLAZE_SSE_MODE
133 {
134    return _mm_tan_pd( (*a).eval().value );
135 }
136 #  endif
137 #elif BLAZE_SLEEF_MODE
138 #  if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
139 {
140    return Sleef_tand8_u10( (*a).eval().value );
141 }
142 #  elif BLAZE_AVX_MODE
143 {
144    return Sleef_tand4_u10( (*a).eval().value );
145 }
146 #  elif BLAZE_SSE_MODE
147 {
148    return Sleef_tand2_u10( (*a).eval().value );
149 }
150 #  endif
151 #else
152 = delete;
153 #endif
154 //*************************************************************************************************
155 
156 } // namespace blaze
157 
158 #endif
159