$darkmode
Eigen  5.0.1-dev
TypeCasting.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2023 Zang Ruochen <zangruochen@loongson.cn>
5 // Copyright (C) 2024 XiWei Gu <guxiwei-hf@loongson.cn>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_TYPE_CASTING_LSX_H
12 #define EIGEN_TYPE_CASTING_LSX_H
13 
14 // IWYU pragma: private
15 #include "../../InternalHeaderCheck.h"
16 
17 namespace Eigen {
18 
19 namespace internal {
20 
21 //==============================================================================
22 // preinterpret
23 //==============================================================================
24 template <>
25 EIGEN_STRONG_INLINE Packet4f preinterpret<Packet4f, Packet4i>(const Packet4i& a) {
26  return (__m128)((__m128i)a);
27 }
28 template <>
29 EIGEN_STRONG_INLINE Packet4f preinterpret<Packet4f, Packet4ui>(const Packet4ui& a) {
30  return (__m128)((__m128i)a);
31 }
32 template <>
33 EIGEN_STRONG_INLINE Packet2d preinterpret<Packet2d, Packet2l>(const Packet2l& a) {
34  return (__m128d)((__m128i)a);
35 }
36 template <>
37 EIGEN_STRONG_INLINE Packet2d preinterpret<Packet2d, Packet2ul>(const Packet2ul& a) {
38  return (__m128d)((__m128i)a);
39 }
40 template <>
41 EIGEN_STRONG_INLINE Packet2d preinterpret<Packet2d, Packet4i>(const Packet4i& a) {
42  return (__m128d)((__m128i)a);
43 }
44 template <>
45 EIGEN_STRONG_INLINE Packet16c preinterpret<Packet16c, Packet16uc>(const Packet16uc& a) {
46  return (__m128i)a;
47 }
48 template <>
49 EIGEN_STRONG_INLINE Packet8s preinterpret<Packet8s, Packet8us>(const Packet8us& a) {
50  return (__m128i)a;
51 }
52 template <>
53 EIGEN_STRONG_INLINE Packet4i preinterpret<Packet4i, Packet4f>(const Packet4f& a) {
54  return (__m128i)a;
55 }
56 template <>
57 EIGEN_STRONG_INLINE Packet4i preinterpret<Packet4i, Packet4ui>(const Packet4ui& a) {
58  return (__m128i)a;
59 }
60 template <>
61 EIGEN_STRONG_INLINE Packet4i preinterpret<Packet4i, Packet2d>(const Packet2d& a) {
62  return (__m128i)a;
63 }
64 template <>
65 EIGEN_STRONG_INLINE Packet2l preinterpret<Packet2l, Packet2d>(const Packet2d& a) {
66  return (__m128i)a;
67 }
68 template <>
69 EIGEN_STRONG_INLINE Packet16uc preinterpret<Packet16uc, Packet16c>(const Packet16c& a) {
70  return (__m128i)a;
71 }
72 template <>
73 EIGEN_STRONG_INLINE Packet8us preinterpret<Packet8us, Packet8s>(const Packet8s& a) {
74  return (__m128i)a;
75 }
76 template <>
77 EIGEN_STRONG_INLINE Packet4ui preinterpret<Packet4ui, Packet4f>(const Packet4f& a) {
78  return (__m128i)a;
79 }
80 template <>
81 EIGEN_STRONG_INLINE Packet4ui preinterpret<Packet4ui, Packet4i>(const Packet4i& a) {
82  return (__m128i)a;
83 }
84 template <>
85 EIGEN_STRONG_INLINE Packet2ul preinterpret<Packet2ul, Packet2d>(const Packet2d& a) {
86  return (__m128i)a;
87 }
88 template <>
89 EIGEN_STRONG_INLINE Packet2ul preinterpret<Packet2ul, Packet2l>(const Packet2l& a) {
90  return (__m128i)a;
91 }
92 
93 template <>
94 EIGEN_STRONG_INLINE Packet2l pcast<Packet4f, Packet2l>(const Packet4f& a) {
95  Packet2d tmp = __lsx_vfcvtl_d_s(a);
96  return __lsx_vftint_l_d(tmp);
97 }
98 template <>
99 EIGEN_STRONG_INLINE Packet2ul pcast<Packet4f, Packet2ul>(const Packet4f& a) {
100  Packet2d tmp = __lsx_vfcvtl_d_s(a);
101  return __lsx_vftint_lu_d(tmp);
102 }
103 template <>
104 EIGEN_STRONG_INLINE Packet4i pcast<Packet4f, Packet4i>(const Packet4f& a) {
105  return __lsx_vftint_w_s(a);
106 }
107 template <>
108 EIGEN_STRONG_INLINE Packet4ui pcast<Packet4f, Packet4ui>(const Packet4f& a) {
109  return __lsx_vftint_wu_s(a);
110 }
111 template <>
112 EIGEN_STRONG_INLINE Packet8s pcast<Packet4f, Packet8s>(const Packet4f& a, const Packet4f& b) {
113  return __lsx_vssrlni_h_w(__lsx_vftint_w_s(a), __lsx_vftint_w_s(b), 0);
114 }
115 template <>
116 EIGEN_STRONG_INLINE Packet8us pcast<Packet4f, Packet8us>(const Packet4f& a, const Packet4f& b) {
117  return __lsx_vssrlni_hu_w(__lsx_vftint_wu_s(a), __lsx_vftint_wu_s(b), 0);
118 }
119 template <>
120 EIGEN_STRONG_INLINE Packet16c pcast<Packet4f, Packet16c>(const Packet4f& a, const Packet4f& b, const Packet4f& c,
121  const Packet4f& d) {
122  Packet8s tmp1 = __lsx_vssrlni_h_w(__lsx_vftint_w_s(a), __lsx_vftint_w_s(b), 0);
123  Packet8s tmp2 = __lsx_vssrlni_h_w(__lsx_vftint_w_s(c), __lsx_vftint_w_s(d), 0);
124  return __lsx_vssrlni_b_h((__m128i)tmp1, (__m128i)tmp2, 0);
125 }
126 template <>
127 EIGEN_STRONG_INLINE Packet16uc pcast<Packet4f, Packet16uc>(const Packet4f& a, const Packet4f& b, const Packet4f& c,
128  const Packet4f& d) {
129  Packet8us tmp1 = __lsx_vssrlni_hu_w(__lsx_vftint_wu_s(a), __lsx_vftint_wu_s(b), 0);
130  Packet8us tmp2 = __lsx_vssrlni_hu_w(__lsx_vftint_wu_s(c), __lsx_vftint_wu_s(d), 0);
131  return __lsx_vssrlni_bu_h((__m128i)tmp1, (__m128i)tmp2, 0);
132 }
133 
134 template <>
135 EIGEN_STRONG_INLINE Packet4f pcast<Packet16c, Packet4f>(const Packet16c& a) {
136  Packet8s tmp1 = __lsx_vsllwil_h_b((__m128i)a, 0);
137  Packet4i tmp2 = __lsx_vsllwil_w_h((__m128i)tmp1, 0);
138  return __lsx_vffint_s_w(tmp2);
139 }
140 template <>
141 EIGEN_STRONG_INLINE Packet2l pcast<Packet16c, Packet2l>(const Packet16c& a) {
142  Packet8s tmp1 = __lsx_vsllwil_h_b((__m128i)a, 0);
143  Packet4i tmp2 = __lsx_vsllwil_w_h((__m128i)tmp1, 0);
144  return __lsx_vsllwil_d_w((__m128i)tmp2, 0);
145 }
146 template <>
147 EIGEN_STRONG_INLINE Packet2ul pcast<Packet16c, Packet2ul>(const Packet16c& a) {
148  Packet8s tmp1 = __lsx_vsllwil_h_b((__m128i)a, 0);
149  Packet4i tmp2 = __lsx_vsllwil_w_h((__m128i)tmp1, 0);
150  return (Packet2ul)__lsx_vsllwil_d_w((__m128i)tmp2, 0);
151 }
152 template <>
153 EIGEN_STRONG_INLINE Packet4i pcast<Packet16c, Packet4i>(const Packet16c& a) {
154  Packet8s tmp1 = __lsx_vsllwil_h_b((__m128i)a, 0);
155  return __lsx_vsllwil_w_h((__m128i)tmp1, 0);
156 }
157 template <>
158 EIGEN_STRONG_INLINE Packet4ui pcast<Packet16c, Packet4ui>(const Packet16c& a) {
159  Packet8s tmp1 = __lsx_vsllwil_h_b((__m128i)a, 0);
160  return (Packet4ui)__lsx_vsllwil_w_h((__m128i)tmp1, 0);
161 }
162 template <>
163 EIGEN_STRONG_INLINE Packet8s pcast<Packet16c, Packet8s>(const Packet16c& a) {
164  return __lsx_vsllwil_h_b((__m128i)a, 0);
165 }
166 template <>
167 EIGEN_STRONG_INLINE Packet8us pcast<Packet16c, Packet8us>(const Packet16c& a) {
168  return (Packet8us)__lsx_vsllwil_h_b((__m128i)a, 0);
169 }
170 
171 template <>
172 EIGEN_STRONG_INLINE Packet4f pcast<Packet16uc, Packet4f>(const Packet16uc& a) {
173  Packet8us tmp1 = __lsx_vsllwil_hu_bu((__m128i)a, 0);
174  Packet4ui tmp2 = __lsx_vsllwil_wu_hu((__m128i)tmp1, 0);
175  return __lsx_vffint_s_wu(tmp2);
176 }
177 template <>
178 EIGEN_STRONG_INLINE Packet2ul pcast<Packet16uc, Packet2ul>(const Packet16uc& a) {
179  Packet8us tmp1 = __lsx_vsllwil_hu_bu((__m128i)a, 0);
180  Packet4ui tmp2 = __lsx_vsllwil_wu_hu((__m128i)tmp1, 0);
181  return __lsx_vsllwil_du_wu((__m128i)tmp2, 0);
182 }
183 template <>
184 EIGEN_STRONG_INLINE Packet2l pcast<Packet16uc, Packet2l>(const Packet16uc& a) {
185  Packet8us tmp1 = __lsx_vsllwil_hu_bu((__m128i)a, 0);
186  Packet4ui tmp2 = __lsx_vsllwil_wu_hu((__m128i)tmp1, 0);
187  return (Packet2l)__lsx_vsllwil_du_wu((__m128i)tmp2, 0);
188 }
189 template <>
190 EIGEN_STRONG_INLINE Packet4ui pcast<Packet16uc, Packet4ui>(const Packet16uc& a) {
191  Packet8us tmp1 = __lsx_vsllwil_hu_bu((__m128i)a, 0);
192  return __lsx_vsllwil_wu_hu((__m128i)tmp1, 0);
193 }
194 template <>
195 EIGEN_STRONG_INLINE Packet4i pcast<Packet16uc, Packet4i>(const Packet16uc& a) {
196  Packet8us tmp1 = __lsx_vsllwil_hu_bu((__m128i)a, 0);
197  return (Packet4i)__lsx_vsllwil_wu_hu((__m128i)tmp1, 0);
198 }
199 template <>
200 EIGEN_STRONG_INLINE Packet8us pcast<Packet16uc, Packet8us>(const Packet16uc& a) {
201  return __lsx_vsllwil_hu_bu((__m128i)a, 0);
202 }
203 template <>
204 EIGEN_STRONG_INLINE Packet8s pcast<Packet16uc, Packet8s>(const Packet16uc& a) {
205  return (Packet8s)__lsx_vsllwil_hu_bu((__m128i)a, 0);
206 }
207 
208 template <>
209 EIGEN_STRONG_INLINE Packet4f pcast<Packet8s, Packet4f>(const Packet8s& a) {
210  Packet4i tmp1 = __lsx_vsllwil_w_h((__m128i)a, 0);
211  return __lsx_vffint_s_w(tmp1);
212 }
213 template <>
214 EIGEN_STRONG_INLINE Packet2l pcast<Packet8s, Packet2l>(const Packet8s& a) {
215  Packet4i tmp1 = __lsx_vsllwil_w_h((__m128i)a, 0);
216  return __lsx_vsllwil_d_w((__m128i)tmp1, 0);
217 }
218 template <>
219 EIGEN_STRONG_INLINE Packet2ul pcast<Packet8s, Packet2ul>(const Packet8s& a) {
220  Packet4i tmp1 = __lsx_vsllwil_w_h((__m128i)a, 0);
221  return (Packet2ul)__lsx_vsllwil_d_w((__m128i)tmp1, 0);
222 }
223 template <>
224 EIGEN_STRONG_INLINE Packet4i pcast<Packet8s, Packet4i>(const Packet8s& a) {
225  return __lsx_vsllwil_w_h((__m128i)a, 0);
226 }
227 template <>
228 EIGEN_STRONG_INLINE Packet4ui pcast<Packet8s, Packet4ui>(const Packet8s& a) {
229  return (Packet4ui)__lsx_vsllwil_w_h((__m128i)a, 0);
230 }
231 template <>
232 EIGEN_STRONG_INLINE Packet16c pcast<Packet8s, Packet16c>(const Packet8s& a, const Packet8s& b) {
233  return __lsx_vssrlni_b_h((__m128i)a, (__m128i)b, 0);
234 }
235 template <>
236 EIGEN_STRONG_INLINE Packet16uc pcast<Packet8s, Packet16uc>(const Packet8s& a, const Packet8s& b) {
237  return (Packet16uc)__lsx_vssrlni_b_h((__m128i)a, (__m128i)b, 0);
238 }
239 
240 template <>
241 EIGEN_STRONG_INLINE Packet4f pcast<Packet8us, Packet4f>(const Packet8us& a) {
242  Packet4ui tmp1 = __lsx_vsllwil_wu_hu((__m128i)a, 0);
243  return __lsx_vffint_s_wu(tmp1);
244 }
245 template <>
246 EIGEN_STRONG_INLINE Packet2ul pcast<Packet8us, Packet2ul>(const Packet8us& a) {
247  Packet4ui tmp1 = __lsx_vsllwil_wu_hu((__m128i)a, 0);
248  return __lsx_vsllwil_du_wu((__m128i)tmp1, 0);
249 }
250 template <>
251 EIGEN_STRONG_INLINE Packet2l pcast<Packet8us, Packet2l>(const Packet8us& a) {
252  Packet4ui tmp1 = __lsx_vsllwil_wu_hu((__m128i)a, 0);
253  return (Packet2l)__lsx_vsllwil_du_wu((__m128i)tmp1, 0);
254 }
255 template <>
256 EIGEN_STRONG_INLINE Packet4ui pcast<Packet8us, Packet4ui>(const Packet8us& a) {
257  return __lsx_vsllwil_wu_hu((__m128i)a, 0);
258 }
259 template <>
260 EIGEN_STRONG_INLINE Packet4i pcast<Packet8us, Packet4i>(const Packet8us& a) {
261  return (Packet4i)__lsx_vsllwil_wu_hu((__m128i)a, 0);
262 }
263 template <>
264 EIGEN_STRONG_INLINE Packet16uc pcast<Packet8us, Packet16uc>(const Packet8us& a, const Packet8us& b) {
265  return __lsx_vssrlni_bu_h((__m128i)a, (__m128i)b, 0);
266 }
267 template <>
268 EIGEN_STRONG_INLINE Packet16c pcast<Packet8us, Packet16c>(const Packet8us& a, const Packet8us& b) {
269  return (Packet16c)__lsx_vssrlni_bu_h((__m128i)a, (__m128i)b, 0);
270 }
271 
272 template <>
273 EIGEN_STRONG_INLINE Packet4f pcast<Packet4i, Packet4f>(const Packet4i& a) {
274  return __lsx_vffint_s_w(a);
275 }
276 template <>
277 EIGEN_STRONG_INLINE Packet2l pcast<Packet4i, Packet2l>(const Packet4i& a) {
278  return __lsx_vsllwil_d_w((__m128i)a, 0);
279 }
280 template <>
281 EIGEN_STRONG_INLINE Packet2ul pcast<Packet4i, Packet2ul>(const Packet4i& a) {
282  return (Packet2ul)__lsx_vsllwil_d_w((__m128i)a, 0);
283 }
284 template <>
285 EIGEN_STRONG_INLINE Packet8s pcast<Packet4i, Packet8s>(const Packet4i& a, const Packet4i& b) {
286  return __lsx_vssrlni_h_w((__m128i)a, (__m128i)b, 0);
287 }
288 template <>
289 EIGEN_STRONG_INLINE Packet8us pcast<Packet4i, Packet8us>(const Packet4i& a, const Packet4i& b) {
290  return (Packet8us)__lsx_vssrlni_h_w((__m128i)a, (__m128i)b, 0);
291 }
292 template <>
293 EIGEN_STRONG_INLINE Packet16c pcast<Packet4i, Packet16c>(const Packet4i& a, const Packet4i& b, const Packet4i& c,
294  const Packet4i& d) {
295  Packet8s tmp1 = __lsx_vssrlni_h_w((__m128i)a, (__m128i)b, 0);
296  Packet8s tmp2 = __lsx_vssrlni_h_w((__m128i)c, (__m128i)d, 0);
297  return __lsx_vssrlni_b_h((__m128i)tmp1, (__m128i)tmp2, 0);
298 }
299 template <>
300 EIGEN_STRONG_INLINE Packet16uc pcast<Packet4i, Packet16uc>(const Packet4i& a, const Packet4i& b, const Packet4i& c,
301  const Packet4i& d) {
302  Packet8s tmp1 = __lsx_vssrlni_h_w((__m128i)a, (__m128i)b, 0);
303  Packet8s tmp2 = __lsx_vssrlni_h_w((__m128i)c, (__m128i)d, 0);
304  return (Packet16uc)__lsx_vssrlni_b_h((__m128i)tmp1, (__m128i)tmp2, 0);
305 }
306 
307 template <>
308 EIGEN_STRONG_INLINE Packet4f pcast<Packet4ui, Packet4f>(const Packet4ui& a) {
309  return __lsx_vffint_s_wu(a);
310 }
311 template <>
312 EIGEN_STRONG_INLINE Packet2ul pcast<Packet4ui, Packet2ul>(const Packet4ui& a) {
313  return __lsx_vsllwil_du_wu((__m128i)a, 0);
314 }
315 template <>
316 EIGEN_STRONG_INLINE Packet2l pcast<Packet4ui, Packet2l>(const Packet4ui& a) {
317  return (Packet2l)__lsx_vsllwil_du_wu((__m128i)a, 0);
318 }
319 template <>
320 EIGEN_STRONG_INLINE Packet8us pcast<Packet4ui, Packet8us>(const Packet4ui& a, const Packet4ui& b) {
321  return __lsx_vssrlni_hu_w((__m128i)a, (__m128i)b, 0);
322 }
323 template <>
324 EIGEN_STRONG_INLINE Packet8s pcast<Packet4ui, Packet8s>(const Packet4ui& a, const Packet4ui& b) {
325  return (Packet8s)__lsx_vssrlni_hu_w((__m128i)a, (__m128i)b, 0);
326 }
327 template <>
328 EIGEN_STRONG_INLINE Packet16uc pcast<Packet4ui, Packet16uc>(const Packet4ui& a, const Packet4ui& b, const Packet4ui& c,
329  const Packet4ui& d) {
330  Packet8us tmp1 = __lsx_vssrlni_hu_w((__m128i)a, (__m128i)b, 0);
331  Packet8us tmp2 = __lsx_vssrlni_hu_w((__m128i)c, (__m128i)d, 0);
332  return __lsx_vssrlni_bu_h((__m128i)tmp1, (__m128i)tmp2, 0);
333 }
334 template <>
335 EIGEN_STRONG_INLINE Packet16c pcast<Packet4ui, Packet16c>(const Packet4ui& a, const Packet4ui& b, const Packet4ui& c,
336  const Packet4ui& d) {
337  Packet8us tmp1 = __lsx_vssrlni_hu_w((__m128i)a, (__m128i)b, 0);
338  Packet8us tmp2 = __lsx_vssrlni_hu_w((__m128i)c, (__m128i)d, 0);
339  return (Packet16c)__lsx_vssrlni_bu_h((__m128i)tmp1, (__m128i)tmp2, 0);
340 }
341 
342 template <>
343 EIGEN_STRONG_INLINE Packet4f pcast<Packet2l, Packet4f>(const Packet2l& a, const Packet2l& b) {
344  return __lsx_vffint_s_w(__lsx_vssrlni_w_d((__m128i)a, (__m128i)b, 0));
345 }
346 template <>
347 EIGEN_STRONG_INLINE Packet4i pcast<Packet2l, Packet4i>(const Packet2l& a, const Packet2l& b) {
348  return __lsx_vssrlni_w_d((__m128i)a, (__m128i)b, 0);
349 }
350 template <>
351 EIGEN_STRONG_INLINE Packet4ui pcast<Packet2l, Packet4ui>(const Packet2l& a, const Packet2l& b) {
352  return (Packet4ui)__lsx_vssrlni_w_d((__m128i)a, (__m128i)b, 0);
353 }
354 template <>
355 EIGEN_STRONG_INLINE Packet8s pcast<Packet2l, Packet8s>(const Packet2l& a, const Packet2l& b, const Packet2l& c,
356  const Packet2l& d) {
357  Packet4i tmp1 = __lsx_vssrlni_w_d((__m128i)a, (__m128i)b, 0);
358  Packet4i tmp2 = __lsx_vssrlni_w_d((__m128i)c, (__m128i)d, 0);
359  return __lsx_vssrlni_h_w((__m128i)tmp1, (__m128i)tmp2, 0);
360 }
361 template <>
362 EIGEN_STRONG_INLINE Packet8us pcast<Packet2l, Packet8us>(const Packet2l& a, const Packet2l& b, const Packet2l& c,
363  const Packet2l& d) {
364  Packet4i tmp1 = __lsx_vssrlni_w_d((__m128i)a, (__m128i)b, 0);
365  Packet4i tmp2 = __lsx_vssrlni_w_d((__m128i)c, (__m128i)d, 0);
366  return (Packet8us)__lsx_vssrlni_h_w((__m128i)tmp1, (__m128i)tmp2, 0);
367 }
368 template <>
369 EIGEN_STRONG_INLINE Packet16c pcast<Packet2l, Packet16c>(const Packet2l& a, const Packet2l& b, const Packet2l& c,
370  const Packet2l& d, const Packet2l& e, const Packet2l& f,
371  const Packet2l& g, const Packet2l& h) {
372  const Packet8s abcd = pcast<Packet2l, Packet8s>(a, b, c, d);
373  const Packet8s efgh = pcast<Packet2l, Packet8s>(e, f, g, h);
374  return __lsx_vssrlni_b_h((__m128i)abcd, (__m128i)efgh, 0);
375 }
376 template <>
377 EIGEN_STRONG_INLINE Packet16uc pcast<Packet2l, Packet16uc>(const Packet2l& a, const Packet2l& b, const Packet2l& c,
378  const Packet2l& d, const Packet2l& e, const Packet2l& f,
379  const Packet2l& g, const Packet2l& h) {
380  const Packet8us abcd = pcast<Packet2l, Packet8us>(a, b, c, d);
381  const Packet8us efgh = pcast<Packet2l, Packet8us>(e, f, g, h);
382  return __lsx_vssrlni_bu_h((__m128i)abcd, (__m128i)efgh, 0);
383 }
384 
385 template <>
386 EIGEN_STRONG_INLINE Packet4f pcast<Packet2ul, Packet4f>(const Packet2ul& a, const Packet2ul& b) {
387  return __lsx_vffint_s_wu(__lsx_vssrlni_w_d((__m128i)a, (__m128i)b, 0));
388 }
389 template <>
390 EIGEN_STRONG_INLINE Packet4ui pcast<Packet2ul, Packet4ui>(const Packet2ul& a, const Packet2ul& b) {
391  return __lsx_vssrlni_wu_d((__m128i)a, (__m128i)b, 0);
392 }
393 template <>
394 EIGEN_STRONG_INLINE Packet4i pcast<Packet2ul, Packet4i>(const Packet2ul& a, const Packet2ul& b) {
395  return (Packet4i)__lsx_vssrlni_wu_d((__m128i)a, (__m128i)b, 0);
396 }
397 template <>
398 EIGEN_STRONG_INLINE Packet8us pcast<Packet2ul, Packet8us>(const Packet2ul& a, const Packet2ul& b, const Packet2ul& c,
399  const Packet2ul& d) {
400  Packet4ui tmp1 = __lsx_vssrlni_wu_d((__m128i)a, (__m128i)b, 0);
401  Packet4ui tmp2 = __lsx_vssrlni_wu_d((__m128i)c, (__m128i)d, 0);
402  return __lsx_vssrlni_hu_w((__m128i)tmp1, (__m128i)tmp2, 0);
403 }
404 template <>
405 EIGEN_STRONG_INLINE Packet8s pcast<Packet2ul, Packet8s>(const Packet2ul& a, const Packet2ul& b, const Packet2ul& c,
406  const Packet2ul& d) {
407  Packet4ui tmp1 = __lsx_vssrlni_wu_d((__m128i)a, (__m128i)b, 0);
408  Packet4ui tmp2 = __lsx_vssrlni_wu_d((__m128i)c, (__m128i)d, 0);
409  return (Packet8s)__lsx_vssrlni_hu_w((__m128i)tmp1, (__m128i)tmp2, 0);
410 }
411 template <>
412 EIGEN_STRONG_INLINE Packet16uc pcast<Packet2ul, Packet16uc>(const Packet2ul& a, const Packet2ul& b, const Packet2ul& c,
413  const Packet2ul& d, const Packet2ul& e, const Packet2ul& f,
414  const Packet2ul& g, const Packet2ul& h) {
415  const Packet8s abcd = pcast<Packet2ul, Packet8s>(a, b, c, d);
416  const Packet8s efgh = pcast<Packet2ul, Packet8s>(e, f, g, h);
417  return __lsx_vssrlni_b_h((__m128i)abcd, (__m128i)efgh, 0);
418 }
419 template <>
420 EIGEN_STRONG_INLINE Packet16c pcast<Packet2ul, Packet16c>(const Packet2ul& a, const Packet2ul& b, const Packet2ul& c,
421  const Packet2ul& d, const Packet2ul& e, const Packet2ul& f,
422  const Packet2ul& g, const Packet2ul& h) {
423  const Packet8us abcd = pcast<Packet2ul, Packet8us>(a, b, c, d);
424  const Packet8us efgh = pcast<Packet2ul, Packet8us>(e, f, g, h);
425  return __lsx_vssrlni_bu_h((__m128i)abcd, (__m128i)efgh, 0);
426 }
427 
428 template <>
429 EIGEN_STRONG_INLINE Packet4f pcast<Packet2d, Packet4f>(const Packet2d& a, const Packet2d& b) {
430  return __lsx_vfcvt_s_d(b, a);
431 }
432 template <>
433 EIGEN_STRONG_INLINE Packet2l pcast<Packet2d, Packet2l>(const Packet2d& a) {
434  return __lsx_vftint_l_d(a);
435 }
436 template <>
437 EIGEN_STRONG_INLINE Packet2ul pcast<Packet2d, Packet2ul>(const Packet2d& a) {
438  return __lsx_vftint_lu_d(a);
439 }
440 template <>
441 EIGEN_STRONG_INLINE Packet4i pcast<Packet2d, Packet4i>(const Packet2d& a, const Packet2d& b) {
442  return __lsx_vssrlni_w_d(__lsx_vftint_l_d(a), __lsx_vftint_l_d(b), 0);
443 }
444 template <>
445 EIGEN_STRONG_INLINE Packet4ui pcast<Packet2d, Packet4ui>(const Packet2d& a, const Packet2d& b) {
446  return __lsx_vssrlni_wu_d(__lsx_vftint_lu_d(a), __lsx_vftint_lu_d(b), 0);
447 }
448 template <>
449 EIGEN_STRONG_INLINE Packet8s pcast<Packet2d, Packet8s>(const Packet2d& a, const Packet2d& b, const Packet2d& c,
450  const Packet2d& d) {
451  Packet4i tmp1 = __lsx_vssrlni_w_d(__lsx_vftint_l_d(a), __lsx_vftint_l_d(b), 0);
452  Packet4i tmp2 = __lsx_vssrlni_w_d(__lsx_vftint_l_d(c), __lsx_vftint_l_d(d), 0);
453  return __lsx_vssrlni_h_w((__m128i)tmp1, (__m128i)tmp2, 0);
454 }
455 template <>
456 EIGEN_STRONG_INLINE Packet8us pcast<Packet2d, Packet8us>(const Packet2d& a, const Packet2d& b, const Packet2d& c,
457  const Packet2d& d) {
458  Packet4ui tmp1 = __lsx_vssrlni_wu_d(__lsx_vftint_lu_d(a), __lsx_vftint_lu_d(b), 0);
459  Packet4ui tmp2 = __lsx_vssrlni_wu_d(__lsx_vftint_lu_d(c), __lsx_vftint_lu_d(d), 0);
460  return __lsx_vssrlni_hu_w((__m128i)tmp1, (__m128i)tmp2, 0);
461 }
462 template <>
463 EIGEN_STRONG_INLINE Packet16c pcast<Packet2d, Packet16c>(const Packet2d& a, const Packet2d& b, const Packet2d& c,
464  const Packet2d& d, const Packet2d& e, const Packet2d& f,
465  const Packet2d& g, const Packet2d& h) {
466  const Packet8s abcd = pcast<Packet2d, Packet8s>(a, b, c, d);
467  const Packet8s efgh = pcast<Packet2d, Packet8s>(e, f, g, h);
468  return __lsx_vssrlni_b_h((__m128i)abcd, (__m128i)efgh, 0);
469 }
470 template <>
471 EIGEN_STRONG_INLINE Packet16uc pcast<Packet2d, Packet16uc>(const Packet2d& a, const Packet2d& b, const Packet2d& c,
472  const Packet2d& d, const Packet2d& e, const Packet2d& f,
473  const Packet2d& g, const Packet2d& h) {
474  const Packet8us abcd = pcast<Packet2d, Packet8us>(a, b, c, d);
475  const Packet8us efgh = pcast<Packet2d, Packet8us>(e, f, g, h);
476  return __lsx_vssrlni_bu_h((__m128i)abcd, (__m128i)efgh, 0);
477 }
478 
479 template <>
480 EIGEN_STRONG_INLINE Packet2d pcast<Packet4f, Packet2d>(const Packet4f& a) {
481  return __lsx_vfcvtl_d_s(a);
482 }
483 template <>
484 EIGEN_STRONG_INLINE Packet2d pcast<Packet16c, Packet2d>(const Packet16c& a) {
485  Packet8s tmp1 = __lsx_vsllwil_h_b((__m128i)a, 0);
486  Packet4i tmp2 = __lsx_vsllwil_w_h((__m128i)tmp1, 0);
487  return __lsx_vffint_d_l(__lsx_vsllwil_d_w((__m128i)tmp2, 0));
488 }
489 template <>
490 EIGEN_STRONG_INLINE Packet2d pcast<Packet16uc, Packet2d>(const Packet16uc& a) {
491  Packet8us tmp1 = __lsx_vsllwil_hu_bu((__m128i)a, 0);
492  Packet4ui tmp2 = __lsx_vsllwil_wu_hu((__m128i)tmp1, 0);
493  return __lsx_vffint_d_lu(__lsx_vsllwil_du_wu((__m128i)tmp2, 0));
494 }
495 template <>
496 EIGEN_STRONG_INLINE Packet2d pcast<Packet8s, Packet2d>(const Packet8s& a) {
497  Packet4i tmp = __lsx_vsllwil_w_h((__m128i)a, 0);
498  return __lsx_vffint_d_l(__lsx_vsllwil_d_w((__m128i)tmp, 0));
499 }
500 template <>
501 EIGEN_STRONG_INLINE Packet2d pcast<Packet8us, Packet2d>(const Packet8us& a) {
502  Packet4ui tmp = __lsx_vsllwil_wu_hu((__m128i)a, 0);
503  return __lsx_vffint_d_lu(__lsx_vsllwil_du_wu((__m128i)tmp, 0));
504 }
505 template <>
506 EIGEN_STRONG_INLINE Packet2d pcast<Packet4i, Packet2d>(const Packet4i& a) {
507  return __lsx_vffint_d_l(__lsx_vsllwil_d_w((__m128i)a, 0));
508 }
509 template <>
510 EIGEN_STRONG_INLINE Packet2d pcast<Packet4ui, Packet2d>(const Packet4ui& a) {
511  return __lsx_vffint_d_lu(__lsx_vsllwil_du_wu((__m128i)a, 0));
512 }
513 template <>
514 EIGEN_STRONG_INLINE Packet2d pcast<Packet2l, Packet2d>(const Packet2l& a) {
515  return __lsx_vffint_d_l(a);
516 }
517 template <>
518 EIGEN_STRONG_INLINE Packet2d pcast<Packet2ul, Packet2d>(const Packet2ul& a) {
519  return __lsx_vffint_d_lu(a);
520 }
521 
522 } // end namespace internal
523 
524 } // end namespace Eigen
525 
526 #endif // EIGEN_TYPE_CASTING_LSX_H
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1