![]() |
Eigen
3.3.3
|
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2015 Benoit Steiner <benoit.steiner.goog@gmail.com> 00005 // 00006 // This Source Code Form is subject to the terms of the Mozilla 00007 // Public License v. 2.0. If a copy of the MPL was not distributed 00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 00009 00010 #ifndef EIGEN_TYPE_CASTING_SSE_H 00011 #define EIGEN_TYPE_CASTING_SSE_H 00012 00013 namespace Eigen { 00014 00015 namespace internal { 00016 00017 template <> 00018 struct type_casting_traits<float, int> { 00019 enum { 00020 VectorizedCast = 1, 00021 SrcCoeffRatio = 1, 00022 TgtCoeffRatio = 1 00023 }; 00024 }; 00025 00026 template<> EIGEN_STRONG_INLINE Packet4i pcast<Packet4f, Packet4i>(const Packet4f& a) { 00027 return _mm_cvttps_epi32(a); 00028 } 00029 00030 00031 template <> 00032 struct type_casting_traits<int, float> { 00033 enum { 00034 VectorizedCast = 1, 00035 SrcCoeffRatio = 1, 00036 TgtCoeffRatio = 1 00037 }; 00038 }; 00039 00040 template<> EIGEN_STRONG_INLINE Packet4f pcast<Packet4i, Packet4f>(const Packet4i& a) { 00041 return _mm_cvtepi32_ps(a); 00042 } 00043 00044 00045 template <> 00046 struct type_casting_traits<double, float> { 00047 enum { 00048 VectorizedCast = 1, 00049 SrcCoeffRatio = 2, 00050 TgtCoeffRatio = 1 00051 }; 00052 }; 00053 00054 template<> EIGEN_STRONG_INLINE Packet4f pcast<Packet2d, Packet4f>(const Packet2d& a, const Packet2d& b) { 00055 return _mm_shuffle_ps(_mm_cvtpd_ps(a), _mm_cvtpd_ps(b), (1 << 2) | (1 << 6)); 00056 } 00057 00058 template <> 00059 struct type_casting_traits<float, double> { 00060 enum { 00061 VectorizedCast = 1, 00062 SrcCoeffRatio = 1, 00063 TgtCoeffRatio = 2 00064 }; 00065 }; 00066 00067 template<> EIGEN_STRONG_INLINE Packet2d pcast<Packet4f, Packet2d>(const Packet4f& a) { 00068 // Simply discard the second half of the input 00069 return _mm_cvtps_pd(a); 00070 } 00071 00072 00073 } // end namespace internal 00074 00075 } // end namespace Eigen 00076 00077 #endif // EIGEN_TYPE_CASTING_SSE_H