-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmathx.logic.byte.cs
225 lines (197 loc) · 15.1 KB
/
mathx.logic.byte.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#region Header
// ** Copyright (C) 2023 Nicolas Reinhard, @LTMX. All rights reserved.
// ** Github Profile: https://github.com/LTMX
// ** Repository : https://github.com/LTMX/Unity.mathx
#endregion
using MI = System.Runtime.CompilerServices.MethodImplAttribute;
namespace Unity.Mathematics
{
public static partial class mathx
{
/// Returns true if a is odd
[MI(IL)] public static bool odd(this byte a) => (a & 1) != 0; // 12% faster than a % 2 == 1
/// Returns true if a is odd component-wise
[MI(IL)] public static bool2 odd(this byte2 a) => (a & 1) != 0;
/// Returns true if a is odd component-wise
[MI(IL)] public static bool3 odd(this byte3 a) => (a & 1) != 0;
/// Returns true if a is odd component-wise
[MI(IL)] public static bool4 odd(this byte4 a) => (a & 1) != 0;
/// Returns true if a is even
[MI(IL)] public static bool even(this byte a) => (a & 1) != 1; // 12% faster than a % 2 == 0
/// Returns true if a is even component-wise
[MI(IL)] public static bool2 even(this byte2 a) => (a & 1) != 1;
/// Returns true if a is even component-wise
[MI(IL)] public static bool3 even(this byte3 a) => (a & 1) != 1;
/// Returns true if a is even component-wise
[MI(IL)] public static bool4 even(this byte4 a) => (a & 1) != 1;
// Node : Bytes are never NAN, and Never Infinite... these methods are reserved to floating point numbers
/// returns true component-wise if the any component is greater to the other value, otherwise false
[MI(IL)] public static bool4 greater(this byte4 f, byte value) => f > value;
/// <inheritdoc cref="greater(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 greater(this byte3 f, byte value) => f > value;
/// <inheritdoc cref="greater(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 greater(this byte2 f, byte value) => f > value;
/// <inheritdoc cref="greater(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool greater(this byte f, byte value) => f > value;
/// <inheritdoc cref="greater(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool4 greater(this byte4 f, byte4 value) => f > value;
/// <inheritdoc cref="greater(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 greater(this byte3 f, byte3 value) => f > value;
/// <inheritdoc cref="greater(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 greater(this byte2 f, byte2 value) => f > value;
/// returns true component-wise if the any component is less to the other value, otherwise false
[MI(IL)] public static bool4 less(this byte4 f, byte value) => f < value;
/// <inheritdoc cref="less(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 less(this byte3 f, byte value) => f < value;
/// <inheritdoc cref="less(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 less(this byte2 f, byte value) => f < value;
/// <inheritdoc cref="less(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool less(this byte f, byte value) => f < value;
/// <inheritdoc cref="less(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool4 less(this byte4 f, byte4 value) => f < value;
/// <inheritdoc cref="less(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 less(this byte3 f, byte3 value) => f < value;
/// <inheritdoc cref="less(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 less(this byte2 f, byte2 value) => f < value;
/// returns true component-wise if the any component is less or equal to the other value, otherwise false
[MI(IL)] public static bool4 lesseq(this byte4 f, byte value) => f <= value;
/// <inheritdoc cref="lesseq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 lesseq(this byte3 f, byte value) => f <= value;
/// <inheritdoc cref="lesseq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 lesseq(this byte2 f, byte value) => f <= value;
/// <inheritdoc cref="lesseq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool lesseq(this byte f, byte value) => f <= value;
/// <inheritdoc cref="lesseq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool4 lesseq(this byte4 f, byte4 value) => f <= value;
/// <inheritdoc cref="lesseq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 lesseq(this byte3 f, byte3 value) => f <= value;
/// <inheritdoc cref="lesseq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 lesseq(this byte2 f, byte2 value) => f <= value;
/// returns true component-wise if the any component is greater or equal to the other value, otherwise false
[MI(IL)] public static bool4 greatereq(this byte4 f, byte value) => f >= value;
/// <inheritdoc cref="greatereq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 greatereq(this byte3 f, byte value) => f >= value;
/// <inheritdoc cref="greatereq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 greatereq(this byte2 f, byte value) => f >= value;
/// <inheritdoc cref="greatereq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool greatereq(this byte f, byte value) => f >= value;
/// <inheritdoc cref="greatereq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool4 greatereq(this byte4 f, byte4 value) => f >= value;
/// <inheritdoc cref="greatereq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 greatereq(this byte3 f, byte3 value) => f >= value;
/// <inheritdoc cref="greatereq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 greatereq(this byte2 f, byte2 value) => f >= value;
/// returns true component-wise if the any component is equal to the other value, otherwise false
[MI(IL)] public static bool4 eq(this byte4 f, byte value) => f == value;
/// <inheritdoc cref="eq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 eq(this byte3 f, byte value) => f == value;
/// <inheritdoc cref="eq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 eq(this byte2 f, byte value) => f == value;
/// <inheritdoc cref="eq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool eq(this byte f, byte value) => f == value;
/// <inheritdoc cref="eq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool4 eq(this byte4 f, byte4 value) => f == value;
/// <inheritdoc cref="eq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 eq(this byte3 f, byte3 value) => f == value;
/// <inheritdoc cref="eq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 eq(this byte2 f, byte2 value) => f == value;
/// returns true component-wise if the any component is not equal to the other value, otherwise false
[MI(IL)] public static bool4 neq(this byte4 f, byte value) => f != value;
/// <inheritdoc cref="neq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 neq(this byte3 f, byte value) => f != value;
/// <inheritdoc cref="neq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 neq(this byte2 f, byte value) => f != value;
/// <inheritdoc cref="neq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool neq(this byte f, byte value) => f != value;
/// <inheritdoc cref="neq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool4 neq(this byte4 f, byte4 value) => f != value;
/// <inheritdoc cref="neq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool3 neq(this byte3 f, byte3 value) => f != value;
/// <inheritdoc cref="neq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool2 neq(this byte2 f, byte2 value) => f != value;
/// returns true if the any component is greater to the other value, otherwise false
[MI(IL)] public static bool anygreater(this byte4 f, byte v) => f.x > v || f.y > v || f.z > v || f.w > v;
/// <inheritdoc cref="anygreater(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anygreater(this byte3 f, byte v) => f.x > v || f.y > v || f.z > v;
/// <inheritdoc cref="anygreater(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anygreater(this byte2 f, byte v) => f.x > v || f.y > v;
/// <inheritdoc cref="anygreater(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anygreater(this byte4 f, byte4 v) => f.x > v.x || f.y > v.y || f.z > v.z || f.z > v.z || f.w > v.w;
/// <inheritdoc cref="anygreater(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anygreater(this byte3 f, byte3 v) => f.x > v.x || f.y > v.y || f.z > v.z || f.z > v.z;
/// <inheritdoc cref="anygreater(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anygreater(this byte2 f, byte2 v) => f.x > v.x || f.y > v.y;
/// returns true if the any component is greater or equal to the other value, otherwise false
[MI(IL)] public static bool anygreatereq(this byte4 f, byte v) => f.x >= v || f.y >= v || f.z >= v || f.w >= v;
/// <inheritdoc cref="anygreatereq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anygreatereq(this byte3 f, byte v) => f.x >= v || f.y >= v || f.z >= v;
/// <inheritdoc cref="anygreatereq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anygreatereq(this byte2 f, byte v) => f.x >= v || f.y >= v;
/// <inheritdoc cref="anygreatereq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anygreatereq(this byte4 f, byte4 v) => f.x >= v.x || f.y >= v.y || f.z >= v.z || f.w >= v.w;
/// <inheritdoc cref="anygreatereq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anygreatereq(this byte3 f, byte3 v) => f.x >= v.x || f.y >= v.y || f.z >= v.z;
/// <inheritdoc cref="anygreatereq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anygreatereq(this byte2 f, byte2 v) => f.x >= v.x || f.y >= v.y;
/// returns true if the any component is less to the other value, otherwise false
[MI(IL)] public static bool anyless(this byte4 f, byte v) => f.x < v || f.y < v || f.z < v || f.w < v;
/// <inheritdoc cref="anyless(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyless(this byte3 f, byte v) => f.x < v || f.y < v || f.z < v;
/// <inheritdoc cref="anyless(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyless(this byte2 f, byte v) => f.x < v || f.y < v;
/// <inheritdoc cref="anyless(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyless(this byte4 f, byte4 v) => f.x < v.x || f.y < v.y || f.z < v.z || f.w < v.w;
/// <inheritdoc cref="anyless(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyless(this byte3 f, byte3 v) => f.x < v.x || f.y < v.y || f.z < v.z;
/// <inheritdoc cref="anyless(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyless(this byte2 f, byte2 v) => f.x < v.x || f.y < v.y;
/// returns true if the any component is less or equal to the other value, otherwise false
[MI(IL)] public static bool anylesseq(this byte4 f, byte v) => f.x <= v || f.y <= v || f.z <= v || f.w <= v;
/// <inheritdoc cref="anylesseq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anylesseq(this byte3 f, byte v) => f.x <= v || f.y <= v || f.z <= v;
/// <inheritdoc cref="anylesseq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anylesseq(this byte2 f, byte v) => f.x <= v || f.y <= v;
/// <inheritdoc cref="anylesseq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anylesseq(this byte4 f, byte4 v) => f.x <= v.x || f.y <= v.y || f.z <= v.z || f.w <= v.w;
/// <inheritdoc cref="anylesseq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anylesseq(this byte3 f, byte3 v) => f.x <= v.x || f.y <= v.y || f.z <= v.z;
/// <inheritdoc cref="anylesseq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anylesseq(this byte2 f, byte2 v) => f.x <= v.x || f.y <= v.y;
/// returns true if the any component is equal to the other value, otherwise false
[MI(IL)] public static bool anyeq(this byte4 f, byte v) => f.x == v || f.y == v || f.z == v || f.w == v;
/// <inheritdoc cref="anyeq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyeq(this byte3 f, byte v) => f.x == v || f.y == v || f.z == v;
/// <inheritdoc cref="anyeq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyeq(this byte2 f, byte v) => f.x == v || f.y == v;
/// <inheritdoc cref="anyeq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyeq(this byte4 f, byte4 v) => f.x == v.x || f.y == v.y || f.z == v.z || f.w == v.w;
/// <inheritdoc cref="anyeq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyeq(this byte3 f, byte3 v) => f.x == v.x || f.y == v.y || f.z == v.z;
/// <inheritdoc cref="anyeq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyeq(this byte2 f, byte2 v) => f.x == v.x || f.y == v.y;
/// returns true if the any component is not equal to the other value, otherwise false
[MI(IL)] public static bool anyneq(this byte4 f, byte v) => f.x != v || f.y != v || f.z != v || f.w != v;
/// <inheritdoc cref="anyneq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyneq(this byte3 f, byte v) => f.x != v || f.y != v || f.z != v;
/// <inheritdoc cref="anyneq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyneq(this byte2 f, byte v) => f.x != v || f.y != v;
/// <inheritdoc cref="anyneq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyneq(this byte4 f, byte4 v) => f.x != v.x || f.y != v.y || f.z != v.z || f.w != v.w;
/// <inheritdoc cref="anyneq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyneq(this byte3 f, byte3 v) => f.x != v.x || f.y != v.y || f.z != v.z;
/// <inheritdoc cref="anyneq(Mathematics.byte4,byte)"/>
[MI(IL)] public static bool anyneq(this byte2 f, byte2 v) => f.x != v.x || f.y != v.y;
/// Returns 1 inside the longest(s) axis(es) and 0 in the others
[MI(IL)] public static bool4 isgreatest(this byte4 f) => f == f.cmax();
/// <inheritdoc cref="isgreatest(Mathematics.byte4)"/>
[MI(IL)] public static bool3 isgreatest(this byte3 f) => f == f.cmax();
/// <inheritdoc cref="isgreatest(Mathematics.byte4)"/>
[MI(IL)] public static bool2 isgreatest(this byte2 f) => f == f.cmax();
/// Returns true inside the shortest axes
[MI(IL)] public static bool4 isshortest(this byte4 f) => f == f.cmin();
/// <inheritdoc cref="isshortest(Mathematics.byte4)"/>
[MI(IL)] public static bool3 isshortest(this byte3 f) => f == f.cmin();
/// <inheritdoc cref="isshortest(Mathematics.byte4)"/>
[MI(IL)] public static bool2 isshortest(this byte2 f) => f == f.cmin();
}
}