glam/i16/
i16vec4.rs

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