Eigen  5.0.1
 
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) 2020, Arm Limited and Contributors
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// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_TYPE_CASTING_SVE_H
12#define EIGEN_TYPE_CASTING_SVE_H
13
14// IWYU pragma: private
15#include "../../InternalHeaderCheck.h"
16
17namespace Eigen {
18namespace internal {
19
20template <>
21struct type_casting_traits<float, numext::int32_t> {
22 enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 };
23};
24
25template <>
26struct type_casting_traits<numext::int32_t, float> {
27 enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 };
28};
29
30template <>
31EIGEN_STRONG_INLINE PacketXf pcast<PacketXi, PacketXf>(const PacketXi& a) {
32 return svcvt_f32_s32_x(svptrue_b32(), a);
33}
34
35template <>
36EIGEN_STRONG_INLINE PacketXi pcast<PacketXf, PacketXi>(const PacketXf& a) {
37 return svcvt_s32_f32_x(svptrue_b32(), a);
38}
39
40template <>
41EIGEN_STRONG_INLINE PacketXf preinterpret<PacketXf, PacketXi>(const PacketXi& a) {
42 return svreinterpret_f32_s32(a);
43}
44
45template <>
46EIGEN_STRONG_INLINE PacketXi preinterpret<PacketXi, PacketXf>(const PacketXf& a) {
47 return svreinterpret_s32_f32(a);
48}
49
50template <>
51struct type_casting_traits<double, numext::int64_t> {
52 enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 };
53};
54
55template <>
56struct type_casting_traits<numext::int64_t, double> {
57 enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 };
58};
59
60template <>
61EIGEN_STRONG_INLINE PacketXd pcast<PacketXl, PacketXd>(const PacketXl& a) {
62 return svcvt_f64_s64_x(svptrue_b64(), a);
63}
64
65template <>
66EIGEN_STRONG_INLINE PacketXl pcast<PacketXd, PacketXl>(const PacketXd& a) {
67 return svcvt_s64_f64_x(svptrue_b64(), a);
68}
69
70template <>
71EIGEN_STRONG_INLINE PacketXd preinterpret<PacketXd, PacketXl>(const PacketXl& a) {
72 return svreinterpret_f64_s64(a);
73}
74
75template <>
76EIGEN_STRONG_INLINE PacketXl preinterpret<PacketXl, PacketXd>(const PacketXd& a) {
77 return svreinterpret_s64_f64(a);
78}
79
80} // namespace internal
81} // namespace Eigen
82
83#endif // EIGEN_TYPE_CASTING_SVE_H