Debian Codegraph @

debian/missing-sources/safe_arch/tests/integration/avx_tests.rs

raw
1 use super::*;
2
3 #[test]
4 fn test_add_m256d() {
5 let a = m256d::from_array([1.0, 2.0, 3.0, 4.0]);
6 let b = m256d::from_array([5.0, 6.0, 7.0, 8.5]);
7 let c = add_m256d(a, b).to_array();
8 assert_eq!(c, [6.0, 8.0, 10.0, 12.5]);
9 }
10
11 #[test]
12 fn test_add_m256() {
13 let a = m256::from_array([1.0, 2.0, 3.0, 4.0, 20.0, 30.0, 40.0, 50.0]);
14 let b = m256::from_array([5.0, 6.0, 7.0, 8.5, 90.0, 100.0, 110.0, 51.0]);
15 let c = add_m256(a, b).to_array();
16 assert_eq!(c, [6.0, 8.0, 10.0, 12.5, 110.0, 130.0, 150.0, 101.0]);
17 }
18
19 #[test]
20 fn test_addsub_m256d() {
21 let a = m256d::from_array([10.0, 20.0, 30.0, 40.0]);
22 let b = m256d::from_array([100.0, 200.0, 300.0, 400.0]);
23 let c = addsub_m256d(a, b).to_array();
24 assert_eq!(c, [-90.0, 220.0, -270.0, 440.0]);
25 }
26
27 #[test]
28 fn test_addsub_m256() {
29 let a = m256::from_array([10.0, 20.0, 30.0, 40.0, 1.0, 2.0, 3.0, 4.0]);
30 let b = m256::from_array([1.0, 20.0, 3.0, 40.0, 11.0, 12.0, 13.0, 14.0]);
31 let c = addsub_m256(a, b).to_array();
32 assert_eq!(c, [9.0, 40.0, 27.0, 80.0, -10.0, 14.0, -10.0, 18.0]);
33 }
34
35 #[test]
36 fn test_bitand_m256d() {
37 let a = m256d::from_array([1.0, 0.0, 1.0, 0.0]);
38 let b = m256d::from_array([1.0, 1.0, 0.0, 0.0]);
39 let c = bitand_m256d(a, b).to_array();
40 assert_eq!(c, [1.0, 0.0, 0.0, 0.0]);
41 }
42
43 #[test]
44 fn test_bitand_m256() {
45 let a = m256::from_array([1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0]);
46 let b = m256::from_array([1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0]);
47 let c = bitand_m256(a, b).to_array();
48 assert_eq!(c, [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]);
49 }
50
51 #[test]
52 fn test_bitandnot_m256d() {
53 let a = m256d::from_array([1.0, 0.0, 1.0, 0.0]);
54 let b = m256d::from_array([1.0, 1.0, 0.0, 0.0]);
55 let c = bitandnot_m256d(a, b).to_array();
56 assert_eq!(c, [0.0, 1.0, 0.0, 0.0]);
57 }
58
59 #[test]
60 fn test_bitandnot_m256() {
61 let a = m256::from_array([1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0]);
62 let b = m256::from_array([1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0]);
63 let c = bitandnot_m256(a, b).to_array();
64 assert_eq!(c, [0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0]);
65 }
66
67 #[test]
68 fn test_blend_m256d() {
69 let a = m256d::from_array([10.0, 20.0, 30.0, 40.0]);
70 let b = m256d::from_array([100.0, 200.0, 300.0, 400.0]);
71 //
72 let c = blend_m256d::<0b0110>(a, b).to_array();
73 assert_eq!(c, [10.0, 200.0, 300.0, 40.0]);
74 }
75
76 #[test]
77 fn test_blend_m256() {
78 let a = m256::from_array([10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0]);
79 let b = m256::from_array([100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0]);
80 //
81 let c = blend_m256::<0b0011_0110>(a, b).to_array();
82 assert_eq!(c, [10.0, 200.0, 300.0, 40.0, 500.0, 600.0, 70.0, 80.0]);
83 }
84
85 #[test]
86 fn test_blend_varying_m256d() {
87 let a = m256d::from_array([0.0, 1.0, 20.0, 30.0]);
88 let b = m256d::from_array([2.0, 3.0, 70.0, 80.0]);
89 let mask = m256d::from_array([-1.0, 0.0, 0.0, -1.0]);
90 let c = blend_varying_m256d(a, b, mask).to_array();
91 assert_eq!(c, [2.0, 1.0, 20.0, 80.0]);
92 }
93
94 #[test]
95 fn test_blend_varying_m256() {
96 let a = m256::from_array([0.0, 1.0, 2.0, 3.0, 8.0, 9.0, 10.0, 11.0]);
97 let b = m256::from_array([4.0, 5.0, 6.0, 7.0, -4.0, -5.0, -6.0, -7.0]);
98 let mask = m256::from_array([-1.0, 0.0, -1.0, 0.0, -1.0, -1.0, 0.0, 0.0]);
99 let c = blend_varying_m256(a, b, mask).to_array();
100 assert_eq!(c, [4.0, 1.0, 6.0, 3.0, -4.0, -5.0, 10.0, 11.0]);
101 }
102
103 #[test]
104 fn test_load_m128d_splat_m256d() {
105 let a = m128d::from_array([0.0, 1.0]);
106 let b = load_m128d_splat_m256d(&a).to_array();
107 assert_eq!(b, [0.0, 1.0, 0.0, 1.0]);
108 }
109
110 #[test]
111 fn test_load_m128_splat_m256() {
112 let a = m128::from_array([0.0, 1.0, 2.0, 3.0]);
113 let b = load_m128_splat_m256(&a).to_array();
114 assert_eq!(b, [0.0, 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 3.0]);
115 }
116
117 #[test]
118 fn test_load_f64_splat_m256d() {
119 let a = 1.0;
120 let b = load_f64_splat_m256d(&a).to_array();
121 assert_eq!(b, [1.0, 1.0, 1.0, 1.0]);
122 }
123
124 #[test]
125 fn test_load_f32_splat_m256() {
126 let a = 1.0;
127 let b = load_f32_splat_m256(&a).to_array();
128 assert_eq!(b, [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]);
129 }
130
131 #[test]
132 fn test_cast_to_m256_from_m256d() {
133 let a = load_f64_splat_m256d(&1.0);
134 assert_eq!(cast_to_m256_from_m256d(a).to_bits(), [0, 0x3FF0_0000, 0, 0x3FF0_0000, 0, 0x3FF0_0000, 0, 0x3FF0_0000]);
135 }
136
137 #[test]
138 fn test_cast_to_m256i_from_m256d() {
139 let a = load_f64_splat_m256d(&1.0);
140 let b: [u64; 4] = cast_to_m256i_from_m256d(a).into();
141 assert_eq!(b, [0x3FF00000_00000000_u64; 4]);
142 }
143
144 #[test]
145 fn test_cast_to_m256d_from_m256i() {
146 let a = m256i::from([1.0_f64.to_bits(); 4]);
147 let b = cast_to_m256d_from_m256i(a).to_array();
148 assert_eq!(b, [1.0; 4]);
149 }
150
151 #[test]
152 fn test_cast_to_m256_from_m256i() {
153 let a = m256i::from([1.0_f32.to_bits(); 8]);
154 let b = cast_to_m256_from_m256i(a).to_array();
155 assert_eq!(b, [1.0; 8]);
156 }
157
158 #[test]
159 fn test_cast_to_m128_from_m256() {
160 let a = m256::from([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
161 let b = cast_to_m128_from_m256(a).to_array();
162 assert_eq!(b, [1.0, 2.0, 3.0, 4.0]);
163 }
164
165 #[test]
166 fn test_cast_to_m128d_from_m256d() {
167 let a = m256d::from([1.0, 2.0, 3.0, 4.0]);
168 let b = cast_to_m128d_from_m256d(a).to_array();
169 assert_eq!(b, [1.0, 2.0]);
170 }
171
172 #[test]
173 fn test_cast_to_m128i_from_m256i() {
174 let a = m256i::from([1, 2, 3, 4, 5, 6, 7, 8]);
175 let b: [i32; 4] = cast_to_m128i_from_m256i(a).into();
176 assert_eq!(b, [1, 2, 3, 4]);
177 }
178
179 #[test]
180 fn test_ceil_m256d() {
181 let a = m256d::from([1.1, 2.5, 3.8, 5.0]);
182 let b = ceil_m256d(a).to_array();
183 assert_eq!(b, [2.0, 3.0, 4.0, 5.0]);
184 }
185
186 #[test]
187 fn test_ceil_m256() {
188 let a = m256::from([1.1, 2.5, 3.8, 5.0, -0.5, -1.1, -2.7, -3.0]);
189 let b = ceil_m256(a).to_array();
190 assert_eq!(b, [2.0, 3.0, 4.0, 5.0, 0.0, -1.0, -2.0, -3.0]);
191 }
192
193 #[test]
194 fn test_cmp_op_mask_m128() {
195 let a = m128::from_array([2.0, 0.0, -2.0, 0.0]);
196 let b = m128::from_array([1.0, 1.0, -1.0, -1.0]);
197 let c = cmp_op_mask_m128::<{ cmp_op!(GreaterThanOrdered) }>(a, b).to_bits();
198 assert_eq!(c, [u32::MAX, 0, 0, u32::MAX]);
199 }
200
201 #[test]
202 fn test_cmp_op_mask_m128_s() {
203 let a = m128::from_array([2.0, 0.0, -2.0, 0.0]);
204 let b = m128::from_array([1.0, 1.0, -1.0, -1.0]);
205 let c = cmp_op_mask_m128_s::<{ cmp_op!(GreaterThanOrdered) }>(a, b).to_bits();
206 assert_eq!(c, [u32::MAX, 0, (-2_f32).to_bits(), 0]);
207 }
208
209 #[test]
210 fn test_cmp_op_mask_m256() {
211 let a = m256::from_array([1.0, 5.0, 0.0, 7.0, 5.0, 6.0, 7.0, -20.0]);
212 let b = m256::from_array([2.0, 1.0, 3.0, 4.0, 1.0, -2.0, -3.0, -4.0]);
213 let c = cmp_op_mask_m256::<{ cmp_op!(LessThanOrdered) }>(a, b).to_bits();
214 assert_eq!(c, [u32::MAX, 0, u32::MAX, 0, 0, 0, 0, u32::MAX]);
215 }
216
217 #[test]
218 fn test_cmp_op_mask_m128d() {
219 let a = m128d::from_array([1.0, 0.0]);
220 let b = m128d::from_array([1.0, 1.0]);
221 let c = cmp_op_mask_m128d::<{ cmp_op!(EqualOrdered) }>(a, b).to_bits();
222 assert_eq!(c, [u64::MAX, 0]);
223 }
224
225 #[test]
226 fn test_cmp_op_mask_m128d_s() {
227 let a = m128d::from_array([1.0, 7.0]);
228 let b = m128d::from_array([1.0, 1.0]);
229 let c = cmp_op_mask_m128d_s::<{ cmp_op!(EqualOrdered) }>(a, b).to_bits();
230 assert_eq!(c, [u64::MAX, 7_f64.to_bits()]);
231 }
232
233 #[test]
234 fn test_cmp_op_mask_m256d() {
235 let a = m256d::from_array([1.0, 5.0, 0.0, 7.0]);
236 let b = m256d::from_array([2.0, 1.0, 3.0, 4.0]);
237 let c = cmp_op_mask_m256d::<{ cmp_op!(LessThanOrdered) }>(a, b).to_bits();
238 assert_eq!(c, [u64::MAX, 0, u64::MAX, 0]);
239 }
240
241 #[test]
242 fn test_convert_to_m256d_from_i32_m128i() {
243 let a = m128i::from([4, 5, 6, 7]);
244 let b = convert_to_m256d_from_i32_m128i(a).to_array();
245 assert_eq!(b, [4.0, 5.0, 6.0, 7.0]);
246 }
247
248 #[test]
249 fn test_convert_to_m256_from_i32_m256i() {
250 let a = m256i::from([4, 5, 6, 7, 8, -9, 1, 0]);
251 let b = convert_to_m256_from_i32_m256i(a).to_array();
252 assert_eq!(b, [4.0, 5.0, 6.0, 7.0, 8.0, -9.0, 1.0, 0.0]);
253 }
254
255 #[test]
256 fn test_convert_to_i32_m128i_from_m256d() {
257 let a = m256d::from([4.0, 5.0, 6.0, 7.0]);
258 let b: [i32; 4] = convert_to_i32_m128i_from_m256d(a).into();
259 assert_eq!(b, [4, 5, 6, 7]);
260 }
261
262 #[test]
263 fn test_convert_to_m128_from_m256d() {
264 let a = m256d::from([4.0, 5.0, 6.0, 7.0]);
265 let b = convert_to_m128_from_m256d(a).to_array();
266 assert_eq!(b, [4.0, 5.0, 6.0, 7.0]);
267 }
268
269 #[test]
270 fn test_convert_to_i32_m256i_from_m256() {
271 let a = m256::from([4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0]);
272 let b: [i32; 8] = convert_to_i32_m256i_from_m256(a).into();
273 assert_eq!(b, [4, 5, 6, 7, 8, 9, 10, 11]);
274 }
275
276 #[test]
277 fn test_convert_to_m256d_from_m128() {
278 let a = m128::from([4.0, 5.0, 6.0, 7.0]);
279 let b = convert_to_m256d_from_m128(a).to_array();
280 assert_eq!(b, [4.0, 5.0, 6.0, 7.0]);
281 }
282
283 #[test]
284 fn test_convert_to_f64_from_m256d_s() {
285 let a = m256d::from([4.0, 5.0, 6.0, 7.0]);
286 let b = convert_to_f64_from_m256d_s(a);
287 assert_eq!(b, 4.0);
288 }
289
290 #[test]
291 fn test_convert_to_i32_from_m256i_s() {
292 let a = m256i::from([4, 5, 6, 7, 8, 9, 10, 11]);
293 let b = convert_to_i32_from_m256i_s(a);
294 assert_eq!(b, 4);
295 }
296
297 #[test]
298 fn test_convert_to_f32_from_m256_s() {
299 let a = m256::from([4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0]);
300 let b = convert_to_f32_from_m256_s(a);
301 assert_eq!(b, 4.0);
302 }
303
304 #[test]
305 fn test_div_m256d() {
306 let a = m256d::from([4.0, 5.0, 6.0, 7.0]);
307 let b = m256d::from([2.0, 2.0, 3.0, 7.0]);
308 let c = div_m256d(a, b).to_array();
309 assert_eq!(c, [2.0, 2.5, 2.0, 1.0]);
310 }
311
312 #[test]
313 fn test_div_m256() {
314 let a = m256::from_array([4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0]);
315 let b = m256::from_array([2.0, 2.0, 3.0, 7.0, 2.0, 3.0, 4.0, 11.0]);
316 let c = div_m256(a, b).to_array();
317 assert_eq!(c, [2.0, 2.5, 2.0, 1.0, 4.0, 3.0, 2.5, 1.0]);
318 }
319
320 #[test]
321 fn test_dot_product_m256() {
322 let a = m256::from_array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
323 let b = m256::from_array([9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]);
324 let c = dot_product_m256::<0b1111_1111>(a, b).to_array();
325 assert_eq!(c, [110.0, 110.0, 110.0, 110.0, 382.0, 382.0, 382.0, 382.0]);
326 }
327
328 #[test]
329 fn test_extract_i32_from_m256i() {
330 let a = m256i::from([9, 10, 11, 12, 13, 14, 15, 16]);
331 assert_eq!(extract_i32_from_m256i::<3>(a), 12);
332 }
333
334 #[test]
335 #[cfg(target_arch = "x86_64")]
336 fn test_extract_i64_from_m256i() {
337 let a = m256i::from([9_i64, 10, 11, 12]);
338 assert_eq!(extract_i64_from_m256i::<1>(a), 10_i64);
339 }
340
341 #[test]
342 fn test_extract_m128d_from_m256d() {
343 let a = m256d::from([13.0, 14.0, 15.0, 16.0]);
344 let b = m128d::from([15.0, 16.0]).to_array();
345 let c = extract_m128d_from_m256d::<1>(a).to_array();
346 assert_eq!(b, c);
347 }
348
349 #[test]
350 fn test_extract_m128_from_m256() {
351 let a = m256::from([9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]);
352 let b = m128::from([13.0, 14.0, 15.0, 16.0]).to_array();
353 let c = extract_m128_from_m256::<1>(a).to_array();
354 assert_eq!(b, c);
355 }
356
357 #[test]
358 fn test_extract_m128i_from_m256i() {
359 let a = m256i::from([9, 10, 11, 12, 13, 14, 15, 16]);
360 let b: [i32; 4] = m128i::from([13, 14, 15, 16]).into();
361 let c: [i32; 4] = extract_m128i_from_m256i::<1>(a).into();
362 assert_eq!(b, c);
363 }
364
365 #[test]
366 fn test_floor_m256d() {
367 let a = m256d::from([1.1, 2.5, 3.8, 5.0]);
368 let b = floor_m256d(a).to_array();
369 assert_eq!(b, [1.0, 2.0, 3.0, 5.0]);
370 }
371
372 #[test]
373 fn test_floor_m256() {
374 let a = m256::from([1.1, 2.5, 3.8, 5.0, -0.5, -1.1, -2.7, -3.0]);
375 let b = floor_m256(a).to_array();
376 assert_eq!(b, [1.0, 2.0, 3.0, 5.0, -1.0, -2.0, -3.0, -3.0]);
377 }
378
379 #[test]
380 fn test_add_horizontal_m256d() {
381 let a = m256d::from([1.0, 2.0, 3.0, 4.0]);
382 let b = m256d::from([1.0, 3.0, 5.0, 7.0]);
383 let c = add_horizontal_m256d(a, b).to_array();
384 assert_eq!(c, [3.0, 4.0, 7.0, 12.0]);
385 }
386
387 #[test]
388 fn test_add_horizontal_m256() {
389 let a = m256::from([8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0]);
390 let b = m256::from([0.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0]);
391 let c = add_horizontal_m256(a, b).to_array();
392 assert_eq!(c, [15.0, 11.0, 2.0, 12.0, 7.0, 3.0, 48.0, 192.0]);
393 }
394
395 #[test]
396 fn test_sub_horizontal_m256d() {
397 let a = m256d::from([1.0, 2.0, 3.0, 4.0]);
398 let b = m256d::from([1.0, 3.0, 5.0, 70.0]);
399 let c = sub_horizontal_m256d(a, b).to_array();
400 assert_eq!(c, [-1.0, -2.0, -1.0, -65.0]);
401 }
402
403 #[test]
404 fn test_sub_horizontal_m256() {
405 let a = m256::from([8.0, 17.0, 6.0, 5.0, 4.0, 23.0, 2.0, 1.0]);
406 let b = m256::from([0.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0]);
407 let c = sub_horizontal_m256(a, b).to_array();
408 assert_eq!(c, [-9.0, 1.0, -2.0, -4.0, -19.0, 1.0, -16.0, -64.0]);
409 }
410
411 #[test]
412 fn test_insert_i8_to_m256i() {
413 let a = m256i::from([0_i8; 32]);
414 let b: [i8; 32] = insert_i8_to_m256i::<3>(a, 5).into();
415 let c: [i8; 32] = m256i::from([0_i8, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).into();
416 assert_eq!(b, c);
417 }
418
419 #[test]
420 fn test_insert_i16_to_m256i() {
421 let a = m256i::from([0_i16; 16]);
422 let b: [i16; 16] = insert_i16_to_m256i::<3>(a, 5).into();
423 let c: [i16; 16] = m256i::from([0_i16, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).into();
424 assert_eq!(b, c);
425 }
426
427 #[test]
428 fn test_insert_i32_to_m256i() {
429 let a = m256i::from([0_i32; 8]);
430 let b: [i32; 8] = insert_i32_to_m256i::<3>(a, 5).into();
431 let c: [i32; 8] = m256i::from([0, 0, 0, 5, 0, 0, 0, 0]).into();
432 assert_eq!(b, c);
433 }
434
435 #[test]
436 #[cfg(target_arch = "x86_64")]
437 fn test_insert_i64_to_m256i() {
438 let a = m256i::from([0_i64; 4]);
439 let b: [i64; 4] = insert_i64_to_m256i::<3>(a, 5).into();
440 let c: [i64; 4] = m256i::from([0, 0, 0, 5_i64]).into();
441 assert_eq!(b, c);
442 }
443
444 #[test]
445 fn test_insert_m128d_to_m256d() {
446 let a = m256d::from([0.0; 4]);
447 let b: [f64; 4] = insert_m128d_to_m256d::<1>(a, m128d::from([3.0, 4.0])).to_array();
448 assert_eq!(b, [0.0, 0.0, 3.0, 4.0]);
449 }
450
451 #[test]
452 fn test_insert_m128_to_m256() {
453 let a = m256::from([0.0; 8]);
454 let b: [f32; 8] = insert_m128_to_m256::<1>(a, m128::from([1.0, 2.0, 3.0, 4.0])).to_array();
455 assert_eq!(b, [0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0]);
456 }
457
458 #[test]
459 fn test_insert_m128i_to_m256i_slow_avx() {
460 let a = m256i::from([0_i32; 8]);
461 let b: [i32; 8] = insert_m128i_to_m256i_slow_avx::<1>(a, m128i::from([1, 2, 3, 4])).into();
462 assert_eq!(b, [0, 0, 0, 0, 1, 2, 3, 4]);
463 }
464
465 #[test]
466 fn test_load_m256d() {
467 let a = m256d::from([8.0, 17.0, 6.0, 5.0]);
468 let b = load_m256d(&a);
469 assert_eq!(a.to_array(), b.to_array());
470 }
471
472 #[test]
473 fn test_load_m256() {
474 let a = m256::from([8.0, 17.0, 6.0, 5.0, 4.0, 23.0, 2.0, 1.0]);
475 let b = load_m256(&a);
476 assert_eq!(a.to_array(), b.to_array());
477 }
478
479 #[test]
480 fn test_load_m256i() {
481 let a = m256i::from([8, 17, 6, 5, 4, 23, 2, 1]);
482 let b = load_m256i(&a);
483 assert_eq!(<[i32; 8]>::from(a), <[i32; 8]>::from(b));
484 }
485
486 #[test]
487 fn test_load_unaligned_m256d() {
488 assert_eq!(load_unaligned_m256d(&[8.0, 17.0, 6.0, 5.0]).to_array(), [8.0, 17.0, 6.0, 5.0]);
489 }
490
491 #[test]
492 fn test_load_unaligned_m256() {
493 assert_eq!(load_unaligned_m256(&[8.0, 17.0, 6.0, 5.0, 1.0, 2.0, 3.0, 4.0]).to_array(), [8.0, 17.0, 6.0, 5.0, 1.0, 2.0, 3.0, 4.0]);
494 }
495
496 #[test]
497 fn test_load_unaligned_m256i() {
498 assert_eq!(<[i8; 32]>::from(load_unaligned_m256i(&[7_i8; 32])), [7_i8; 32]);
499 }
500
501 #[test]
502 fn test_load_unaligned_hi_lo_m256d() {
503 assert_eq!(load_unaligned_hi_lo_m256d(&[3.0, 4.0], &[1.0, 2.0]).to_array(), [1.0, 2.0, 3.0, 4.0]);
504 }
505
506 #[test]
507 fn test_load_unaligned_hi_lo_m256() {
508 assert_eq!(load_unaligned_hi_lo_m256(&[5.0, 6.0, 7.0, 8.0], &[1.0, 2.0, 3.0, 4.0]).to_array(), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
509 }
510
511 #[test]
512 fn test_load_unaligned_hi_lo_m256i() {
513 assert_eq!(<[i8; 32]>::from(load_unaligned_hi_lo_m256i(&[7_i8; 16], &[9_i8; 16])), [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,]);
514 }
515
516 #[test]
517 fn test_load_masked_m128d() {
518 let a = m128d::from([8.0, 17.0]);
519 let b = load_masked_m128d(&a, m128i::from([0_i64, -1])).to_array();
520 assert_eq!(b, [0.0, 17.0]);
521 }
522
523 #[test]
524 fn test_load_masked_m256d() {
525 let a = m256d::from([8.0, 17.0, 16.0, 20.0]);
526 let b = load_masked_m256d(&a, m256i::from([0_i64, -1, -1, 0])).to_array();
527 assert_eq!(b, [0.0, 17.0, 16.0, 0.0]);
528 }
529
530 #[test]
531 fn test_load_masked_m128() {
532 let a = m128::from([8.0, 17.0, 16.0, 12.0]);
533 let b = load_masked_m128(&a, m128i::from([0, -1, -1, 0])).to_array();
534 assert_eq!(b, [0.0, 17.0, 16.0, 0.0]);
535 }
536
537 #[test]
538 fn test_load_masked_m256() {
539 let a = m256::from([8.0, 17.0, 16.0, 20.0, 80.0, 1.0, 2.0, 3.0]);
540 let b = load_masked_m256(&a, m256i::from([0, -1, -1, 0, -1, -1, 0, 0])).to_array();
541 assert_eq!(b, [0.0, 17.0, 16.0, 0.0, 80.0, 1.0, 0.0, 0.0]);
542 }
543
544 #[test]
545 fn test_store_masked_m128d() {
546 let mut a = m128d::default();
547 store_masked_m128d(&mut a, m128i::from([0_i64, -1]), m128d::from([8.0, 17.0]));
548 assert_eq!(a.to_array(), [0.0, 17.0]);
549 }
550
551 #[test]
552 fn test_store_masked_m256d() {
553 let mut a = m256d::default();
554 store_masked_m256d(&mut a, m256i::from([0_i64, -1, -1, 0]), m256d::from([8.0, 17.0, 16.0, 20.0]));
555 assert_eq!(a.to_array(), [0.0, 17.0, 16.0, 0.0]);
556 }
557
558 #[test]
559 fn test_store_masked_m128() {
560 let mut a = m128::default();
561 store_masked_m128(&mut a, m128i::from([0, -1, -1, 0]), m128::from([8.0, 17.0, 16.0, 20.0]));
562 assert_eq!(a.to_array(), [0.0, 17.0, 16.0, 0.0]);
563 }
564
565 #[test]
566 fn test_store_masked_m256() {
567 let mut a = m256::default();
568 store_masked_m256(&mut a, m256i::from([0, -1, -1, 0, -1, -1, 0, 0]), m256::from([8.0, 17.0, 16.0, 20.0, 80.0, 1.0, 2.0, 3.0]));
569 assert_eq!(a.to_array(), [0.0, 17.0, 16.0, 0.0, 80.0, 1.0, 0.0, 0.0]);
570 }
571
572 #[test]
573 fn test_max_m256d() {
574 let a = m256d::from_array([1.0, 12.0, -1.0, 3.0]);
575 let b = m256d::from_array([5.0, 6.0, -0.5, 2.2]);
576 let c = max_m256d(a, b).to_array();
577 assert_eq!(c, [5.0, 12.0, -0.5, 3.0]);
578 }
579
580 #[test]
581 fn test_max_m256() {
582 let a = m256::from_array([1.0, 12.0, -1.0, 3.0, 10.0, 0.0, 1.0, 2.0]);
583 let b = m256::from_array([5.0, 6.0, -0.5, 2.2, 5.0, 6.0, 7.0, 8.0]);
584 let c = max_m256(a, b).to_array();
585 assert_eq!(c, [5.0, 12.0, -0.5, 3.0, 10.0, 6.0, 7.0, 8.0]);
586 }
587
588 #[test]
589 fn test_min_m256d() {
590 let a = m256d::from_array([1.0, 12.0, -1.0, 3.0]);
591 let b = m256d::from_array([5.0, 6.0, -0.5, 2.2]);
592 let c = min_m256d(a, b).to_array();
593 assert_eq!(c, [1.0, 6.0, -1.0, 2.2]);
594 }
595
596 #[test]
597 fn test_min_m256() {
598 let a = m256::from_array([1.0, 12.0, -1.0, 3.0, 10.0, 0.0, 1.0, 2.0]);
599 let b = m256::from_array([5.0, 6.0, -0.5, 2.2, 5.0, 6.0, 7.0, 8.0]);
600 let c = min_m256(a, b).to_array();
601 assert_eq!(c, [1.0, 6.0, -1.0, 2.2, 5.0, 0.0, 1.0, 2.0]);
602 }
603
604 #[test]
605 fn test_duplicate_odd_lanes_m256d() {
606 let a = m256d::from_array([1.0, 12.0, -1.0, 3.0]);
607 let c = duplicate_odd_lanes_m256d(a).to_array();
608 assert_eq!(c, [1.0, 1.0, -1.0, -1.0]);
609 }
610
611 #[test]
612 fn test_duplicate_even_lanes_m256() {
613 let a = m256::from_array([1.0, 12.0, -1.0, 3.0, 0.0, 7.0, 2.0, 50.0]);
614 let c = duplicate_even_lanes_m256(a).to_array();
615 assert_eq!(c, [12.0, 12.0, 3.0, 3.0, 7.0, 7.0, 50.0, 50.0]);
616 }
617
618 #[test]
619 fn test_duplicate_odd_lanes_m256() {
620 let a = m256::from_array([1.0, 12.0, -1.0, 3.0, 0.0, 7.0, 2.0, 50.0]);
621 let c = duplicate_odd_lanes_m256(a).to_array();
622 assert_eq!(c, [1.0, 1.0, -1.0, -1.0, 0.0, 0.0, 2.0, 2.0]);
623 }
624
625 #[test]
626 fn test_move_mask_m256d() {
627 assert_eq!(0b0100, move_mask_m256d(m256d::from([1.0, 12.0, -1.0, 3.0])));
628 }
629
630 #[test]
631 fn test_move_mask_m256() {
632 assert_eq!(0b00110100, move_mask_m256(m256::from([1.0, 12.0, -1.0, 3.0, -1.0, -2.0, 3.0, 4.0])));
633 }
634
635 #[test]
636 fn test_mul_m256d() {
637 let a = m256d::from_array([1.0, 2.0, 3.0, 4.0]);
638 let b = m256d::from_array([5.0, 6.0, 7.0, 8.5]);
639 let c = mul_m256d(a, b).to_array();
640 assert_eq!(c, [5.0, 12.0, 21.0, 34.0]);
641 }
642
643 #[test]
644 fn test_mul_m256() {
645 let a = m256::from_array([1.0, 2.0, 3.0, 4.0, 20.0, 30.0, 40.0, 50.0]);
646 let b = m256::from_array([5.0, 6.0, 7.0, 8.5, 90.0, 100.0, 110.0, 51.0]);
647 let c = mul_m256(a, b).to_array();
648 assert_eq!(c, [5.0, 12.0, 21.0, 34.0, 1800.0, 3000.0, 4400.0, 2550.0]);
649 }
650
651 #[test]
652 fn test_bitor_m256d() {
653 let a = m256d::from_array([1.0, 1.0, 0.0, 0.0]);
654 let b = m256d::from_array([1.0, 0.0, 1.0, 0.0]);
655 let c = bitor_m256d(a, b).to_array();
656 assert_eq!(c, [1.0, 1.0, 1.0, 0.0]);
657 }
658
659 #[test]
660 fn test_bitor_m256() {
661 let a = m256::from_array([1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0]);
662 let b = m256::from_array([1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0]);
663 let c = bitor_m256(a, b).to_array();
664 assert_eq!(c, [1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0]);
665 }
666
667 #[test]
668 fn test_permute_m128d() {
669 let a = m128d::from_array([1.0, 2.0]);
670 //
671 let b = permute_m128d::<0b_0_1>(a).to_array();
672 assert_eq!(b, [2.0, 1.0]);
673 }
674
675 #[test]
676 fn test_permute_m256d() {
677 let a = m256d::from_array([1.0, 2.0, 3.0, 4.0]);
678 //
679 let b = permute_m256d::<0b_0_1_0_1>(a).to_array();
680 assert_eq!(b, [2.0, 1.0, 4.0, 3.0]);
681 }
682
683 #[test]
684 fn test_permute_m128() {
685 let a = m128::from_array([1.0, 2.0, 3.0, 4.0]);
686 //
687 let b = permute_m128::<0b_00_00_00_00>(a).to_array();
688 assert_eq!(b, [1.0, 1.0, 1.0, 1.0]);
689 //
690 let b = permute_m128::<0b_11_00_01_00>(a).to_array();
691 assert_eq!(b, [1.0, 2.0, 1.0, 4.0]);
692 //
693 let b = permute_m128::<0b_10_10_00_00>(a).to_array();
694 assert_eq!(b, [1.0, 1.0, 3.0, 3.0]);
695 }
696
697 #[test]
698 fn test_permute_m256() {
699 let a = m256::from_array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
700 //
701 let b = permute_m256::<0b_00_10_01_11>(a).to_array();
702 assert_eq!(b, [4.0, 2.0, 3.0, 1.0, 8.0, 6.0, 7.0, 5.0]);
703 }
704
705 #[test]
706 fn test_permute2z_m256d() {
707 let a = m256d::from_array([1.0, 2.0, 3.0, 4.0]);
708 let b = m256d::from_array([5.0, 6.0, 7.0, 8.0]);
709 //
710 let c = permute2z_m256d::<0b1000_0010>(a, b).to_array();
711 assert_eq!(c, [5.0, 6.0, 0.0, 0.0]);
712 //
713 let c = permute2z_m256d::<0b0001_1000>(a, b).to_array();
714 assert_eq!(c, [0.0, 0.0, 3.0, 4.0]);
715 }
716
717 #[test]
718 fn test_permute2z_m256() {
719 let a = m256::from_array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
720 let b = m256::from_array([9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]);
721 //
722 let c = permute2z_m256::<0b1000_0010>(a, b).to_array();
723 assert_eq!(c, [9.0, 10.0, 11.0, 12.0, 0.0, 0.0, 0.0, 0.0]);
724 //
725 let c = permute2z_m256::<0b0001_1000>(a, b).to_array();
726 assert_eq!(c, [0.0, 0.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0]);
727 }
728
729 #[test]
730 fn test_permute2z_m256i() {
731 let a = m256i::from([1, 2, 3, 4, 5, 6, 7, 8]);
732 let b = m256i::from([9, 10, 11, 12, 13, 14, 15, 16]);
733 //
734 let c: [i32; 8] = permute2z_m256i::<0b1000_0010>(a, b).into();
735 assert_eq!(c, [9, 10, 11, 12, 0, 0, 0, 0]);
736 //
737 let c: [i32; 8] = permute2z_m256i::<0b0001_1000>(a, b).into();
738 assert_eq!(c, [0, 0, 0, 0, 5, 6, 7, 8]);
739 }
740
741 #[test]
742 fn test_shuffle_av_f64_all_m128d() {
743 let a = m128d::from_array([2.0, 3.0]);
744 let v = m128i::from([1_i64 << 1, 0 << 1]);
745 let c = shuffle_av_f64_all_m128d(a, v).to_array();
746 assert_eq!(c, [3.0, 2.0]);
747 }
748
749 #[test]
750 fn test_shuffle_av_f64_half_m256d() {
751 let a = m256d::from_array([2.0, 3.0, 7.0, 8.0]);
752 let v = m256i::from([1_i64 << 1, 0 << 1, 1 << 1, 1 << 1]);
753 let c = shuffle_av_f64_half_m256d(a, v).to_array();
754 assert_eq!(c, [3.0, 2.0, 8.0, 8.0]);
755 }
756
757 #[test]
758 fn test_shuffle_av_f32_all_m128() {
759 let a = m128::from_array([5.0, 6.0, 7.0, 8.0]);
760 let v = m128i::from([0, 2, 3, 1]);
761 let c = shuffle_av_f32_all_m128(a, v).to_array();
762 assert_eq!(c, [5.0, 7.0, 8.0, 6.0]);
763 }
764
765 #[test]
766 fn test_shuffle_av_f32_half_m256() {
767 let a = m256::from_array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]);
768 let v = m256i::from([0, 2, 3, 1, 0, 3, 2, 2]);
769 let c = shuffle_av_f32_half_m256(a, v).to_array();
770 assert_eq!(c, [0.0, 2.0, 3.0, 1.0, 4.0, 7.0, 6.0, 6.0]);
771 }
772
773 #[test]
774 fn test_reciprocal_m256() {
775 let a = m256::from_array([1.0, 2.0, 4.0, 8.0, 0.5, 2.0, 8.0, 16.0]);
776 let b = reciprocal_m256(a).to_array();
777 let expected = [1.0, 0.5, 0.25, 0.125, 2.0, 0.5, 0.125, 0.0625];
778 for i in 0..4 {
779 assert!((b[i] - expected[i]).abs() < 0.001);
780 }
781 }
782
783 #[test]
784 fn test_round_m256d() {
785 let a = m256d::from_array([-0.1, 1.6, 2.5, 3.1]);
786 //
787 assert_eq!(round_m256d::<{ round_op!(Nearest) }>(a).to_array(), [0.0, 2.0, 2.0, 3.0]);
788 //
789 assert_eq!(round_m256d::<{ round_op!(NegInf) }>(a).to_array(), [-1.0, 1.0, 2.0, 3.0]);
790 //
791 assert_eq!(round_m256d::<{ round_op!(PosInf) }>(a).to_array(), [0.0, 2.0, 3.0, 4.0]);
792 //
793 assert_eq!(round_m256d::<{ round_op!(Zero) }>(a).to_array(), [0.0, 1.0, 2.0, 3.0]);
794 }
795
796 #[test]
797 fn test_round_m256() {
798 let a = m256::from_array([-0.1, 1.6, 3.3, 4.5, 5.1, 6.5, 7.2, 8.0]);
799 //
800 assert_eq!(round_m256::<{ round_op!(Nearest) }>(a).to_array(), [0.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
801 //
802 assert_eq!(round_m256::<{ round_op!(NegInf) }>(a).to_array(), [-1.0, 1.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
803 //
804 assert_eq!(round_m256::<{ round_op!(PosInf) }>(a).to_array(), [0.0, 2.0, 4.0, 5.0, 6.0, 7.0, 8.0, 8.0]);
805 //
806 assert_eq!(round_m256::<{ round_op!(Zero) }>(a).to_array(), [0.0, 1.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
807 }
808
809 #[test]
810 fn test_reciprocal_sqrt_m256() {
811 let a = m256::from_array([16.0, 9.0, 4.0, 25.0, 16.0, 9.0, 4.0, 25.0]);
812 let b = reciprocal_sqrt_m256(a).to_array();
813 let expected = [0.25, 0.33333, 0.5, 0.2, 0.25, 0.33333, 0.5, 0.2];
814 for i in 0..8 {
815 assert!((b[i] - expected[i]).abs() < 0.001);
816 }
817 }
818
819 #[test]
820 fn test_set_i8_m256i() {
821 let a: [i8; 32] = set_i8_m256i(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31).into();
822 assert_eq!(a, [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]);
823 }
824
825 #[test]
826 fn test_set_i16_m256i() {
827 let a: [i16; 16] = set_i16_m256i(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).into();
828 assert_eq!(a, [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]);
829 }
830
831 #[test]
832 fn test_set_i32_m256i() {
833 let a: [i32; 8] = set_i32_m256i(0, 1, 2, 3, 4, 5, 6, 7).into();
834 assert_eq!(a, [7, 6, 5, 4, 3, 2, 1, 0]);
835 }
836
837 #[test]
838 #[cfg(target_arch = "x86_64")]
839 fn test_set_i64_m256i() {
840 let a: [i64; 4] = set_i64_m256i(0, 1, 2, 3).into();
841 assert_eq!(a, [3, 2, 1, 0]);
842 }
843
844 #[test]
845 fn test_set_m128_m256() {
846 let a = set_m128_m256(m128::from([4.0, 5.0, 6.0, 7.0]), m128::from([0.0, 1.0, 2.0, 3.0])).to_array();
847 assert_eq!(a, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]);
848 }
849
850 #[test]
851 fn test_set_m128d_m256d() {
852 let a = set_m128d_m256d(m128d::from([2.0, 3.0]), m128d::from([0.0, 1.0])).to_array();
853 assert_eq!(a, [0.0, 1.0, 2.0, 3.0]);
854 }
855
856 #[test]
857 fn test_set_m128i_m256i() {
858 let a: [i64; 4] = set_m128i_m256i(set_i64_m128i(3_i64, 2), set_i64_m128i(1_i64, 0)).into();
859 assert_eq!(a, [0_i64, 1, 2, 3]);
860 }
861
862 #[test]
863 fn test_set_m256d() {
864 let a = set_m256d(0.0, 1.0, 2.0, 3.0).to_array();
865 assert_eq!(a, [3.0, 2.0, 1.0, 0.0]);
866 }
867
868 #[test]
869 fn test_set_m256() {
870 let a = set_m256(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0).to_array();
871 assert_eq!(a, [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0]);
872 }
873
874 #[test]
875 fn test_set_splat_i8_m256i() {
876 let a: [i8; 32] = set_splat_i8_m256i(56).into();
877 assert_eq!(a, [56_i8; 32]);
878 }
879
880 #[test]
881 fn test_set_splat_i16_m256i() {
882 let a: [i16; 16] = set_splat_i16_m256i(56).into();
883 assert_eq!(a, [56_i16; 16]);
884 }
885
886 #[test]
887 fn test_set_splat_i32_m256i() {
888 let a: [i32; 8] = set_splat_i32_m256i(56).into();
889 assert_eq!(a, [56_i32; 8]);
890 }
891
892 #[test]
893 #[cfg(target_arch = "x86_64")]
894 fn test_set_splat_i64_m256i() {
895 let a: [i64; 4] = set_splat_i64_m256i(56).into();
896 assert_eq!(a, [56_i64; 4]);
897 }
898
899 #[test]
900 fn test_set_splat_m256d() {
901 let a = set_splat_m256d(56.0).to_array();
902 assert_eq!(a, [56.0; 4]);
903 }
904
905 #[test]
906 fn test_set_splat_m256() {
907 let a = set_splat_m256(56.0).to_array();
908 assert_eq!(a, [56.0; 8]);
909 }
910
911 #[test]
912 fn test_set_reversed_i8_m256i() {
913 let a: [i8; 32] = set_reversed_i8_m256i(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31).into();
914 assert_eq!(a, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]);
915 }
916
917 #[test]
918 fn test_set_reversed_i16_m256i() {
919 let a: [i16; 16] = set_reversed_i16_m256i(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).into();
920 assert_eq!(a, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
921 }
922
923 #[test]
924 fn test_set_reversed_i32_m256i() {
925 let a: [i32; 8] = set_reversed_i32_m256i(0, 1, 2, 3, 4, 5, 6, 7).into();
926 assert_eq!(a, [0, 1, 2, 3, 4, 5, 6, 7]);
927 }
928
929 #[test]
930 #[cfg(target_arch = "x86_64")]
931 fn test_set_reversed_i64_m256i() {
932 let a: [i64; 4] = set_reversed_i64_m256i(0, 1, 2, 3).into();
933 assert_eq!(a, [0, 1, 2, 3]);
934 }
935
936 #[test]
937 fn test_set_reversed_m128_m256() {
938 let a = set_reversed_m128_m256(set_reversed_m128(7.0, 6.0, 5.0, 4.0), set_reversed_m128(3.0, 2.0, 1.0, 0.0)).to_array();
939 assert_eq!(a, [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0]);
940 }
941
942 #[test]
943 fn test_set_reversed_m128d_m256d() {
944 let a = set_reversed_m128d_m256d(set_reversed_m128d(3.0, 2.0), set_reversed_m128d(1.0, 0.0)).to_array();
945 assert_eq!(a, [3.0, 2.0, 1.0, 0.0]);
946 }
947
948 #[test]
949 fn test_set_reversed_m128i_m256i() {
950 let a: [i64; 4] = set_reversed_m128i_m256i(m128i::from([0_i64, 1]), m128i::from([2_i64, 3])).into();
951 assert_eq!(a, [0_i64, 1, 2, 3]);
952 }
953
954 #[test]
955 fn test_set_reversed_m256d() {
956 let a = set_reversed_m256d(0.0, 1.0, 2.0, 3.0).to_array();
957 assert_eq!(a, [0.0, 1.0, 2.0, 3.0]);
958 }
959
960 #[test]
961 fn test_set_reversed_m256() {
962 let a = set_reversed_m256(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0).to_array();
963 assert_eq!(a, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]);
964 }
965
966 #[test]
967 fn test_zeroed_m256d() {
968 let a = zeroed_m256d().to_array();
969 assert_eq!(a, [0.0; 4]);
970 }
971
972 #[test]
973 fn test_zeroed_m256() {
974 let a = zeroed_m256().to_array();
975 assert_eq!(a, [0.0; 8]);
976 }
977
978 #[test]
979 fn test_zeroed_m256i() {
980 let a: [i32; 8] = zeroed_m256i().into();
981 assert_eq!(a, [0; 8]);
982 }
983
984 #[test]
985 fn test_shuffle_m256d() {
986 let a = m256d::from_array([1.0, 2.0, 3.0, 4.0]);
987 let b = m256d::from_array([5.0, 6.0, 7.0, 8.0]);
988 //
989 let c = shuffle_m256d::<0b_0_0_0_0>(a, b).to_array();
990 assert_eq!(c, [1.0, 5.0, 3.0, 7.0]);
991 //
992 let c = shuffle_m256d::<0b_0_0_0_1>(a, b).to_array();
993 assert_eq!(c, [2.0, 5.0, 3.0, 7.0]);
994 //
995 let c = shuffle_m256d::<0b_0_0_1_0>(a, b).to_array();
996 assert_eq!(c, [1.0, 6.0, 3.0, 7.0]);
997 //
998 let c = shuffle_m256d::<0b_0_0_1_1>(a, b).to_array();
999 assert_eq!(c, [2.0, 6.0, 3.0, 7.0]);
1000 //
1001 let c = shuffle_m256d::<0b_1_0_0_1>(a, b).to_array();
1002 assert_eq!(c, [2.0, 5.0, 3.0, 8.0]);
1003 //
1004 let c = shuffle_m256d::<0b_0_1_0_1>(a, b).to_array();
1005 assert_eq!(c, [2.0, 5.0, 4.0, 7.0]);
1006 //
1007 let c = shuffle_m256d::<0b_1_1_1_1>(a, b).to_array();
1008 assert_eq!(c, [2.0, 6.0, 4.0, 8.0]);
1009 }
1010
1011 #[test]
1012 fn test_shuffle_m256() {
1013 let a = m256::from_array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
1014 let b = m256::from_array([9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]);
1015 //
1016 let c = shuffle_m256::<0b_00_10_11_01>(a, b).to_array();
1017 assert_eq!(c, [2.0, 4.0, 11.0, 9.0, 6.0, 8.0, 15.0, 13.0]);
1018 }
1019
1020 #[test]
1021 fn test_sqrt_m256d() {
1022 let a = m256d::from_array([1.0, 4.0, 9.0, 16.0]);
1023 let b = sqrt_m256d(a).to_array();
1024 assert_eq!(b, [1.0, 2.0, 3.0, 4.0]);
1025 }
1026
1027 #[test]
1028 fn test_sqrt_m256() {
1029 let a = m256::from_array([1.0, 4.0, 9.0, 16.0, 25.0, 36.0, 0.0, 49.0]);
1030 let b = sqrt_m256(a).to_array();
1031 assert_eq!(b, [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0, 7.0]);
1032 }
1033
1034 #[test]
1035 fn test_store_m256d() {
1036 let mut addr = m256d::from([0.0; 4]);
1037 store_m256d(&mut addr, m256d::from([1.0, 2.0, 3.0, 4.0]));
1038 assert_eq!(addr.to_array(), [1.0, 2.0, 3.0, 4.0]);
1039 }
1040
1041 #[test]
1042 fn test_store_m256() {
1043 let mut addr = m256::from([0.0; 8]);
1044 store_m256(&mut addr, m256::from([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]));
1045 assert_eq!(addr.to_array(), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
1046 }
1047
1048 #[test]
1049 fn test_store_m256i() {
1050 let mut addr = m256i::from([0_i32; 8]);
1051 store_m256i(&mut addr, m256i::from([1, 2, 3, 4, 5, 6, 7, 8]));
1052 assert_eq!(<[i32; 8]>::from(addr), [1, 2, 3, 4, 5, 6, 7, 8]);
1053 }
1054
1055 #[test]
1056 fn test_store_unaligned_m256d() {
1057 let mut addr = [0.0; 4];
1058 store_unaligned_m256d(&mut addr, m256d::from([1.0, 2.0, 3.0, 4.0]));
1059 assert_eq!(addr, [1.0, 2.0, 3.0, 4.0]);
1060 }
1061
1062 #[test]
1063 fn test_store_unaligned_m256() {
1064 let mut addr = [0.0; 8];
1065 store_unaligned_m256(&mut addr, m256::from([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]));
1066 assert_eq!(addr, [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
1067 }
1068
1069 #[test]
1070 fn test_store_unaligned_m256i() {
1071 let mut addr = [0_i8; 32];
1072 store_unaligned_m256i(&mut addr, m256i::from([12_i8; 32]));
1073 assert_eq!(addr, [12_i8; 32]);
1074 }
1075
1076 #[test]
1077 fn test_store_unaligned_hi_lo_m256d() {
1078 let mut hi_addr = [0.0; 2];
1079 let mut lo_addr = [0.0; 2];
1080 store_unaligned_hi_lo_m256d(&mut hi_addr, &mut lo_addr, m256d::from([1.0, 2.0, 3.0, 4.0]));
1081 assert_eq!(hi_addr, [3.0, 4.0]);
1082 assert_eq!(lo_addr, [1.0, 2.0]);
1083 }
1084
1085 #[test]
1086 fn test_store_unaligned_hi_lo_m256() {
1087 let mut hi_addr = [0.0; 4];
1088 let mut lo_addr = [0.0; 4];
1089 store_unaligned_hi_lo_m256(&mut hi_addr, &mut lo_addr, m256::from([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]));
1090 assert_eq!(hi_addr, [5.0, 6.0, 7.0, 8.0]);
1091 assert_eq!(lo_addr, [1.0, 2.0, 3.0, 4.0]);
1092 }
1093
1094 #[test]
1095 fn test_store_unaligned_hi_lo_m256i() {
1096 let mut hi_addr = [0_i8; 16];
1097 let mut lo_addr = [0_i8; 16];
1098 store_unaligned_hi_lo_m256i(&mut hi_addr, &mut lo_addr, m256i::from([56_i8; 32]));
1099 assert_eq!(hi_addr, [56_i8; 16]);
1100 assert_eq!(lo_addr, [56_i8; 16]);
1101 }
1102
1103 #[test]
1104 fn test_sub_m256d() {
1105 let a = m256d::from_array([1.0, 2.0, 3.0, 4.0]);
1106 let b = m256d::from_array([5.0, 60.0, 712.0, 8.5]);
1107 let c = sub_m256d(a, b).to_array();
1108 assert_eq!(c, [-4.0, -58.0, -709.0, -4.5]);
1109 }
1110
1111 #[test]
1112 fn test_sub_m256() {
1113 let a = m256::from_array([1.0, 2.0, 3.0, 4.0, 20.0, 30.0, 40.0, 50.0]);
1114 let b = m256::from_array([59.0, 61.0, 79.0, 81.5, 90.0, 100.0, 110.0, 51.0]);
1115 let c = sub_m256(a, b).to_array();
1116 assert_eq!(c, [-58.0, -59.0, -76.0, -77.5, -70.0, -70.0, -70.0, -1.0]);
1117 }
1118
1119 #[test]
1120 fn test_unpack_hi_m256d() {
1121 let a = m256d::from_array([1.0, 2.0, 3.0, 4.0]);
1122 let b = m256d::from_array([59.0, 61.0, 79.0, 81.5]);
1123 let c = unpack_hi_m256d(a, b).to_array();
1124 assert_eq!(c, [2.0, 61.0, 4.0, 81.5]);
1125 }
1126
1127 #[test]
1128 fn test_unpack_hi_m256() {
1129 let a = m256::from_array([1.0, 2.0, 3.0, 4.0, 20.0, 30.0, 40.0, 50.0]);
1130 let b = m256::from_array([59.0, 61.0, 79.0, 81.5, 90.0, 100.0, 110.0, 51.0]);
1131 let c = unpack_hi_m256(a, b).to_array();
1132 assert_eq!(c, [3.0, 79.0, 4.0, 81.5, 40.0, 110.0, 50.0, 51.0]);
1133 }
1134
1135 #[test]
1136 fn test_unpack_lo_m256d() {
1137 let a = m256d::from_array([1.0, 2.0, 3.0, 4.0]);
1138 let b = m256d::from_array([59.0, 61.0, 79.0, 81.5]);
1139 let c = unpack_lo_m256d(a, b).to_array();
1140 assert_eq!(c, [1.0, 59.0, 3.0, 79.0]);
1141 }
1142
1143 #[test]
1144 fn test_unpack_lo_m256() {
1145 let a = m256::from_array([1.0, 2.0, 3.0, 4.0, 20.0, 30.0, 40.0, 50.0]);
1146 let b = m256::from_array([59.0, 61.0, 79.0, 81.5, 90.0, 100.0, 110.0, 51.0]);
1147 let c = unpack_lo_m256(a, b).to_array();
1148 assert_eq!(c, [1.0, 59.0, 2.0, 61.0, 20.0, 90.0, 30.0, 100.0]);
1149 }
1150
1151 #[test]
1152 fn test_bitxor_m256d() {
1153 let a = m256d::from_array([1.0, 0.0, 1.0, 0.0]);
1154 let b = m256d::from_array([1.0, 1.0, 0.0, 0.0]);
1155 let c = bitxor_m256d(a, b).to_array();
1156 assert_eq!(c, [0.0, 1.0, 1.0, 0.0]);
1157 }
1158
1159 #[test]
1160 fn test_bitxor_m256() {
1161 let a = m256::from_array([1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0]);
1162 let b = m256::from_array([1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0]);
1163 let c = bitxor_m256(a, b).to_array();
1164 assert_eq!(c, [0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0]);
1165 }
1166
1167 #[test]
1168 fn test_zero_extend_m128d() {
1169 let a = zero_extend_m128d(m128d::from_array([1.0, 2.0])).to_array();
1170 assert_eq!(a, [1.0, 2.0, 0.0, 0.0]);
1171 }
1172
1173 #[test]
1174 fn test_zero_extend_m128() {
1175 let a = zero_extend_m128(m128::from_array([1.0, 2.0, 3.0, 4.0])).to_array();
1176 assert_eq!(a, [1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 0.0, 0.0]);
1177 }
1178
1179 #[test]
1180 fn test_zero_extend_m128i() {
1181 let a: [i32; 8] = zero_extend_m128i(m128i::from([1, 2, 3, 4])).into();
1182 assert_eq!(a, [1, 2, 3, 4, 0, 0, 0, 0]);
1183 }
1184
1185 #[test]
1186 fn test_ptest_m256() {
1187 let a = m256::from([-1.0, 5.0, -1.0, 0.0, -1.0, 0.0, -1.0, 0.0]);
1188 let b = m256::from([0.0, -1.0, 0.0, -1.0, 0.0, -1.0, 0.0, -1.0]);
1189
1190 assert_eq!(testz_m256(a, a), 0);
1191 assert_eq!(testz_m256(a, b), 1);
1192 assert_eq!(testz_m256(b, b), 0);
1193
1194 assert_eq!(testc_m256(a, a), 1);
1195 assert_eq!(testc_m256(a, b), 0);
1196 assert_eq!(testc_m256(b, b), 1);
1197 }
1198
1199 #[test]
1200 fn test_ptest_m128() {
1201 let a = m128::from([-1.0, 5.0, -1.0, 0.0]);
1202 let b = m128::from([0.0, -1.0, 0.0, -1.0]);
1203
1204 assert_eq!(testz_m128(a, a), 0);
1205 assert_eq!(testz_m128(a, b), 1);
1206 assert_eq!(testz_m128(b, b), 0);
1207
1208 assert_eq!(testc_m128(a, a), 1);
1209 assert_eq!(testc_m128(a, b), 0);
1210 assert_eq!(testc_m128(b, b), 1);
1211 }
1212
1213 #[test]
1214 fn test_ptest_m256d() {
1215 let a = m256d::from([-1.0, 5.0, -1.0, 0.0]);
1216 let b = m256d::from([0.0, -1.0, 0.0, -1.0]);
1217
1218 assert_eq!(testz_m256d(a, a), 0);
1219 assert_eq!(testz_m256d(a, b), 1);
1220 assert_eq!(testz_m256d(b, b), 0);
1221
1222 assert_eq!(testc_m256d(a, a), 1);
1223 assert_eq!(testc_m256d(a, b), 0);
1224 assert_eq!(testc_m256d(b, b), 1);
1225 }
1226
1227 #[test]
1228 fn test_ptest_m128d() {
1229 let a = m128d::from([-1.0, 5.0]);
1230 let b = m128d::from([0.0, -1.0]);
1231
1232 assert_eq!(testz_m128d(a, a), 0);
1233 assert_eq!(testz_m128d(a, b), 1);
1234 assert_eq!(testz_m128d(b, b), 0);
1235
1236 assert_eq!(testc_m128d(a, a), 1);
1237 assert_eq!(testc_m128d(a, b), 0);
1238 assert_eq!(testc_m128d(b, b), 1);
1239 }
1240
1241 #[test]
1242 fn test_ptest_i256() {
1243 let a = m256i::from([1, 0, 1, 0, 1, 0, 1, 0]);
1244 let b = m256i::from([0, 1, 0, 1, 0, 1, 0, 1]);
1245
1246 assert_eq!(testz_m256i(a, a), 0);
1247 assert_eq!(testz_m256i(a, b), 1);
1248 assert_eq!(testz_m256i(b, b), 0);
1249
1250 assert_eq!(testc_m256i(a, a), 1);
1251 assert_eq!(testc_m256i(a, b), 0);
1252 assert_eq!(testc_m256i(b, b), 1);
1253 }