1#[cfg(not(feature = "scalar-math"))]
4use crate::BVec4A;
5use crate::{
6 BVec4, I16Vec4, I64Vec4, I8Vec4, IVec4, U16Vec2, U16Vec3, U64Vec4, U8Vec4, USizeVec4, UVec4,
7};
8
9use core::fmt;
10use core::iter::{Product, Sum};
11use core::{f32, ops::*};
12
13#[inline(always)]
15#[must_use]
16pub const fn u16vec4(x: u16, y: u16, z: u16, w: u16) -> U16Vec4 {
17 U16Vec4::new(x, y, z, w)
18}
19
20#[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
22#[derive(Clone, Copy, PartialEq, Eq)]
23#[cfg_attr(feature = "cuda", repr(align(8)))]
24#[cfg_attr(not(target_arch = "spirv"), repr(C))]
25#[cfg_attr(target_arch = "spirv", repr(simd))]
26pub struct U16Vec4 {
27 pub x: u16,
28 pub y: u16,
29 pub z: u16,
30 pub w: u16,
31}
32
33impl U16Vec4 {
34 pub const ZERO: Self = Self::splat(0);
36
37 pub const ONE: Self = Self::splat(1);
39
40 pub const MIN: Self = Self::splat(u16::MIN);
42
43 pub const MAX: Self = Self::splat(u16::MAX);
45
46 pub const X: Self = Self::new(1, 0, 0, 0);
48
49 pub const Y: Self = Self::new(0, 1, 0, 0);
51
52 pub const Z: Self = Self::new(0, 0, 1, 0);
54
55 pub const W: Self = Self::new(0, 0, 0, 1);
57
58 pub const AXES: [Self; 4] = [Self::X, Self::Y, Self::Z, Self::W];
60
61 #[inline(always)]
63 #[must_use]
64 pub const fn new(x: u16, y: u16, z: u16, w: u16) -> Self {
65 Self { x, y, z, w }
66 }
67
68 #[inline]
70 #[must_use]
71 pub const fn splat(v: u16) -> Self {
72 Self {
73 x: v,
74
75 y: v,
76
77 z: v,
78
79 w: v,
80 }
81 }
82
83 #[inline]
85 #[must_use]
86 pub fn map<F>(self, f: F) -> Self
87 where
88 F: Fn(u16) -> u16,
89 {
90 Self::new(f(self.x), f(self.y), f(self.z), f(self.w))
91 }
92
93 #[inline]
99 #[must_use]
100 pub fn select(mask: BVec4, if_true: Self, if_false: Self) -> Self {
101 Self {
102 x: if mask.test(0) { if_true.x } else { if_false.x },
103 y: if mask.test(1) { if_true.y } else { if_false.y },
104 z: if mask.test(2) { if_true.z } else { if_false.z },
105 w: if mask.test(3) { if_true.w } else { if_false.w },
106 }
107 }
108
109 #[inline]
111 #[must_use]
112 pub const fn from_array(a: [u16; 4]) -> Self {
113 Self::new(a[0], a[1], a[2], a[3])
114 }
115
116 #[inline]
118 #[must_use]
119 pub const fn to_array(&self) -> [u16; 4] {
120 [self.x, self.y, self.z, self.w]
121 }
122
123 #[inline]
129 #[must_use]
130 pub const fn from_slice(slice: &[u16]) -> Self {
131 assert!(slice.len() >= 4);
132 Self::new(slice[0], slice[1], slice[2], slice[3])
133 }
134
135 #[inline]
141 pub fn write_to_slice(self, slice: &mut [u16]) {
142 slice[..4].copy_from_slice(&self.to_array());
143 }
144
145 #[inline]
149 #[must_use]
150 pub fn truncate(self) -> U16Vec3 {
151 use crate::swizzles::Vec4Swizzles;
152 self.xyz()
153 }
154
155 #[inline]
157 #[must_use]
158 pub fn with_x(mut self, x: u16) -> Self {
159 self.x = x;
160 self
161 }
162
163 #[inline]
165 #[must_use]
166 pub fn with_y(mut self, y: u16) -> Self {
167 self.y = y;
168 self
169 }
170
171 #[inline]
173 #[must_use]
174 pub fn with_z(mut self, z: u16) -> Self {
175 self.z = z;
176 self
177 }
178
179 #[inline]
181 #[must_use]
182 pub fn with_w(mut self, w: u16) -> Self {
183 self.w = w;
184 self
185 }
186
187 #[inline]
189 #[must_use]
190 pub fn dot(self, rhs: Self) -> u16 {
191 (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z) + (self.w * rhs.w)
192 }
193
194 #[inline]
196 #[must_use]
197 pub fn dot_into_vec(self, rhs: Self) -> Self {
198 Self::splat(self.dot(rhs))
199 }
200
201 #[inline]
205 #[must_use]
206 pub fn min(self, rhs: Self) -> Self {
207 Self {
208 x: if self.x < rhs.x { self.x } else { rhs.x },
209 y: if self.y < rhs.y { self.y } else { rhs.y },
210 z: if self.z < rhs.z { self.z } else { rhs.z },
211 w: if self.w < rhs.w { self.w } else { rhs.w },
212 }
213 }
214
215 #[inline]
219 #[must_use]
220 pub fn max(self, rhs: Self) -> Self {
221 Self {
222 x: if self.x > rhs.x { self.x } else { rhs.x },
223 y: if self.y > rhs.y { self.y } else { rhs.y },
224 z: if self.z > rhs.z { self.z } else { rhs.z },
225 w: if self.w > rhs.w { self.w } else { rhs.w },
226 }
227 }
228
229 #[inline]
237 #[must_use]
238 pub fn clamp(self, min: Self, max: Self) -> Self {
239 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
240 self.max(min).min(max)
241 }
242
243 #[inline]
247 #[must_use]
248 pub fn min_element(self) -> u16 {
249 let min = |a, b| if a < b { a } else { b };
250 min(self.x, min(self.y, min(self.z, self.w)))
251 }
252
253 #[inline]
257 #[must_use]
258 pub fn max_element(self) -> u16 {
259 let max = |a, b| if a > b { a } else { b };
260 max(self.x, max(self.y, max(self.z, self.w)))
261 }
262
263 #[doc(alias = "argmin")]
265 #[inline]
266 #[must_use]
267 pub fn min_position(self) -> usize {
268 let mut min = self.x;
269 let mut index = 0;
270 if self.y < min {
271 min = self.y;
272 index = 1;
273 }
274 if self.z < min {
275 min = self.z;
276 index = 2;
277 }
278 if self.w < min {
279 index = 3;
280 }
281 index
282 }
283
284 #[doc(alias = "argmax")]
286 #[inline]
287 #[must_use]
288 pub fn max_position(self) -> usize {
289 let mut max = self.x;
290 let mut index = 0;
291 if self.y > max {
292 max = self.y;
293 index = 1;
294 }
295 if self.z > max {
296 max = self.z;
297 index = 2;
298 }
299 if self.w > max {
300 index = 3;
301 }
302 index
303 }
304
305 #[inline]
309 #[must_use]
310 pub fn element_sum(self) -> u16 {
311 self.x + self.y + self.z + self.w
312 }
313
314 #[inline]
318 #[must_use]
319 pub fn element_product(self) -> u16 {
320 self.x * self.y * self.z * self.w
321 }
322
323 #[inline]
329 #[must_use]
330 pub fn cmpeq(self, rhs: Self) -> BVec4 {
331 BVec4::new(
332 self.x.eq(&rhs.x),
333 self.y.eq(&rhs.y),
334 self.z.eq(&rhs.z),
335 self.w.eq(&rhs.w),
336 )
337 }
338
339 #[inline]
345 #[must_use]
346 pub fn cmpne(self, rhs: Self) -> BVec4 {
347 BVec4::new(
348 self.x.ne(&rhs.x),
349 self.y.ne(&rhs.y),
350 self.z.ne(&rhs.z),
351 self.w.ne(&rhs.w),
352 )
353 }
354
355 #[inline]
361 #[must_use]
362 pub fn cmpge(self, rhs: Self) -> BVec4 {
363 BVec4::new(
364 self.x.ge(&rhs.x),
365 self.y.ge(&rhs.y),
366 self.z.ge(&rhs.z),
367 self.w.ge(&rhs.w),
368 )
369 }
370
371 #[inline]
377 #[must_use]
378 pub fn cmpgt(self, rhs: Self) -> BVec4 {
379 BVec4::new(
380 self.x.gt(&rhs.x),
381 self.y.gt(&rhs.y),
382 self.z.gt(&rhs.z),
383 self.w.gt(&rhs.w),
384 )
385 }
386
387 #[inline]
393 #[must_use]
394 pub fn cmple(self, rhs: Self) -> BVec4 {
395 BVec4::new(
396 self.x.le(&rhs.x),
397 self.y.le(&rhs.y),
398 self.z.le(&rhs.z),
399 self.w.le(&rhs.w),
400 )
401 }
402
403 #[inline]
409 #[must_use]
410 pub fn cmplt(self, rhs: Self) -> BVec4 {
411 BVec4::new(
412 self.x.lt(&rhs.x),
413 self.y.lt(&rhs.y),
414 self.z.lt(&rhs.z),
415 self.w.lt(&rhs.w),
416 )
417 }
418
419 #[doc(alias = "magnitude2")]
421 #[inline]
422 #[must_use]
423 pub fn length_squared(self) -> u16 {
424 self.dot(self)
425 }
426
427 #[inline]
436 #[must_use]
437 pub fn manhattan_distance(self, other: Self) -> u16 {
438 self.x.abs_diff(other.x)
439 + self.y.abs_diff(other.y)
440 + self.z.abs_diff(other.z)
441 + self.w.abs_diff(other.w)
442 }
443
444 #[inline]
450 #[must_use]
451 pub fn checked_manhattan_distance(self, other: Self) -> Option<u16> {
452 let d = self.x.abs_diff(other.x);
453 let d = d.checked_add(self.y.abs_diff(other.y))?;
454 let d = d.checked_add(self.z.abs_diff(other.z))?;
455 d.checked_add(self.w.abs_diff(other.w))
456 }
457
458 #[inline]
462 #[must_use]
463 pub fn chebyshev_distance(self, other: Self) -> u16 {
464 [
466 self.x.abs_diff(other.x),
467 self.y.abs_diff(other.y),
468 self.z.abs_diff(other.z),
469 self.w.abs_diff(other.w),
470 ]
471 .into_iter()
472 .max()
473 .unwrap()
474 }
475
476 #[inline]
478 #[must_use]
479 pub fn as_vec4(&self) -> crate::Vec4 {
480 crate::Vec4::new(self.x as f32, self.y as f32, self.z as f32, self.w as f32)
481 }
482
483 #[inline]
485 #[must_use]
486 pub fn as_dvec4(&self) -> crate::DVec4 {
487 crate::DVec4::new(self.x as f64, self.y as f64, self.z as f64, self.w as f64)
488 }
489
490 #[inline]
492 #[must_use]
493 pub fn as_i8vec4(&self) -> crate::I8Vec4 {
494 crate::I8Vec4::new(self.x as i8, self.y as i8, self.z as i8, self.w as i8)
495 }
496
497 #[inline]
499 #[must_use]
500 pub fn as_u8vec4(&self) -> crate::U8Vec4 {
501 crate::U8Vec4::new(self.x as u8, self.y as u8, self.z as u8, self.w as u8)
502 }
503
504 #[inline]
506 #[must_use]
507 pub fn as_i16vec4(&self) -> crate::I16Vec4 {
508 crate::I16Vec4::new(self.x as i16, self.y as i16, self.z as i16, self.w as i16)
509 }
510
511 #[inline]
513 #[must_use]
514 pub fn as_ivec4(&self) -> crate::IVec4 {
515 crate::IVec4::new(self.x as i32, self.y as i32, self.z as i32, self.w as i32)
516 }
517
518 #[inline]
520 #[must_use]
521 pub fn as_uvec4(&self) -> crate::UVec4 {
522 crate::UVec4::new(self.x as u32, self.y as u32, self.z as u32, self.w as u32)
523 }
524
525 #[inline]
527 #[must_use]
528 pub fn as_i64vec4(&self) -> crate::I64Vec4 {
529 crate::I64Vec4::new(self.x as i64, self.y as i64, self.z as i64, self.w as i64)
530 }
531
532 #[inline]
534 #[must_use]
535 pub fn as_u64vec4(&self) -> crate::U64Vec4 {
536 crate::U64Vec4::new(self.x as u64, self.y as u64, self.z as u64, self.w as u64)
537 }
538
539 #[inline]
541 #[must_use]
542 pub fn as_usizevec4(&self) -> crate::USizeVec4 {
543 crate::USizeVec4::new(
544 self.x as usize,
545 self.y as usize,
546 self.z as usize,
547 self.w as usize,
548 )
549 }
550
551 #[inline]
555 #[must_use]
556 pub const fn checked_add(self, rhs: Self) -> Option<Self> {
557 let x = match self.x.checked_add(rhs.x) {
558 Some(v) => v,
559 None => return None,
560 };
561 let y = match self.y.checked_add(rhs.y) {
562 Some(v) => v,
563 None => return None,
564 };
565 let z = match self.z.checked_add(rhs.z) {
566 Some(v) => v,
567 None => return None,
568 };
569 let w = match self.w.checked_add(rhs.w) {
570 Some(v) => v,
571 None => return None,
572 };
573
574 Some(Self { x, y, z, w })
575 }
576
577 #[inline]
581 #[must_use]
582 pub const fn checked_sub(self, rhs: Self) -> Option<Self> {
583 let x = match self.x.checked_sub(rhs.x) {
584 Some(v) => v,
585 None => return None,
586 };
587 let y = match self.y.checked_sub(rhs.y) {
588 Some(v) => v,
589 None => return None,
590 };
591 let z = match self.z.checked_sub(rhs.z) {
592 Some(v) => v,
593 None => return None,
594 };
595 let w = match self.w.checked_sub(rhs.w) {
596 Some(v) => v,
597 None => return None,
598 };
599
600 Some(Self { x, y, z, w })
601 }
602
603 #[inline]
607 #[must_use]
608 pub const fn checked_mul(self, rhs: Self) -> Option<Self> {
609 let x = match self.x.checked_mul(rhs.x) {
610 Some(v) => v,
611 None => return None,
612 };
613 let y = match self.y.checked_mul(rhs.y) {
614 Some(v) => v,
615 None => return None,
616 };
617 let z = match self.z.checked_mul(rhs.z) {
618 Some(v) => v,
619 None => return None,
620 };
621 let w = match self.w.checked_mul(rhs.w) {
622 Some(v) => v,
623 None => return None,
624 };
625
626 Some(Self { x, y, z, w })
627 }
628
629 #[inline]
633 #[must_use]
634 pub const fn checked_div(self, rhs: Self) -> Option<Self> {
635 let x = match self.x.checked_div(rhs.x) {
636 Some(v) => v,
637 None => return None,
638 };
639 let y = match self.y.checked_div(rhs.y) {
640 Some(v) => v,
641 None => return None,
642 };
643 let z = match self.z.checked_div(rhs.z) {
644 Some(v) => v,
645 None => return None,
646 };
647 let w = match self.w.checked_div(rhs.w) {
648 Some(v) => v,
649 None => return None,
650 };
651
652 Some(Self { x, y, z, w })
653 }
654
655 #[inline]
659 #[must_use]
660 pub const fn wrapping_add(self, rhs: Self) -> Self {
661 Self {
662 x: self.x.wrapping_add(rhs.x),
663 y: self.y.wrapping_add(rhs.y),
664 z: self.z.wrapping_add(rhs.z),
665 w: self.w.wrapping_add(rhs.w),
666 }
667 }
668
669 #[inline]
673 #[must_use]
674 pub const fn wrapping_sub(self, rhs: Self) -> Self {
675 Self {
676 x: self.x.wrapping_sub(rhs.x),
677 y: self.y.wrapping_sub(rhs.y),
678 z: self.z.wrapping_sub(rhs.z),
679 w: self.w.wrapping_sub(rhs.w),
680 }
681 }
682
683 #[inline]
687 #[must_use]
688 pub const fn wrapping_mul(self, rhs: Self) -> Self {
689 Self {
690 x: self.x.wrapping_mul(rhs.x),
691 y: self.y.wrapping_mul(rhs.y),
692 z: self.z.wrapping_mul(rhs.z),
693 w: self.w.wrapping_mul(rhs.w),
694 }
695 }
696
697 #[inline]
701 #[must_use]
702 pub const fn wrapping_div(self, rhs: Self) -> Self {
703 Self {
704 x: self.x.wrapping_div(rhs.x),
705 y: self.y.wrapping_div(rhs.y),
706 z: self.z.wrapping_div(rhs.z),
707 w: self.w.wrapping_div(rhs.w),
708 }
709 }
710
711 #[inline]
715 #[must_use]
716 pub const fn saturating_add(self, rhs: Self) -> Self {
717 Self {
718 x: self.x.saturating_add(rhs.x),
719 y: self.y.saturating_add(rhs.y),
720 z: self.z.saturating_add(rhs.z),
721 w: self.w.saturating_add(rhs.w),
722 }
723 }
724
725 #[inline]
729 #[must_use]
730 pub const fn saturating_sub(self, rhs: Self) -> Self {
731 Self {
732 x: self.x.saturating_sub(rhs.x),
733 y: self.y.saturating_sub(rhs.y),
734 z: self.z.saturating_sub(rhs.z),
735 w: self.w.saturating_sub(rhs.w),
736 }
737 }
738
739 #[inline]
743 #[must_use]
744 pub const fn saturating_mul(self, rhs: Self) -> Self {
745 Self {
746 x: self.x.saturating_mul(rhs.x),
747 y: self.y.saturating_mul(rhs.y),
748 z: self.z.saturating_mul(rhs.z),
749 w: self.w.saturating_mul(rhs.w),
750 }
751 }
752
753 #[inline]
757 #[must_use]
758 pub const fn saturating_div(self, rhs: Self) -> Self {
759 Self {
760 x: self.x.saturating_div(rhs.x),
761 y: self.y.saturating_div(rhs.y),
762 z: self.z.saturating_div(rhs.z),
763 w: self.w.saturating_div(rhs.w),
764 }
765 }
766
767 #[inline]
771 #[must_use]
772 pub const fn checked_add_signed(self, rhs: I16Vec4) -> Option<Self> {
773 let x = match self.x.checked_add_signed(rhs.x) {
774 Some(v) => v,
775 None => return None,
776 };
777 let y = match self.y.checked_add_signed(rhs.y) {
778 Some(v) => v,
779 None => return None,
780 };
781 let z = match self.z.checked_add_signed(rhs.z) {
782 Some(v) => v,
783 None => return None,
784 };
785 let w = match self.w.checked_add_signed(rhs.w) {
786 Some(v) => v,
787 None => return None,
788 };
789
790 Some(Self { x, y, z, w })
791 }
792
793 #[inline]
797 #[must_use]
798 pub const fn wrapping_add_signed(self, rhs: I16Vec4) -> Self {
799 Self {
800 x: self.x.wrapping_add_signed(rhs.x),
801 y: self.y.wrapping_add_signed(rhs.y),
802 z: self.z.wrapping_add_signed(rhs.z),
803 w: self.w.wrapping_add_signed(rhs.w),
804 }
805 }
806
807 #[inline]
811 #[must_use]
812 pub const fn saturating_add_signed(self, rhs: I16Vec4) -> Self {
813 Self {
814 x: self.x.saturating_add_signed(rhs.x),
815 y: self.y.saturating_add_signed(rhs.y),
816 z: self.z.saturating_add_signed(rhs.z),
817 w: self.w.saturating_add_signed(rhs.w),
818 }
819 }
820}
821
822impl Default for U16Vec4 {
823 #[inline(always)]
824 fn default() -> Self {
825 Self::ZERO
826 }
827}
828
829impl Div<U16Vec4> for U16Vec4 {
830 type Output = Self;
831 #[inline]
832 fn div(self, rhs: Self) -> Self {
833 Self {
834 x: self.x.div(rhs.x),
835 y: self.y.div(rhs.y),
836 z: self.z.div(rhs.z),
837 w: self.w.div(rhs.w),
838 }
839 }
840}
841
842impl Div<&U16Vec4> for U16Vec4 {
843 type Output = U16Vec4;
844 #[inline]
845 fn div(self, rhs: &U16Vec4) -> U16Vec4 {
846 self.div(*rhs)
847 }
848}
849
850impl Div<&U16Vec4> for &U16Vec4 {
851 type Output = U16Vec4;
852 #[inline]
853 fn div(self, rhs: &U16Vec4) -> U16Vec4 {
854 (*self).div(*rhs)
855 }
856}
857
858impl Div<U16Vec4> for &U16Vec4 {
859 type Output = U16Vec4;
860 #[inline]
861 fn div(self, rhs: U16Vec4) -> U16Vec4 {
862 (*self).div(rhs)
863 }
864}
865
866impl DivAssign<U16Vec4> for U16Vec4 {
867 #[inline]
868 fn div_assign(&mut self, rhs: Self) {
869 self.x.div_assign(rhs.x);
870 self.y.div_assign(rhs.y);
871 self.z.div_assign(rhs.z);
872 self.w.div_assign(rhs.w);
873 }
874}
875
876impl DivAssign<&U16Vec4> for U16Vec4 {
877 #[inline]
878 fn div_assign(&mut self, rhs: &U16Vec4) {
879 self.div_assign(*rhs)
880 }
881}
882
883impl Div<u16> for U16Vec4 {
884 type Output = Self;
885 #[inline]
886 fn div(self, rhs: u16) -> Self {
887 Self {
888 x: self.x.div(rhs),
889 y: self.y.div(rhs),
890 z: self.z.div(rhs),
891 w: self.w.div(rhs),
892 }
893 }
894}
895
896impl Div<&u16> for U16Vec4 {
897 type Output = U16Vec4;
898 #[inline]
899 fn div(self, rhs: &u16) -> U16Vec4 {
900 self.div(*rhs)
901 }
902}
903
904impl Div<&u16> for &U16Vec4 {
905 type Output = U16Vec4;
906 #[inline]
907 fn div(self, rhs: &u16) -> U16Vec4 {
908 (*self).div(*rhs)
909 }
910}
911
912impl Div<u16> for &U16Vec4 {
913 type Output = U16Vec4;
914 #[inline]
915 fn div(self, rhs: u16) -> U16Vec4 {
916 (*self).div(rhs)
917 }
918}
919
920impl DivAssign<u16> for U16Vec4 {
921 #[inline]
922 fn div_assign(&mut self, rhs: u16) {
923 self.x.div_assign(rhs);
924 self.y.div_assign(rhs);
925 self.z.div_assign(rhs);
926 self.w.div_assign(rhs);
927 }
928}
929
930impl DivAssign<&u16> for U16Vec4 {
931 #[inline]
932 fn div_assign(&mut self, rhs: &u16) {
933 self.div_assign(*rhs)
934 }
935}
936
937impl Div<U16Vec4> for u16 {
938 type Output = U16Vec4;
939 #[inline]
940 fn div(self, rhs: U16Vec4) -> U16Vec4 {
941 U16Vec4 {
942 x: self.div(rhs.x),
943 y: self.div(rhs.y),
944 z: self.div(rhs.z),
945 w: self.div(rhs.w),
946 }
947 }
948}
949
950impl Div<&U16Vec4> for u16 {
951 type Output = U16Vec4;
952 #[inline]
953 fn div(self, rhs: &U16Vec4) -> U16Vec4 {
954 self.div(*rhs)
955 }
956}
957
958impl Div<&U16Vec4> for &u16 {
959 type Output = U16Vec4;
960 #[inline]
961 fn div(self, rhs: &U16Vec4) -> U16Vec4 {
962 (*self).div(*rhs)
963 }
964}
965
966impl Div<U16Vec4> for &u16 {
967 type Output = U16Vec4;
968 #[inline]
969 fn div(self, rhs: U16Vec4) -> U16Vec4 {
970 (*self).div(rhs)
971 }
972}
973
974impl Mul<U16Vec4> for U16Vec4 {
975 type Output = Self;
976 #[inline]
977 fn mul(self, rhs: Self) -> Self {
978 Self {
979 x: self.x.mul(rhs.x),
980 y: self.y.mul(rhs.y),
981 z: self.z.mul(rhs.z),
982 w: self.w.mul(rhs.w),
983 }
984 }
985}
986
987impl Mul<&U16Vec4> for U16Vec4 {
988 type Output = U16Vec4;
989 #[inline]
990 fn mul(self, rhs: &U16Vec4) -> U16Vec4 {
991 self.mul(*rhs)
992 }
993}
994
995impl Mul<&U16Vec4> for &U16Vec4 {
996 type Output = U16Vec4;
997 #[inline]
998 fn mul(self, rhs: &U16Vec4) -> U16Vec4 {
999 (*self).mul(*rhs)
1000 }
1001}
1002
1003impl Mul<U16Vec4> for &U16Vec4 {
1004 type Output = U16Vec4;
1005 #[inline]
1006 fn mul(self, rhs: U16Vec4) -> U16Vec4 {
1007 (*self).mul(rhs)
1008 }
1009}
1010
1011impl MulAssign<U16Vec4> for U16Vec4 {
1012 #[inline]
1013 fn mul_assign(&mut self, rhs: Self) {
1014 self.x.mul_assign(rhs.x);
1015 self.y.mul_assign(rhs.y);
1016 self.z.mul_assign(rhs.z);
1017 self.w.mul_assign(rhs.w);
1018 }
1019}
1020
1021impl MulAssign<&U16Vec4> for U16Vec4 {
1022 #[inline]
1023 fn mul_assign(&mut self, rhs: &U16Vec4) {
1024 self.mul_assign(*rhs)
1025 }
1026}
1027
1028impl Mul<u16> for U16Vec4 {
1029 type Output = Self;
1030 #[inline]
1031 fn mul(self, rhs: u16) -> Self {
1032 Self {
1033 x: self.x.mul(rhs),
1034 y: self.y.mul(rhs),
1035 z: self.z.mul(rhs),
1036 w: self.w.mul(rhs),
1037 }
1038 }
1039}
1040
1041impl Mul<&u16> for U16Vec4 {
1042 type Output = U16Vec4;
1043 #[inline]
1044 fn mul(self, rhs: &u16) -> U16Vec4 {
1045 self.mul(*rhs)
1046 }
1047}
1048
1049impl Mul<&u16> for &U16Vec4 {
1050 type Output = U16Vec4;
1051 #[inline]
1052 fn mul(self, rhs: &u16) -> U16Vec4 {
1053 (*self).mul(*rhs)
1054 }
1055}
1056
1057impl Mul<u16> for &U16Vec4 {
1058 type Output = U16Vec4;
1059 #[inline]
1060 fn mul(self, rhs: u16) -> U16Vec4 {
1061 (*self).mul(rhs)
1062 }
1063}
1064
1065impl MulAssign<u16> for U16Vec4 {
1066 #[inline]
1067 fn mul_assign(&mut self, rhs: u16) {
1068 self.x.mul_assign(rhs);
1069 self.y.mul_assign(rhs);
1070 self.z.mul_assign(rhs);
1071 self.w.mul_assign(rhs);
1072 }
1073}
1074
1075impl MulAssign<&u16> for U16Vec4 {
1076 #[inline]
1077 fn mul_assign(&mut self, rhs: &u16) {
1078 self.mul_assign(*rhs)
1079 }
1080}
1081
1082impl Mul<U16Vec4> for u16 {
1083 type Output = U16Vec4;
1084 #[inline]
1085 fn mul(self, rhs: U16Vec4) -> U16Vec4 {
1086 U16Vec4 {
1087 x: self.mul(rhs.x),
1088 y: self.mul(rhs.y),
1089 z: self.mul(rhs.z),
1090 w: self.mul(rhs.w),
1091 }
1092 }
1093}
1094
1095impl Mul<&U16Vec4> for u16 {
1096 type Output = U16Vec4;
1097 #[inline]
1098 fn mul(self, rhs: &U16Vec4) -> U16Vec4 {
1099 self.mul(*rhs)
1100 }
1101}
1102
1103impl Mul<&U16Vec4> for &u16 {
1104 type Output = U16Vec4;
1105 #[inline]
1106 fn mul(self, rhs: &U16Vec4) -> U16Vec4 {
1107 (*self).mul(*rhs)
1108 }
1109}
1110
1111impl Mul<U16Vec4> for &u16 {
1112 type Output = U16Vec4;
1113 #[inline]
1114 fn mul(self, rhs: U16Vec4) -> U16Vec4 {
1115 (*self).mul(rhs)
1116 }
1117}
1118
1119impl Add<U16Vec4> for U16Vec4 {
1120 type Output = Self;
1121 #[inline]
1122 fn add(self, rhs: Self) -> Self {
1123 Self {
1124 x: self.x.add(rhs.x),
1125 y: self.y.add(rhs.y),
1126 z: self.z.add(rhs.z),
1127 w: self.w.add(rhs.w),
1128 }
1129 }
1130}
1131
1132impl Add<&U16Vec4> for U16Vec4 {
1133 type Output = U16Vec4;
1134 #[inline]
1135 fn add(self, rhs: &U16Vec4) -> U16Vec4 {
1136 self.add(*rhs)
1137 }
1138}
1139
1140impl Add<&U16Vec4> for &U16Vec4 {
1141 type Output = U16Vec4;
1142 #[inline]
1143 fn add(self, rhs: &U16Vec4) -> U16Vec4 {
1144 (*self).add(*rhs)
1145 }
1146}
1147
1148impl Add<U16Vec4> for &U16Vec4 {
1149 type Output = U16Vec4;
1150 #[inline]
1151 fn add(self, rhs: U16Vec4) -> U16Vec4 {
1152 (*self).add(rhs)
1153 }
1154}
1155
1156impl AddAssign<U16Vec4> for U16Vec4 {
1157 #[inline]
1158 fn add_assign(&mut self, rhs: Self) {
1159 self.x.add_assign(rhs.x);
1160 self.y.add_assign(rhs.y);
1161 self.z.add_assign(rhs.z);
1162 self.w.add_assign(rhs.w);
1163 }
1164}
1165
1166impl AddAssign<&U16Vec4> for U16Vec4 {
1167 #[inline]
1168 fn add_assign(&mut self, rhs: &U16Vec4) {
1169 self.add_assign(*rhs)
1170 }
1171}
1172
1173impl Add<u16> for U16Vec4 {
1174 type Output = Self;
1175 #[inline]
1176 fn add(self, rhs: u16) -> Self {
1177 Self {
1178 x: self.x.add(rhs),
1179 y: self.y.add(rhs),
1180 z: self.z.add(rhs),
1181 w: self.w.add(rhs),
1182 }
1183 }
1184}
1185
1186impl Add<&u16> for U16Vec4 {
1187 type Output = U16Vec4;
1188 #[inline]
1189 fn add(self, rhs: &u16) -> U16Vec4 {
1190 self.add(*rhs)
1191 }
1192}
1193
1194impl Add<&u16> for &U16Vec4 {
1195 type Output = U16Vec4;
1196 #[inline]
1197 fn add(self, rhs: &u16) -> U16Vec4 {
1198 (*self).add(*rhs)
1199 }
1200}
1201
1202impl Add<u16> for &U16Vec4 {
1203 type Output = U16Vec4;
1204 #[inline]
1205 fn add(self, rhs: u16) -> U16Vec4 {
1206 (*self).add(rhs)
1207 }
1208}
1209
1210impl AddAssign<u16> for U16Vec4 {
1211 #[inline]
1212 fn add_assign(&mut self, rhs: u16) {
1213 self.x.add_assign(rhs);
1214 self.y.add_assign(rhs);
1215 self.z.add_assign(rhs);
1216 self.w.add_assign(rhs);
1217 }
1218}
1219
1220impl AddAssign<&u16> for U16Vec4 {
1221 #[inline]
1222 fn add_assign(&mut self, rhs: &u16) {
1223 self.add_assign(*rhs)
1224 }
1225}
1226
1227impl Add<U16Vec4> for u16 {
1228 type Output = U16Vec4;
1229 #[inline]
1230 fn add(self, rhs: U16Vec4) -> U16Vec4 {
1231 U16Vec4 {
1232 x: self.add(rhs.x),
1233 y: self.add(rhs.y),
1234 z: self.add(rhs.z),
1235 w: self.add(rhs.w),
1236 }
1237 }
1238}
1239
1240impl Add<&U16Vec4> for u16 {
1241 type Output = U16Vec4;
1242 #[inline]
1243 fn add(self, rhs: &U16Vec4) -> U16Vec4 {
1244 self.add(*rhs)
1245 }
1246}
1247
1248impl Add<&U16Vec4> for &u16 {
1249 type Output = U16Vec4;
1250 #[inline]
1251 fn add(self, rhs: &U16Vec4) -> U16Vec4 {
1252 (*self).add(*rhs)
1253 }
1254}
1255
1256impl Add<U16Vec4> for &u16 {
1257 type Output = U16Vec4;
1258 #[inline]
1259 fn add(self, rhs: U16Vec4) -> U16Vec4 {
1260 (*self).add(rhs)
1261 }
1262}
1263
1264impl Sub<U16Vec4> for U16Vec4 {
1265 type Output = Self;
1266 #[inline]
1267 fn sub(self, rhs: Self) -> Self {
1268 Self {
1269 x: self.x.sub(rhs.x),
1270 y: self.y.sub(rhs.y),
1271 z: self.z.sub(rhs.z),
1272 w: self.w.sub(rhs.w),
1273 }
1274 }
1275}
1276
1277impl Sub<&U16Vec4> for U16Vec4 {
1278 type Output = U16Vec4;
1279 #[inline]
1280 fn sub(self, rhs: &U16Vec4) -> U16Vec4 {
1281 self.sub(*rhs)
1282 }
1283}
1284
1285impl Sub<&U16Vec4> for &U16Vec4 {
1286 type Output = U16Vec4;
1287 #[inline]
1288 fn sub(self, rhs: &U16Vec4) -> U16Vec4 {
1289 (*self).sub(*rhs)
1290 }
1291}
1292
1293impl Sub<U16Vec4> for &U16Vec4 {
1294 type Output = U16Vec4;
1295 #[inline]
1296 fn sub(self, rhs: U16Vec4) -> U16Vec4 {
1297 (*self).sub(rhs)
1298 }
1299}
1300
1301impl SubAssign<U16Vec4> for U16Vec4 {
1302 #[inline]
1303 fn sub_assign(&mut self, rhs: U16Vec4) {
1304 self.x.sub_assign(rhs.x);
1305 self.y.sub_assign(rhs.y);
1306 self.z.sub_assign(rhs.z);
1307 self.w.sub_assign(rhs.w);
1308 }
1309}
1310
1311impl SubAssign<&U16Vec4> for U16Vec4 {
1312 #[inline]
1313 fn sub_assign(&mut self, rhs: &U16Vec4) {
1314 self.sub_assign(*rhs)
1315 }
1316}
1317
1318impl Sub<u16> for U16Vec4 {
1319 type Output = Self;
1320 #[inline]
1321 fn sub(self, rhs: u16) -> Self {
1322 Self {
1323 x: self.x.sub(rhs),
1324 y: self.y.sub(rhs),
1325 z: self.z.sub(rhs),
1326 w: self.w.sub(rhs),
1327 }
1328 }
1329}
1330
1331impl Sub<&u16> for U16Vec4 {
1332 type Output = U16Vec4;
1333 #[inline]
1334 fn sub(self, rhs: &u16) -> U16Vec4 {
1335 self.sub(*rhs)
1336 }
1337}
1338
1339impl Sub<&u16> for &U16Vec4 {
1340 type Output = U16Vec4;
1341 #[inline]
1342 fn sub(self, rhs: &u16) -> U16Vec4 {
1343 (*self).sub(*rhs)
1344 }
1345}
1346
1347impl Sub<u16> for &U16Vec4 {
1348 type Output = U16Vec4;
1349 #[inline]
1350 fn sub(self, rhs: u16) -> U16Vec4 {
1351 (*self).sub(rhs)
1352 }
1353}
1354
1355impl SubAssign<u16> for U16Vec4 {
1356 #[inline]
1357 fn sub_assign(&mut self, rhs: u16) {
1358 self.x.sub_assign(rhs);
1359 self.y.sub_assign(rhs);
1360 self.z.sub_assign(rhs);
1361 self.w.sub_assign(rhs);
1362 }
1363}
1364
1365impl SubAssign<&u16> for U16Vec4 {
1366 #[inline]
1367 fn sub_assign(&mut self, rhs: &u16) {
1368 self.sub_assign(*rhs)
1369 }
1370}
1371
1372impl Sub<U16Vec4> for u16 {
1373 type Output = U16Vec4;
1374 #[inline]
1375 fn sub(self, rhs: U16Vec4) -> U16Vec4 {
1376 U16Vec4 {
1377 x: self.sub(rhs.x),
1378 y: self.sub(rhs.y),
1379 z: self.sub(rhs.z),
1380 w: self.sub(rhs.w),
1381 }
1382 }
1383}
1384
1385impl Sub<&U16Vec4> for u16 {
1386 type Output = U16Vec4;
1387 #[inline]
1388 fn sub(self, rhs: &U16Vec4) -> U16Vec4 {
1389 self.sub(*rhs)
1390 }
1391}
1392
1393impl Sub<&U16Vec4> for &u16 {
1394 type Output = U16Vec4;
1395 #[inline]
1396 fn sub(self, rhs: &U16Vec4) -> U16Vec4 {
1397 (*self).sub(*rhs)
1398 }
1399}
1400
1401impl Sub<U16Vec4> for &u16 {
1402 type Output = U16Vec4;
1403 #[inline]
1404 fn sub(self, rhs: U16Vec4) -> U16Vec4 {
1405 (*self).sub(rhs)
1406 }
1407}
1408
1409impl Rem<U16Vec4> for U16Vec4 {
1410 type Output = Self;
1411 #[inline]
1412 fn rem(self, rhs: Self) -> Self {
1413 Self {
1414 x: self.x.rem(rhs.x),
1415 y: self.y.rem(rhs.y),
1416 z: self.z.rem(rhs.z),
1417 w: self.w.rem(rhs.w),
1418 }
1419 }
1420}
1421
1422impl Rem<&U16Vec4> for U16Vec4 {
1423 type Output = U16Vec4;
1424 #[inline]
1425 fn rem(self, rhs: &U16Vec4) -> U16Vec4 {
1426 self.rem(*rhs)
1427 }
1428}
1429
1430impl Rem<&U16Vec4> for &U16Vec4 {
1431 type Output = U16Vec4;
1432 #[inline]
1433 fn rem(self, rhs: &U16Vec4) -> U16Vec4 {
1434 (*self).rem(*rhs)
1435 }
1436}
1437
1438impl Rem<U16Vec4> for &U16Vec4 {
1439 type Output = U16Vec4;
1440 #[inline]
1441 fn rem(self, rhs: U16Vec4) -> U16Vec4 {
1442 (*self).rem(rhs)
1443 }
1444}
1445
1446impl RemAssign<U16Vec4> for U16Vec4 {
1447 #[inline]
1448 fn rem_assign(&mut self, rhs: Self) {
1449 self.x.rem_assign(rhs.x);
1450 self.y.rem_assign(rhs.y);
1451 self.z.rem_assign(rhs.z);
1452 self.w.rem_assign(rhs.w);
1453 }
1454}
1455
1456impl RemAssign<&U16Vec4> for U16Vec4 {
1457 #[inline]
1458 fn rem_assign(&mut self, rhs: &U16Vec4) {
1459 self.rem_assign(*rhs)
1460 }
1461}
1462
1463impl Rem<u16> for U16Vec4 {
1464 type Output = Self;
1465 #[inline]
1466 fn rem(self, rhs: u16) -> Self {
1467 Self {
1468 x: self.x.rem(rhs),
1469 y: self.y.rem(rhs),
1470 z: self.z.rem(rhs),
1471 w: self.w.rem(rhs),
1472 }
1473 }
1474}
1475
1476impl Rem<&u16> for U16Vec4 {
1477 type Output = U16Vec4;
1478 #[inline]
1479 fn rem(self, rhs: &u16) -> U16Vec4 {
1480 self.rem(*rhs)
1481 }
1482}
1483
1484impl Rem<&u16> for &U16Vec4 {
1485 type Output = U16Vec4;
1486 #[inline]
1487 fn rem(self, rhs: &u16) -> U16Vec4 {
1488 (*self).rem(*rhs)
1489 }
1490}
1491
1492impl Rem<u16> for &U16Vec4 {
1493 type Output = U16Vec4;
1494 #[inline]
1495 fn rem(self, rhs: u16) -> U16Vec4 {
1496 (*self).rem(rhs)
1497 }
1498}
1499
1500impl RemAssign<u16> for U16Vec4 {
1501 #[inline]
1502 fn rem_assign(&mut self, rhs: u16) {
1503 self.x.rem_assign(rhs);
1504 self.y.rem_assign(rhs);
1505 self.z.rem_assign(rhs);
1506 self.w.rem_assign(rhs);
1507 }
1508}
1509
1510impl RemAssign<&u16> for U16Vec4 {
1511 #[inline]
1512 fn rem_assign(&mut self, rhs: &u16) {
1513 self.rem_assign(*rhs)
1514 }
1515}
1516
1517impl Rem<U16Vec4> for u16 {
1518 type Output = U16Vec4;
1519 #[inline]
1520 fn rem(self, rhs: U16Vec4) -> U16Vec4 {
1521 U16Vec4 {
1522 x: self.rem(rhs.x),
1523 y: self.rem(rhs.y),
1524 z: self.rem(rhs.z),
1525 w: self.rem(rhs.w),
1526 }
1527 }
1528}
1529
1530impl Rem<&U16Vec4> for u16 {
1531 type Output = U16Vec4;
1532 #[inline]
1533 fn rem(self, rhs: &U16Vec4) -> U16Vec4 {
1534 self.rem(*rhs)
1535 }
1536}
1537
1538impl Rem<&U16Vec4> for &u16 {
1539 type Output = U16Vec4;
1540 #[inline]
1541 fn rem(self, rhs: &U16Vec4) -> U16Vec4 {
1542 (*self).rem(*rhs)
1543 }
1544}
1545
1546impl Rem<U16Vec4> for &u16 {
1547 type Output = U16Vec4;
1548 #[inline]
1549 fn rem(self, rhs: U16Vec4) -> U16Vec4 {
1550 (*self).rem(rhs)
1551 }
1552}
1553
1554#[cfg(not(target_arch = "spirv"))]
1555impl AsRef<[u16; 4]> for U16Vec4 {
1556 #[inline]
1557 fn as_ref(&self) -> &[u16; 4] {
1558 unsafe { &*(self as *const U16Vec4 as *const [u16; 4]) }
1559 }
1560}
1561
1562#[cfg(not(target_arch = "spirv"))]
1563impl AsMut<[u16; 4]> for U16Vec4 {
1564 #[inline]
1565 fn as_mut(&mut self) -> &mut [u16; 4] {
1566 unsafe { &mut *(self as *mut U16Vec4 as *mut [u16; 4]) }
1567 }
1568}
1569
1570impl Sum for U16Vec4 {
1571 #[inline]
1572 fn sum<I>(iter: I) -> Self
1573 where
1574 I: Iterator<Item = Self>,
1575 {
1576 iter.fold(Self::ZERO, Self::add)
1577 }
1578}
1579
1580impl<'a> Sum<&'a Self> for U16Vec4 {
1581 #[inline]
1582 fn sum<I>(iter: I) -> Self
1583 where
1584 I: Iterator<Item = &'a Self>,
1585 {
1586 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1587 }
1588}
1589
1590impl Product for U16Vec4 {
1591 #[inline]
1592 fn product<I>(iter: I) -> Self
1593 where
1594 I: Iterator<Item = Self>,
1595 {
1596 iter.fold(Self::ONE, Self::mul)
1597 }
1598}
1599
1600impl<'a> Product<&'a Self> for U16Vec4 {
1601 #[inline]
1602 fn product<I>(iter: I) -> Self
1603 where
1604 I: Iterator<Item = &'a Self>,
1605 {
1606 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1607 }
1608}
1609
1610impl Not for U16Vec4 {
1611 type Output = Self;
1612 #[inline]
1613 fn not(self) -> Self::Output {
1614 Self {
1615 x: self.x.not(),
1616 y: self.y.not(),
1617 z: self.z.not(),
1618 w: self.w.not(),
1619 }
1620 }
1621}
1622
1623impl BitAnd for U16Vec4 {
1624 type Output = Self;
1625 #[inline]
1626 fn bitand(self, rhs: Self) -> Self::Output {
1627 Self {
1628 x: self.x.bitand(rhs.x),
1629 y: self.y.bitand(rhs.y),
1630 z: self.z.bitand(rhs.z),
1631 w: self.w.bitand(rhs.w),
1632 }
1633 }
1634}
1635
1636impl BitOr for U16Vec4 {
1637 type Output = Self;
1638 #[inline]
1639 fn bitor(self, rhs: Self) -> Self::Output {
1640 Self {
1641 x: self.x.bitor(rhs.x),
1642 y: self.y.bitor(rhs.y),
1643 z: self.z.bitor(rhs.z),
1644 w: self.w.bitor(rhs.w),
1645 }
1646 }
1647}
1648
1649impl BitXor for U16Vec4 {
1650 type Output = Self;
1651 #[inline]
1652 fn bitxor(self, rhs: Self) -> Self::Output {
1653 Self {
1654 x: self.x.bitxor(rhs.x),
1655 y: self.y.bitxor(rhs.y),
1656 z: self.z.bitxor(rhs.z),
1657 w: self.w.bitxor(rhs.w),
1658 }
1659 }
1660}
1661
1662impl BitAnd<u16> for U16Vec4 {
1663 type Output = Self;
1664 #[inline]
1665 fn bitand(self, rhs: u16) -> Self::Output {
1666 Self {
1667 x: self.x.bitand(rhs),
1668 y: self.y.bitand(rhs),
1669 z: self.z.bitand(rhs),
1670 w: self.w.bitand(rhs),
1671 }
1672 }
1673}
1674
1675impl BitOr<u16> for U16Vec4 {
1676 type Output = Self;
1677 #[inline]
1678 fn bitor(self, rhs: u16) -> Self::Output {
1679 Self {
1680 x: self.x.bitor(rhs),
1681 y: self.y.bitor(rhs),
1682 z: self.z.bitor(rhs),
1683 w: self.w.bitor(rhs),
1684 }
1685 }
1686}
1687
1688impl BitXor<u16> for U16Vec4 {
1689 type Output = Self;
1690 #[inline]
1691 fn bitxor(self, rhs: u16) -> Self::Output {
1692 Self {
1693 x: self.x.bitxor(rhs),
1694 y: self.y.bitxor(rhs),
1695 z: self.z.bitxor(rhs),
1696 w: self.w.bitxor(rhs),
1697 }
1698 }
1699}
1700
1701impl Shl<i8> for U16Vec4 {
1702 type Output = Self;
1703 #[inline]
1704 fn shl(self, rhs: i8) -> Self::Output {
1705 Self {
1706 x: self.x.shl(rhs),
1707 y: self.y.shl(rhs),
1708 z: self.z.shl(rhs),
1709 w: self.w.shl(rhs),
1710 }
1711 }
1712}
1713
1714impl Shr<i8> for U16Vec4 {
1715 type Output = Self;
1716 #[inline]
1717 fn shr(self, rhs: i8) -> Self::Output {
1718 Self {
1719 x: self.x.shr(rhs),
1720 y: self.y.shr(rhs),
1721 z: self.z.shr(rhs),
1722 w: self.w.shr(rhs),
1723 }
1724 }
1725}
1726
1727impl Shl<i16> for U16Vec4 {
1728 type Output = Self;
1729 #[inline]
1730 fn shl(self, rhs: i16) -> Self::Output {
1731 Self {
1732 x: self.x.shl(rhs),
1733 y: self.y.shl(rhs),
1734 z: self.z.shl(rhs),
1735 w: self.w.shl(rhs),
1736 }
1737 }
1738}
1739
1740impl Shr<i16> for U16Vec4 {
1741 type Output = Self;
1742 #[inline]
1743 fn shr(self, rhs: i16) -> Self::Output {
1744 Self {
1745 x: self.x.shr(rhs),
1746 y: self.y.shr(rhs),
1747 z: self.z.shr(rhs),
1748 w: self.w.shr(rhs),
1749 }
1750 }
1751}
1752
1753impl Shl<i32> for U16Vec4 {
1754 type Output = Self;
1755 #[inline]
1756 fn shl(self, rhs: i32) -> Self::Output {
1757 Self {
1758 x: self.x.shl(rhs),
1759 y: self.y.shl(rhs),
1760 z: self.z.shl(rhs),
1761 w: self.w.shl(rhs),
1762 }
1763 }
1764}
1765
1766impl Shr<i32> for U16Vec4 {
1767 type Output = Self;
1768 #[inline]
1769 fn shr(self, rhs: i32) -> Self::Output {
1770 Self {
1771 x: self.x.shr(rhs),
1772 y: self.y.shr(rhs),
1773 z: self.z.shr(rhs),
1774 w: self.w.shr(rhs),
1775 }
1776 }
1777}
1778
1779impl Shl<i64> for U16Vec4 {
1780 type Output = Self;
1781 #[inline]
1782 fn shl(self, rhs: i64) -> Self::Output {
1783 Self {
1784 x: self.x.shl(rhs),
1785 y: self.y.shl(rhs),
1786 z: self.z.shl(rhs),
1787 w: self.w.shl(rhs),
1788 }
1789 }
1790}
1791
1792impl Shr<i64> for U16Vec4 {
1793 type Output = Self;
1794 #[inline]
1795 fn shr(self, rhs: i64) -> Self::Output {
1796 Self {
1797 x: self.x.shr(rhs),
1798 y: self.y.shr(rhs),
1799 z: self.z.shr(rhs),
1800 w: self.w.shr(rhs),
1801 }
1802 }
1803}
1804
1805impl Shl<u8> for U16Vec4 {
1806 type Output = Self;
1807 #[inline]
1808 fn shl(self, rhs: u8) -> Self::Output {
1809 Self {
1810 x: self.x.shl(rhs),
1811 y: self.y.shl(rhs),
1812 z: self.z.shl(rhs),
1813 w: self.w.shl(rhs),
1814 }
1815 }
1816}
1817
1818impl Shr<u8> for U16Vec4 {
1819 type Output = Self;
1820 #[inline]
1821 fn shr(self, rhs: u8) -> Self::Output {
1822 Self {
1823 x: self.x.shr(rhs),
1824 y: self.y.shr(rhs),
1825 z: self.z.shr(rhs),
1826 w: self.w.shr(rhs),
1827 }
1828 }
1829}
1830
1831impl Shl<u16> for U16Vec4 {
1832 type Output = Self;
1833 #[inline]
1834 fn shl(self, rhs: u16) -> Self::Output {
1835 Self {
1836 x: self.x.shl(rhs),
1837 y: self.y.shl(rhs),
1838 z: self.z.shl(rhs),
1839 w: self.w.shl(rhs),
1840 }
1841 }
1842}
1843
1844impl Shr<u16> for U16Vec4 {
1845 type Output = Self;
1846 #[inline]
1847 fn shr(self, rhs: u16) -> Self::Output {
1848 Self {
1849 x: self.x.shr(rhs),
1850 y: self.y.shr(rhs),
1851 z: self.z.shr(rhs),
1852 w: self.w.shr(rhs),
1853 }
1854 }
1855}
1856
1857impl Shl<u32> for U16Vec4 {
1858 type Output = Self;
1859 #[inline]
1860 fn shl(self, rhs: u32) -> Self::Output {
1861 Self {
1862 x: self.x.shl(rhs),
1863 y: self.y.shl(rhs),
1864 z: self.z.shl(rhs),
1865 w: self.w.shl(rhs),
1866 }
1867 }
1868}
1869
1870impl Shr<u32> for U16Vec4 {
1871 type Output = Self;
1872 #[inline]
1873 fn shr(self, rhs: u32) -> Self::Output {
1874 Self {
1875 x: self.x.shr(rhs),
1876 y: self.y.shr(rhs),
1877 z: self.z.shr(rhs),
1878 w: self.w.shr(rhs),
1879 }
1880 }
1881}
1882
1883impl Shl<u64> for U16Vec4 {
1884 type Output = Self;
1885 #[inline]
1886 fn shl(self, rhs: u64) -> Self::Output {
1887 Self {
1888 x: self.x.shl(rhs),
1889 y: self.y.shl(rhs),
1890 z: self.z.shl(rhs),
1891 w: self.w.shl(rhs),
1892 }
1893 }
1894}
1895
1896impl Shr<u64> for U16Vec4 {
1897 type Output = Self;
1898 #[inline]
1899 fn shr(self, rhs: u64) -> Self::Output {
1900 Self {
1901 x: self.x.shr(rhs),
1902 y: self.y.shr(rhs),
1903 z: self.z.shr(rhs),
1904 w: self.w.shr(rhs),
1905 }
1906 }
1907}
1908
1909impl Shl<crate::IVec4> for U16Vec4 {
1910 type Output = Self;
1911 #[inline]
1912 fn shl(self, rhs: crate::IVec4) -> Self::Output {
1913 Self {
1914 x: self.x.shl(rhs.x),
1915 y: self.y.shl(rhs.y),
1916 z: self.z.shl(rhs.z),
1917 w: self.w.shl(rhs.w),
1918 }
1919 }
1920}
1921
1922impl Shr<crate::IVec4> for U16Vec4 {
1923 type Output = Self;
1924 #[inline]
1925 fn shr(self, rhs: crate::IVec4) -> Self::Output {
1926 Self {
1927 x: self.x.shr(rhs.x),
1928 y: self.y.shr(rhs.y),
1929 z: self.z.shr(rhs.z),
1930 w: self.w.shr(rhs.w),
1931 }
1932 }
1933}
1934
1935impl Shl<crate::UVec4> for U16Vec4 {
1936 type Output = Self;
1937 #[inline]
1938 fn shl(self, rhs: crate::UVec4) -> Self::Output {
1939 Self {
1940 x: self.x.shl(rhs.x),
1941 y: self.y.shl(rhs.y),
1942 z: self.z.shl(rhs.z),
1943 w: self.w.shl(rhs.w),
1944 }
1945 }
1946}
1947
1948impl Shr<crate::UVec4> for U16Vec4 {
1949 type Output = Self;
1950 #[inline]
1951 fn shr(self, rhs: crate::UVec4) -> Self::Output {
1952 Self {
1953 x: self.x.shr(rhs.x),
1954 y: self.y.shr(rhs.y),
1955 z: self.z.shr(rhs.z),
1956 w: self.w.shr(rhs.w),
1957 }
1958 }
1959}
1960
1961impl Index<usize> for U16Vec4 {
1962 type Output = u16;
1963 #[inline]
1964 fn index(&self, index: usize) -> &Self::Output {
1965 match index {
1966 0 => &self.x,
1967 1 => &self.y,
1968 2 => &self.z,
1969 3 => &self.w,
1970 _ => panic!("index out of bounds"),
1971 }
1972 }
1973}
1974
1975impl IndexMut<usize> for U16Vec4 {
1976 #[inline]
1977 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1978 match index {
1979 0 => &mut self.x,
1980 1 => &mut self.y,
1981 2 => &mut self.z,
1982 3 => &mut self.w,
1983 _ => panic!("index out of bounds"),
1984 }
1985 }
1986}
1987
1988impl fmt::Display for U16Vec4 {
1989 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1990 write!(f, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w)
1991 }
1992}
1993
1994impl fmt::Debug for U16Vec4 {
1995 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1996 fmt.debug_tuple(stringify!(U16Vec4))
1997 .field(&self.x)
1998 .field(&self.y)
1999 .field(&self.z)
2000 .field(&self.w)
2001 .finish()
2002 }
2003}
2004
2005impl From<[u16; 4]> for U16Vec4 {
2006 #[inline]
2007 fn from(a: [u16; 4]) -> Self {
2008 Self::new(a[0], a[1], a[2], a[3])
2009 }
2010}
2011
2012impl From<U16Vec4> for [u16; 4] {
2013 #[inline]
2014 fn from(v: U16Vec4) -> Self {
2015 [v.x, v.y, v.z, v.w]
2016 }
2017}
2018
2019impl From<(u16, u16, u16, u16)> for U16Vec4 {
2020 #[inline]
2021 fn from(t: (u16, u16, u16, u16)) -> Self {
2022 Self::new(t.0, t.1, t.2, t.3)
2023 }
2024}
2025
2026impl From<U16Vec4> for (u16, u16, u16, u16) {
2027 #[inline]
2028 fn from(v: U16Vec4) -> Self {
2029 (v.x, v.y, v.z, v.w)
2030 }
2031}
2032
2033impl From<(U16Vec3, u16)> for U16Vec4 {
2034 #[inline]
2035 fn from((v, w): (U16Vec3, u16)) -> Self {
2036 Self::new(v.x, v.y, v.z, w)
2037 }
2038}
2039
2040impl From<(u16, U16Vec3)> for U16Vec4 {
2041 #[inline]
2042 fn from((x, v): (u16, U16Vec3)) -> Self {
2043 Self::new(x, v.x, v.y, v.z)
2044 }
2045}
2046
2047impl From<(U16Vec2, u16, u16)> for U16Vec4 {
2048 #[inline]
2049 fn from((v, z, w): (U16Vec2, u16, u16)) -> Self {
2050 Self::new(v.x, v.y, z, w)
2051 }
2052}
2053
2054impl From<(U16Vec2, U16Vec2)> for U16Vec4 {
2055 #[inline]
2056 fn from((v, u): (U16Vec2, U16Vec2)) -> Self {
2057 Self::new(v.x, v.y, u.x, u.y)
2058 }
2059}
2060
2061impl From<U8Vec4> for U16Vec4 {
2062 #[inline]
2063 fn from(v: U8Vec4) -> Self {
2064 Self::new(
2065 u16::from(v.x),
2066 u16::from(v.y),
2067 u16::from(v.z),
2068 u16::from(v.w),
2069 )
2070 }
2071}
2072
2073impl TryFrom<I8Vec4> for U16Vec4 {
2074 type Error = core::num::TryFromIntError;
2075
2076 #[inline]
2077 fn try_from(v: I8Vec4) -> Result<Self, Self::Error> {
2078 Ok(Self::new(
2079 u16::try_from(v.x)?,
2080 u16::try_from(v.y)?,
2081 u16::try_from(v.z)?,
2082 u16::try_from(v.w)?,
2083 ))
2084 }
2085}
2086
2087impl TryFrom<I16Vec4> for U16Vec4 {
2088 type Error = core::num::TryFromIntError;
2089
2090 #[inline]
2091 fn try_from(v: I16Vec4) -> Result<Self, Self::Error> {
2092 Ok(Self::new(
2093 u16::try_from(v.x)?,
2094 u16::try_from(v.y)?,
2095 u16::try_from(v.z)?,
2096 u16::try_from(v.w)?,
2097 ))
2098 }
2099}
2100
2101impl TryFrom<IVec4> for U16Vec4 {
2102 type Error = core::num::TryFromIntError;
2103
2104 #[inline]
2105 fn try_from(v: IVec4) -> Result<Self, Self::Error> {
2106 Ok(Self::new(
2107 u16::try_from(v.x)?,
2108 u16::try_from(v.y)?,
2109 u16::try_from(v.z)?,
2110 u16::try_from(v.w)?,
2111 ))
2112 }
2113}
2114
2115impl TryFrom<UVec4> for U16Vec4 {
2116 type Error = core::num::TryFromIntError;
2117
2118 #[inline]
2119 fn try_from(v: UVec4) -> Result<Self, Self::Error> {
2120 Ok(Self::new(
2121 u16::try_from(v.x)?,
2122 u16::try_from(v.y)?,
2123 u16::try_from(v.z)?,
2124 u16::try_from(v.w)?,
2125 ))
2126 }
2127}
2128
2129impl TryFrom<I64Vec4> for U16Vec4 {
2130 type Error = core::num::TryFromIntError;
2131
2132 #[inline]
2133 fn try_from(v: I64Vec4) -> Result<Self, Self::Error> {
2134 Ok(Self::new(
2135 u16::try_from(v.x)?,
2136 u16::try_from(v.y)?,
2137 u16::try_from(v.z)?,
2138 u16::try_from(v.w)?,
2139 ))
2140 }
2141}
2142
2143impl TryFrom<U64Vec4> for U16Vec4 {
2144 type Error = core::num::TryFromIntError;
2145
2146 #[inline]
2147 fn try_from(v: U64Vec4) -> Result<Self, Self::Error> {
2148 Ok(Self::new(
2149 u16::try_from(v.x)?,
2150 u16::try_from(v.y)?,
2151 u16::try_from(v.z)?,
2152 u16::try_from(v.w)?,
2153 ))
2154 }
2155}
2156
2157impl TryFrom<USizeVec4> for U16Vec4 {
2158 type Error = core::num::TryFromIntError;
2159
2160 #[inline]
2161 fn try_from(v: USizeVec4) -> Result<Self, Self::Error> {
2162 Ok(Self::new(
2163 u16::try_from(v.x)?,
2164 u16::try_from(v.y)?,
2165 u16::try_from(v.z)?,
2166 u16::try_from(v.w)?,
2167 ))
2168 }
2169}
2170
2171impl From<BVec4> for U16Vec4 {
2172 #[inline]
2173 fn from(v: BVec4) -> Self {
2174 Self::new(
2175 u16::from(v.x),
2176 u16::from(v.y),
2177 u16::from(v.z),
2178 u16::from(v.w),
2179 )
2180 }
2181}
2182
2183#[cfg(not(feature = "scalar-math"))]
2184impl From<BVec4A> for U16Vec4 {
2185 #[inline]
2186 fn from(v: BVec4A) -> Self {
2187 let bool_array: [bool; 4] = v.into();
2188 Self::new(
2189 u16::from(bool_array[0]),
2190 u16::from(bool_array[1]),
2191 u16::from(bool_array[2]),
2192 u16::from(bool_array[3]),
2193 )
2194 }
2195}