File indexing completed on 2025-01-18 09:57:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef EIGEN_MOREVECTORIZATION_MATHFUNCTIONS_H
0012 #define EIGEN_MOREVECTORIZATION_MATHFUNCTIONS_H
0013
0014 namespace Eigen {
0015
0016 namespace internal {
0017
0018
0019 template<typename Packet> inline static Packet pasin(Packet a) { return std::asin(a); }
0020
0021 #ifdef EIGEN_VECTORIZE_SSE
0022
0023 template<> EIGEN_DONT_INLINE Packet4f pasin(Packet4f x)
0024 {
0025 _EIGEN_DECLARE_CONST_Packet4f(half, 0.5);
0026 _EIGEN_DECLARE_CONST_Packet4f(minus_half, -0.5);
0027 _EIGEN_DECLARE_CONST_Packet4f(3half, 1.5);
0028
0029 _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(sign_mask, 0x80000000);
0030
0031 _EIGEN_DECLARE_CONST_Packet4f(pi, 3.141592654);
0032 _EIGEN_DECLARE_CONST_Packet4f(pi_over_2, 3.141592654*0.5);
0033
0034 _EIGEN_DECLARE_CONST_Packet4f(asin1, 4.2163199048E-2);
0035 _EIGEN_DECLARE_CONST_Packet4f(asin2, 2.4181311049E-2);
0036 _EIGEN_DECLARE_CONST_Packet4f(asin3, 4.5470025998E-2);
0037 _EIGEN_DECLARE_CONST_Packet4f(asin4, 7.4953002686E-2);
0038 _EIGEN_DECLARE_CONST_Packet4f(asin5, 1.6666752422E-1);
0039
0040 Packet4f a = pabs(x);
0041
0042 Packet4f sign_bit= _mm_and_ps(x, p4f_sign_mask);
0043
0044 Packet4f z1,z2;
0045
0046
0047
0048
0049
0050 Packet4f branch_mask= _mm_cmpgt_ps(a, p4f_half);
0051
0052
0053
0054 {
0055
0056 z1=pmadd(p4f_minus_half,a,p4f_half);
0057 Packet4f x1=psqrt(z1);
0058 Packet4f s1=pmadd(p4f_asin1, z1, p4f_asin2);
0059 Packet4f s2=pmadd(s1, z1, p4f_asin3);
0060 Packet4f s3=pmadd(s2,z1, p4f_asin4);
0061 Packet4f s4=pmadd(s3,z1, p4f_asin5);
0062 Packet4f temp=pmul(s4,z1);
0063 z1=pmadd(temp,x1,x1);
0064 z1=padd(z1,z1);
0065 z1=psub(p4f_pi_over_2,z1);
0066 }
0067
0068 {
0069
0070 Packet4f x2=a;
0071 z2=pmul(x2,x2);
0072 Packet4f s1=pmadd(p4f_asin1, z2, p4f_asin2);
0073 Packet4f s2=pmadd(s1, z2, p4f_asin3);
0074 Packet4f s3=pmadd(s2,z2, p4f_asin4);
0075 Packet4f s4=pmadd(s3,z2, p4f_asin5);
0076 Packet4f temp=pmul(s4,z2);
0077 z2=pmadd(temp,x2,x2);
0078 }
0079
0080
0081 z1 = _mm_and_ps(branch_mask, z1);
0082 z2 = _mm_andnot_ps(branch_mask, z2);
0083 Packet4f z = _mm_or_ps(z1,z2);
0084
0085
0086 return _mm_xor_ps(z, sign_bit);
0087 }
0088
0089 #endif
0090
0091 }
0092
0093 }
0094
0095 #endif