Trait simba::simd::SimdValue

source ·
pub trait SimdValue: Sized {
    type Element: SimdValue<Element = Self::Element, SimdBool = bool>;
    type SimdBool: SimdBool;

    const LANES: usize;

    // Required methods
    fn splat(val: Self::Element) -> Self;
    fn extract(&self, i: usize) -> Self::Element;
    unsafe fn extract_unchecked(&self, i: usize) -> Self::Element;
    fn replace(&mut self, i: usize, val: Self::Element);
    unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element);
    fn select(self, cond: Self::SimdBool, other: Self) -> Self;

    // Provided methods
    fn map_lanes(self, f: impl Fn(Self::Element) -> Self::Element) -> Self
       where Self: Clone { ... }
    fn zip_map_lanes(
        self,
        b: Self,
        f: impl Fn(Self::Element, Self::Element) -> Self::Element,
    ) -> Self
       where Self: Clone { ... }
}
Expand description

Base trait for every SIMD types.

Required Associated Types§

source

type Element: SimdValue<Element = Self::Element, SimdBool = bool>

The type of the elements of each lane of this SIMD value.

source

type SimdBool: SimdBool

Type of the result of comparing two SIMD values like self.

Required Associated Constants§

source

const LANES: usize

The number of lanes of this SIMD value.

Required Methods§

source

fn splat(val: Self::Element) -> Self

Initializes an SIMD value with each lanes set to val.

source

fn extract(&self, i: usize) -> Self::Element

Extracts the i-th lane of self.

Panics if i >= Self::LANES.

source

unsafe fn extract_unchecked(&self, i: usize) -> Self::Element

Extracts the i-th lane of self without bound-checking.

§Safety

Undefined behavior if i >= Self::LANES.

source

fn replace(&mut self, i: usize, val: Self::Element)

Replaces the i-th lane of self by val.

Panics if i >= Self::LANES.

source

unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element)

Replaces the i-th lane of self by val without bound-checking.

§Safety

Undefined behavior if i >= Self::LANES.

source

fn select(self, cond: Self::SimdBool, other: Self) -> Self

Merges self and other depending on the lanes of cond.

For each lane of cond with bits set to 1, the result’s will contain the value of the lane of self. For each lane of cond with bits set to 0, the result’s will contain the value of the lane of other.

Provided Methods§

source

fn map_lanes(self, f: impl Fn(Self::Element) -> Self::Element) -> Self
where Self: Clone,

Applies a function to each lane of self.

Note that, while convenient, this method can be extremely slow as this requires to extract each lane of self and then combine them again into a new SIMD value.

source

fn zip_map_lanes( self, b: Self, f: impl Fn(Self::Element, Self::Element) -> Self::Element, ) -> Self
where Self: Clone,

Applies a function to each lane of self paired with the corresponding lane of b.

Note that, while convenient, this method can be extremely slow as this requires to extract each lane of self and then combine them again into a new SIMD value.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl SimdValue for bool

source§

const LANES: usize = 1usize

§

type Element = bool

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for f32

source§

const LANES: usize = 1usize

§

type Element = f32

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for f64

source§

const LANES: usize = 1usize

§

type Element = f64

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for i8

source§

const LANES: usize = 1usize

§

type Element = i8

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for i16

source§

const LANES: usize = 1usize

§

type Element = i16

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for i32

source§

const LANES: usize = 1usize

§

type Element = i32

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for i64

source§

const LANES: usize = 1usize

§

type Element = i64

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for i128

source§

const LANES: usize = 1usize

§

type Element = i128

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for isize

source§

const LANES: usize = 1usize

§

type Element = isize

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for u8

source§

const LANES: usize = 1usize

§

type Element = u8

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for u16

source§

const LANES: usize = 1usize

§

type Element = u16

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for u32

source§

const LANES: usize = 1usize

§

type Element = u32

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for u64

source§

const LANES: usize = 1usize

§

type Element = u64

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for u128

source§

const LANES: usize = 1usize

§

type Element = u128

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl SimdValue for usize

source§

const LANES: usize = 1usize

§

type Element = usize

§

type SimdBool = bool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, _: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, _: usize) -> Self::Element

source§

fn replace(&mut self, _: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, _: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

source§

impl<N: SimdValue> SimdValue for Complex<N>

source§

const LANES: usize = N::LANES

§

type Element = Complex<<N as SimdValue>::Element>

§

type SimdBool = <N as SimdValue>::SimdBool

source§

fn splat(val: Self::Element) -> Self

source§

fn extract(&self, i: usize) -> Self::Element

source§

unsafe fn extract_unchecked(&self, i: usize) -> Self::Element

source§

fn replace(&mut self, i: usize, val: Self::Element)

source§

unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element)

source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

Implementors§

source§

impl SimdValue for AutoSimd<[bool; 1]>

source§

const LANES: usize = 1usize

§

type Element = bool

§

type SimdBool = AutoSimd<[bool; 1]>

source§

impl SimdValue for AutoSimd<[bool; 2]>

source§

const LANES: usize = 2usize

§

type Element = bool

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[bool; 4]>

source§

const LANES: usize = 4usize

§

type Element = bool

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[bool; 8]>

source§

const LANES: usize = 8usize

§

type Element = bool

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[bool; 16]>

source§

const LANES: usize = 16usize

§

type Element = bool

§

type SimdBool = AutoSimd<[bool; 16]>

source§

impl SimdValue for AutoSimd<[bool; 32]>

source§

const LANES: usize = 32usize

§

type Element = bool

§

type SimdBool = AutoSimd<[bool; 32]>

source§

impl SimdValue for AutoSimd<[f32; 2]>

source§

const LANES: usize = 2usize

§

type Element = f32

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[f32; 4]>

source§

const LANES: usize = 4usize

§

type Element = f32

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[f32; 8]>

source§

const LANES: usize = 8usize

§

type Element = f32

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[f32; 16]>

source§

const LANES: usize = 16usize

§

type Element = f32

§

type SimdBool = AutoSimd<[bool; 16]>

source§

impl SimdValue for AutoSimd<[f64; 2]>

source§

const LANES: usize = 2usize

§

type Element = f64

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[f64; 4]>

source§

const LANES: usize = 4usize

§

type Element = f64

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[f64; 8]>

source§

const LANES: usize = 8usize

§

type Element = f64

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[i8; 2]>

source§

const LANES: usize = 2usize

§

type Element = i8

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[i8; 4]>

source§

const LANES: usize = 4usize

§

type Element = i8

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[i8; 8]>

source§

const LANES: usize = 8usize

§

type Element = i8

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[i8; 16]>

source§

const LANES: usize = 16usize

§

type Element = i8

§

type SimdBool = AutoSimd<[bool; 16]>

source§

impl SimdValue for AutoSimd<[i8; 32]>

source§

const LANES: usize = 32usize

§

type Element = i8

§

type SimdBool = AutoSimd<[bool; 32]>

source§

impl SimdValue for AutoSimd<[i16; 2]>

source§

const LANES: usize = 2usize

§

type Element = i16

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[i16; 4]>

source§

const LANES: usize = 4usize

§

type Element = i16

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[i16; 8]>

source§

const LANES: usize = 8usize

§

type Element = i16

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[i16; 16]>

source§

const LANES: usize = 16usize

§

type Element = i16

§

type SimdBool = AutoSimd<[bool; 16]>

source§

impl SimdValue for AutoSimd<[i16; 32]>

source§

const LANES: usize = 32usize

§

type Element = i16

§

type SimdBool = AutoSimd<[bool; 32]>

source§

impl SimdValue for AutoSimd<[i32; 2]>

source§

const LANES: usize = 2usize

§

type Element = i32

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[i32; 4]>

source§

const LANES: usize = 4usize

§

type Element = i32

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[i32; 8]>

source§

const LANES: usize = 8usize

§

type Element = i32

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[i32; 16]>

source§

const LANES: usize = 16usize

§

type Element = i32

§

type SimdBool = AutoSimd<[bool; 16]>

source§

impl SimdValue for AutoSimd<[i64; 2]>

source§

const LANES: usize = 2usize

§

type Element = i64

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[i64; 4]>

source§

const LANES: usize = 4usize

§

type Element = i64

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[i64; 8]>

source§

const LANES: usize = 8usize

§

type Element = i64

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[i128; 1]>

source§

const LANES: usize = 1usize

§

type Element = i128

§

type SimdBool = AutoSimd<[bool; 1]>

source§

impl SimdValue for AutoSimd<[i128; 2]>

source§

const LANES: usize = 2usize

§

type Element = i128

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[i128; 4]>

source§

const LANES: usize = 4usize

§

type Element = i128

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[isize; 2]>

source§

const LANES: usize = 2usize

§

type Element = isize

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[isize; 4]>

source§

const LANES: usize = 4usize

§

type Element = isize

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[isize; 8]>

source§

const LANES: usize = 8usize

§

type Element = isize

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[u8; 2]>

source§

const LANES: usize = 2usize

§

type Element = u8

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[u8; 4]>

source§

const LANES: usize = 4usize

§

type Element = u8

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[u8; 8]>

source§

const LANES: usize = 8usize

§

type Element = u8

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[u8; 16]>

source§

const LANES: usize = 16usize

§

type Element = u8

§

type SimdBool = AutoSimd<[bool; 16]>

source§

impl SimdValue for AutoSimd<[u8; 32]>

source§

const LANES: usize = 32usize

§

type Element = u8

§

type SimdBool = AutoSimd<[bool; 32]>

source§

impl SimdValue for AutoSimd<[u16; 2]>

source§

const LANES: usize = 2usize

§

type Element = u16

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[u16; 4]>

source§

const LANES: usize = 4usize

§

type Element = u16

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[u16; 8]>

source§

const LANES: usize = 8usize

§

type Element = u16

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[u16; 16]>

source§

const LANES: usize = 16usize

§

type Element = u16

§

type SimdBool = AutoSimd<[bool; 16]>

source§

impl SimdValue for AutoSimd<[u16; 32]>

source§

const LANES: usize = 32usize

§

type Element = u16

§

type SimdBool = AutoSimd<[bool; 32]>

source§

impl SimdValue for AutoSimd<[u32; 2]>

source§

const LANES: usize = 2usize

§

type Element = u32

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[u32; 4]>

source§

const LANES: usize = 4usize

§

type Element = u32

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[u32; 8]>

source§

const LANES: usize = 8usize

§

type Element = u32

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[u32; 16]>

source§

const LANES: usize = 16usize

§

type Element = u32

§

type SimdBool = AutoSimd<[bool; 16]>

source§

impl SimdValue for AutoSimd<[u64; 2]>

source§

const LANES: usize = 2usize

§

type Element = u64

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[u64; 4]>

source§

const LANES: usize = 4usize

§

type Element = u64

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[u64; 8]>

source§

const LANES: usize = 8usize

§

type Element = u64

§

type SimdBool = AutoSimd<[bool; 8]>

source§

impl SimdValue for AutoSimd<[u128; 1]>

source§

const LANES: usize = 1usize

§

type Element = u128

§

type SimdBool = AutoSimd<[bool; 1]>

source§

impl SimdValue for AutoSimd<[u128; 2]>

source§

const LANES: usize = 2usize

§

type Element = u128

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[u128; 4]>

source§

const LANES: usize = 4usize

§

type Element = u128

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[usize; 2]>

source§

const LANES: usize = 2usize

§

type Element = usize

§

type SimdBool = AutoSimd<[bool; 2]>

source§

impl SimdValue for AutoSimd<[usize; 4]>

source§

const LANES: usize = 4usize

§

type Element = usize

§

type SimdBool = AutoSimd<[bool; 4]>

source§

impl SimdValue for AutoSimd<[usize; 8]>

source§

const LANES: usize = 8usize

§

type Element = usize

§

type SimdBool = AutoSimd<[bool; 8]>