@@ -367,10 +367,38 @@ where
367
367
368
368
/// Splits a vector into its two halves.
369
369
///
370
+ /// Vector length must be even, or a compile error will be raised.
371
+ ///
372
+ /// ```
373
+ /// # #![feature(portable_simd)]
374
+ /// # #[cfg(feature = "as_crate")] use core_simd::simd::Simd;
375
+ /// # #[cfg(not(feature = "as_crate"))] use core::simd::Simd;
376
+ /// let x = Simd::from_array([0, 1, 2, 3, 4, 5, 6, 7]);
377
+ /// let [y, z] = x.split();
378
+ /// assert_eq!(y.to_array(), [0, 1, 2, 3]);
379
+ /// assert_eq!(z.to_array(), [4, 5, 6, 7]);
380
+ /// ```
381
+ #[ inline]
382
+ #[ must_use = "method returns a new vector and does not mutate the original inputs" ]
383
+ #[ cfg( feature = "generic_const_exprs" ) ]
384
+ pub fn split ( self ) -> [ Simd < T , { LANES / 2 } > ; 2 ]
385
+ where
386
+ LaneCount < { LANES / 2 } > : SupportedLaneCount ,
387
+ {
388
+ self . split_to :: < { LANES / 2 } > ( )
389
+ }
390
+
391
+ /// Splits a vector into its two halves.
392
+ ///
393
+ /// Vector length must be even, or a compile error will be raised.
394
+ ///
370
395
/// Due to limitations in const generics, the length of the resulting vector cannot be inferred
371
396
/// from the input vectors. You must specify it explicitly. A compile-time error will be raised
372
397
/// if `HALF_LANES * 2 != LANES`.
373
398
///
399
+ /// When using the language feature and `std::simd` crate feature `generic_const_exprs`, prefer
400
+ /// to use `Simd::split` which can infer the output length.
401
+ ///
374
402
/// ```
375
403
/// # #![feature(portable_simd)]
376
404
/// # #[cfg(feature = "as_crate")] use core_simd::simd::Simd;
@@ -409,11 +437,35 @@ where
409
437
[ Split :: < false > :: swizzle ( self ) , Split :: < true > :: swizzle ( self ) ]
410
438
}
411
439
440
+ /// Concatenates two vectors of equal length.
441
+ ///
442
+ /// ```
443
+ /// # #![feature(portable_simd)]
444
+ /// # #[cfg(feature = "as_crate")] use core_simd::simd::Simd;
445
+ /// # #[cfg(not(feature = "as_crate"))] use core::simd::Simd;
446
+ /// let x = Simd::from_array([0, 1, 2, 3]);
447
+ /// let y = Simd::from_array([4, 5, 6, 7]);
448
+ /// let z = x.concat_to::<8>(y);
449
+ /// assert_eq!(z.to_array(), [0, 1, 2, 3, 4, 5, 6, 7]);
450
+ /// ```
451
+ #[ inline]
452
+ #[ must_use = "method returns a new vector and does not mutate the original inputs" ]
453
+ #[ cfg( feature = "generic_const_exprs" ) ]
454
+ pub fn concat ( self , other : Self ) -> Simd < T , { LANES * 2 } >
455
+ where
456
+ LaneCount < { LANES * 2 } > : SupportedLaneCount ,
457
+ {
458
+ self . concat_to :: < { LANES * 2 } > ( other)
459
+ }
460
+
412
461
/// Concatenates two vectors of equal length.
413
462
///
414
463
/// Due to limitations in const generics, the length of the resulting vector cannot be inferred
415
464
/// from the input vectors. You must specify it explicitly. A compile time error will be raised
416
- /// if `LANES * 2 != DOUBLE_LANES`
465
+ /// if `LANES * 2 != DOUBLE_LANES`.
466
+ ///
467
+ /// When using the language feature and `std::simd` crate feature `generic_const_exprs`, prefer
468
+ /// to use `Simd::split` which can infer the output length.
417
469
///
418
470
/// ```
419
471
/// # #![feature(portable_simd)]
0 commit comments