Debian Codegraph @

debian/missing-sources/glam-0.20.5/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 Neg for $matn {
43 type Output = Self;
44 #[inline(always)]
45 fn neg(self) -> Self::Output {
46 Self(self.0.neg_matrix())
47 }
48 }
49
50 impl Mul<$matn> for $matn {
51 type Output = Self;
52 #[inline(always)]
53 fn mul(self, other: Self) -> Self::Output {
54 Self(self.0.mul_matrix(&other.0))
55 }
56 }
57
58 impl MulAssign<$matn> for $matn {
59 #[inline(always)]
60 fn mul_assign(&mut self, other: Self) {
61 self.0 = self.0.mul_matrix(&other.0);
62 }
63 }
64
65 impl Mul<$vecn> for $matn {
66 type Output = $vecn;
67 #[inline(always)]
68 fn mul(self, other: $vecn) -> Self::Output {
69 $vecn(self.0.mul_vector(other.0))
70 }
71 }
72
73 impl Mul<$matn> for $t {
74 type Output = $matn;
75 #[inline(always)]
76 fn mul(self, other: $matn) -> Self::Output {
77 $matn(other.0.mul_scalar(self))
78 }
79 }
80
81 impl Mul<$t> for $matn {
82 type Output = Self;
83 #[inline(always)]
84 fn mul(self, other: $t) -> Self::Output {
85 Self(self.0.mul_scalar(other))
86 }
87 }
88
89 impl MulAssign<$t> for $matn {
90 #[inline(always)]
91 fn mul_assign(&mut self, other: $t) {
92 self.0 = self.0.mul_scalar(other);
93 }
94 }
95
96 impl<'a> Sum<&'a Self> for $matn {
97 fn sum<I>(iter: I) -> Self
98 where
99 I: Iterator<Item = &'a Self>,
100 {
101 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
102 }
103 }
104
105 impl<'a> Product<&'a Self> for $matn {
106 fn product<I>(iter: I) -> Self
107 where
108 I: Iterator<Item = &'a Self>,
109 {
110 iter.fold(Self::IDENTITY, |a, &b| Self::mul(a, b))
111 }
112 }
113 };
114 }