Eigen  3.3.9
 
Loading...
Searching...
No Matches
TypeCasting.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2015 Benoit Steiner <benoit.steiner.goog@gmail.com>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#ifndef EIGEN_TYPE_CASTING_SSE_H
11#define EIGEN_TYPE_CASTING_SSE_H
12
13namespace Eigen {
14
15namespace internal {
16
17#ifndef EIGEN_VECTORIZE_AVX
18template <>
19struct type_casting_traits<float, int> {
20 enum {
21 VectorizedCast = 1,
22 SrcCoeffRatio = 1,
23 TgtCoeffRatio = 1
24 };
25};
26
27template <>
28struct type_casting_traits<int, float> {
29 enum {
30 VectorizedCast = 1,
31 SrcCoeffRatio = 1,
32 TgtCoeffRatio = 1
33 };
34};
35
36template <>
37struct type_casting_traits<double, float> {
38 enum {
39 VectorizedCast = 1,
40 SrcCoeffRatio = 2,
41 TgtCoeffRatio = 1
42 };
43};
44
45template <>
46struct type_casting_traits<float, double> {
47 enum {
48 VectorizedCast = 1,
49 SrcCoeffRatio = 1,
50 TgtCoeffRatio = 2
51 };
52};
53#endif
54
55template<> EIGEN_STRONG_INLINE Packet4i pcast<Packet4f, Packet4i>(const Packet4f& a) {
56 return _mm_cvttps_epi32(a);
57}
58
59template<> EIGEN_STRONG_INLINE Packet4f pcast<Packet4i, Packet4f>(const Packet4i& a) {
60 return _mm_cvtepi32_ps(a);
61}
62
63template<> EIGEN_STRONG_INLINE Packet4f pcast<Packet2d, Packet4f>(const Packet2d& a, const Packet2d& b) {
64 return _mm_shuffle_ps(_mm_cvtpd_ps(a), _mm_cvtpd_ps(b), (1 << 2) | (1 << 6));
65}
66
67template<> EIGEN_STRONG_INLINE Packet2d pcast<Packet4f, Packet2d>(const Packet4f& a) {
68 // Simply discard the second half of the input
69 return _mm_cvtps_pd(a);
70}
71
72
73} // end namespace internal
74
75} // end namespace Eigen
76
77#endif // EIGEN_TYPE_CASTING_SSE_H
Namespace containing all symbols from the Eigen library.
Definition A05_PortingFrom2To3.dox:1