Debian Codegraph @

debian/missing-sources/glam-0.18.0/src/mat.rs

raw symbols SCIP
1 // Adds common vector trait implementations.
2 // The traits here should be supported for all types of $t and all sizes of vector.
3 macro_rules! impl_matn_common_traits {
4 ($t:ty, $matn:ident, $vecn:ident) => {
5 impl Default for $matn {
6 #[inline(always)]
7 fn default() -> Self {
8 Self::IDENTITY
9 }
10 }
11
12 impl Add<$matn> for $matn {
13 type Output = Self;
14 #[inline(always)]
15 fn add(self, other: Self) -> Self::Output {
16 Self(self.0.add_matrix(&other.0))
17 }
18 }
19
20 impl AddAssign<$matn> for $matn {
21 #[inline(always)]
22 fn add_assign(&mut self, other: Self) {
23 self.0 = self.0.add_matrix(&other.0);
24 }
25 }
26
27 impl Sub<$matn> for $matn {
28 type Output = Self;
29 #[inline(always)]
30 fn sub(self, other: Self) -> Self::Output {
31 Self(self.0.sub_matrix(&other.0))
32 }
33 }
34
35 impl SubAssign<$matn> for $matn {
36 #[inline(always)]
37 fn sub_assign(&mut self, other: Self) {
38 self.0 = self.0.sub_matrix(&other.0);
39 }
40 }
41
42 impl Mul<$matn> for $matn {
43 type Output = Self;
44 #[inline(always)]
45 fn mul(self, other: Self) -> Self::Output {
46 Self(self.0.mul_matrix(&other.0))
47 }
48 }
49
50 impl MulAssign<$matn> for $matn {
51 #[inline(always)]
52 fn mul_assign(&mut self, other: Self) {
53 self.0 = self.0.mul_matrix(&other.0);
54 }
55 }
56
57 impl Mul<$vecn> for $matn {
58 type Output = $vecn;
59 #[inline(always)]
60 fn mul(self, other: $vecn) -> Self::Output {
61 $vecn(self.0.mul_vector(other.0))
62 }
63 }
64
65 impl Mul<$matn> for $t {
66 type Output = $matn;
67 #[inline(always)]
68 fn mul(self, other: $matn) -> Self::Output {
69 $matn(other.0.mul_scalar(self))
70 }
71 }
72
73 impl Mul<$t> for $matn {
74 type Output = Self;
75 #[inline(always)]
76 fn mul(self, other: $t) -> Self::Output {
77 Self(self.0.mul_scalar(other))
78 }
79 }
80
81 impl MulAssign<$t> for $matn {
82 #[inline(always)]
83 fn mul_assign(&mut self, other: $t) {
84 self.0 = self.0.mul_scalar(other);
85 }
86 }
87
88 #[cfg(feature = "std")]
89 impl<'a> Sum<&'a Self> for $matn {
90 fn sum<I>(iter: I) -> Self
91 where
92 I: Iterator<Item = &'a Self>,
93 {
94 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
95 }
96 }
97
98 #[cfg(feature = "std")]
99 impl<'a> Product<&'a Self> for $matn {
100 fn product<I>(iter: I) -> Self
101 where
102 I: Iterator<Item = &'a Self>,
103 {
104 iter.fold(Self::IDENTITY, |a, &b| Self::mul(a, b))
105 }
106 }
107 };
108 }