Skip to content

Add {u32,f32,...}xN shorthand types for Simd<{u32,f32,...}, N> #447

Open
@ds84182

Description

@ds84182

Shorthand types that are generic over lane count:

type u32xN<const N: usize> = Simd<u32, N>;
type f32xN<const N: usize> = Simd<f32, N>;
type u64xN<const N: usize> = Simd<u64, N>;
type f64xN<const N: usize> = Simd<f64, N>;
// etc.

I've found it easier to write these compared to Simd<u32, N> (which I find quite noisy).

And possibly the inverse, although not as useful(?):

type Tx1<T> = Simd<T, 1>;
type Tx2<T> = Simd<T, 2>;
type Tx4<T> = Simd<T, 4>;
type Tx8<T> = Simd<T, 8>;
// etc.

This would be used in code that is generic over lane count, for example:

fn multiply_add<const N: usize>(x: f32xN<N>, y: f32xN<N>, z: f32xN<N>) -> f32xN<N>
  where LaneCount<N>: SupportedLaneCount
{
  x * y + z
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: a feature request, i.e. not implemented / a PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions