nalgebra/base/
matrix_simba.rs
1use simba::simd::SimdValue;
2
3use crate::base::allocator::Allocator;
4use crate::base::dimension::Dim;
5use crate::base::{DefaultAllocator, OMatrix, Scalar};
6
7impl<T, R, C> SimdValue for OMatrix<T, R, C>
13where
14 T: Scalar + SimdValue,
15 R: Dim,
16 C: Dim,
17 T::Element: Scalar,
18 DefaultAllocator: Allocator<T, R, C> + Allocator<T::Element, R, C>,
19{
20 type Element = OMatrix<T::Element, R, C>;
21 type SimdBool = T::SimdBool;
22
23 #[inline]
24 fn lanes() -> usize {
25 T::lanes()
26 }
27
28 #[inline]
29 fn splat(val: Self::Element) -> Self {
30 val.map(T::splat)
31 }
32
33 #[inline]
34 fn extract(&self, i: usize) -> Self::Element {
35 self.map(|e| e.extract(i))
36 }
37
38 #[inline]
39 unsafe fn extract_unchecked(&self, i: usize) -> Self::Element {
40 self.map(|e| e.extract_unchecked(i))
41 }
42
43 #[inline]
44 fn replace(&mut self, i: usize, val: Self::Element) {
45 self.zip_apply(&val, |a, b| {
46 a.replace(i, b);
47 })
48 }
49
50 #[inline]
51 unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element) {
52 self.zip_apply(&val, |a, b| {
53 a.replace_unchecked(i, b);
54 })
55 }
56
57 fn select(self, cond: Self::SimdBool, other: Self) -> Self {
58 self.zip_map(&other, |a, b| a.select(cond, b))
59 }
60}