pub trait SIMDBase<const N: usize>{
type Underlying;
type Element;
const N: usize = N;
Show 13 methods
// Required methods
fn broadcast(value: Self::Element) -> Self;
unsafe fn load_ptr(addr: *const Self::Element) -> Self;
unsafe fn store_ptr(self, addr: *mut Self::Element);
fn sum(self) -> Self::Element;
// Provided methods
fn load(data: &[Self::Element; N]) -> Self { ... }
fn load_checked(data: &[Self::Element]) -> Self { ... }
fn load_prefix(data: &[Self::Element]) -> Self { ... }
fn store(self, array: &mut [Self::Element; N]) { ... }
fn store_checked(self, slice: &mut [Self::Element]) { ... }
fn store_prefix(self, slice: &mut [Self::Element]) { ... }
fn extract(self, index: usize) -> Self::Element { ... }
fn extract_wrapping(self, index: usize) -> Self::Element { ... }
fn extract_const<const INDEX: i32>(self) -> Self::Element { ... }
}
Expand description
Base trait for fixed-size vector types.
Required Associated Types§
sourcetype Underlying
type Underlying
Underlying intrinsic type or tuple of types.
Provided Associated Constants§
Required Methods§
Provided Methods§
sourcefn load(data: &[Self::Element; N]) -> Self
fn load(data: &[Self::Element; N]) -> Self
Loads vector from a given array.
§Exmaples
assert_eq!(
Vec4f::new(1.0, 2.0, 3.0, 4.0),
Vec4f::load(&[1.0, 2.0, 3.0, 4.0])
);
sourcefn load_checked(data: &[Self::Element]) -> Self
fn load_checked(data: &[Self::Element]) -> Self
Checks that data
contains exactly N
elements and loads them into vector.
§Panics
Panics if data.len()
doesn’t equal N
.
§Examples
assert_eq!(
Vec4f::load_checked(&[1.0, 2.0, 3.0, 4.0]),
Vec4f::new(1.0, 2.0, 3.0, 4.0)
);
ⓘ
Vec4f::load_checked(&[1.0, 2.0, 3.0]);
ⓘ
Vec4f::load_checked(&[1.0, 2.0, 3.0, 4.0, 5.0]);
sourcefn load_prefix(data: &[Self::Element]) -> Self
fn load_prefix(data: &[Self::Element]) -> Self
sourcefn store_checked(self, slice: &mut [Self::Element])
fn store_checked(self, slice: &mut [Self::Element])
Checks that slice
contains exactly N
elements and stores elements of vector there.
§Panics
Panics if slice.len()
doesn’t equal N
.
§Examples
let mut data = [-1.0; 4];
Vec4f::default().store_checked(&mut data);
assert_eq!(data, [0.0; 4]);
ⓘ
let mut data = [-1.0; 3];
Vec4f::default().store_checked(&mut data);
ⓘ
let mut data = [-1.0; 5];
Vec4f::default().store_checked(&mut data);
sourcefn store_prefix(self, slice: &mut [Self::Element])
fn store_prefix(self, slice: &mut [Self::Element])
sourcefn extract(self, index: usize) -> Self::Element
fn extract(self, index: usize) -> Self::Element
Extracts index
-th element of the vector. Index 0
corresponds to the “most left”
element.
§Panic
Panics if index
is invalid, i.e. isn’t less than N
.
§Examples
let vec = Vec4f::new(1.0, 2.0, 3.0, 4.0);
assert_eq!(vec.extract(2), 3.0);
ⓘ
Vec4f::default().extract(5);
§Note
If index
is known at compile time consider using extract_const
.
sourcefn extract_wrapping(self, index: usize) -> Self::Element
fn extract_wrapping(self, index: usize) -> Self::Element
sourcefn extract_const<const INDEX: i32>(self) -> Self::Element
fn extract_const<const INDEX: i32>(self) -> Self::Element
Extracts INDEX
-th element of the vector. Does same as extract
with compile-time
known index.
§Examples
let vec = Vec4f::new(1.0, 2.0, 3.0, 4.0);
assert_eq!(vec.extract_const::<2>(), 3.0);
ⓘ
Vec4f::default().extract_const::<5>();
§Note
Currently not all implementations assures that INDEX
is valid at compile time.
Object Safety§
This trait is not object safe.