-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmathx.common.float.cs
478 lines (404 loc) · 23.8 KB
/
mathx.common.float.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
#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
{
#region sign
/// Returns the sign of the given value.
/// <remarks>
/// This implementation is 2.6x faster than math.sign.
/// </remarks>
[MI(IL)] public static float4 sign(this float4 f) => math.sign(f);
///<inheritdoc cref="sign(float4)"/>
[MI(IL)] public static float3 sign(this float3 f) => math.sign(f);
///<inheritdoc cref="sign(float4)"/>
[MI(IL)] public static float2 sign(this float2 f) => math.sign(f);
///<inheritdoc cref="sign(float4)"/>
[MI(IL)] public static float sign(this float f) => math.sign(f);
///<inheritdoc cref="math.chgsign(float4,float4)"/>
[MI(IL)] public static float4 chgsign(this float4 f, float4 y) => math.chgsign(f, y);
///<inheritdoc cref="math.chgsign(float3,float3)"/>
[MI(IL)] public static float3 chgsign(this float3 f, float3 y) => math.chgsign(f, y);
///<inheritdoc cref="math.chgsign(float2,float2)"/>
[MI(IL)] public static float2 chgsign(this float2 f, float2 y) => math.chgsign(f, y);
///<inheritdoc cref="math.chgsign(float,float)"/>
[MI(IL)] public static float chgsign(this float f, float y) => math.chgsign(f, y);
///<inheritdoc cref="math.chgsign(float4,float4)"/>
[MI(IL)] public static float4 chgsign(this float4 f, float y) => math.asfloat(math.asuint(f) ^ (math.asuint(y) & 0x80000000));
///<inheritdoc cref="math.chgsign(float3,float3)"/>
[MI(IL)] public static float3 chgsign(this float3 f, float y) => math.asfloat(math.asuint(f) ^ (math.asuint(y) & 0x80000000));
///<inheritdoc cref="math.chgsign(float2,float2)"/>
[MI(IL)] public static float2 chgsign(this float2 f, float y) => math.asfloat(math.asuint(f) ^ (math.asuint(y) & 0x80000000));
#endregion
#region abs
/// The component-wise absolute value of the input.
[MI(IL)] public static float4 abs(this float4 f) => math.abs(f);
/// <inheritdoc cref="abs(float4)"/>
[MI(IL)] public static float3 abs(this float3 f) => math.abs(f);
/// <inheritdoc cref="abs(float4)"/>
[MI(IL)] public static float2 abs(this float2 f) => math.abs(f);
/// <inheritdoc cref="abs(float4)"/>
[MI(IL)] public static float abs(this float f) => math.abs(f);
#endregion
#region mod
/// fast mod function
/// <remarks>
/// approx 5% faster than math.mod()
/// It is also exact for negative values of x;
/// </remarks>
[MI(IL)] public static float4 mod(this float4 f, float4 mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float3 mod(this float3 f, float3 mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float2 mod(this float2 f, float2 mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float mod(this float f, float mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float4 mod(this float4 f, int4 mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float3 mod(this float3 f, int3 mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float2 mod(this float2 f, int2 mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float mod(this float f, int mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float4 mod(this float4 f, float mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float3 mod(this float3 f, float mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float2 mod(this float2 f, float mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float4 mod(this float4 f, int mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float3 mod(this float3 f, int mod) => f % mod;
/// <inheritdoc cref="mod(float4, float4)"/>
[MI(IL)] public static float2 mod(this float2 f, int mod) => f % mod;
#endregion
#region frac
/// <summary>Returns the fractional part of a float value.</summary>
/// <remarks>Fractional Remainder (f - (int)f) is x3 faster than math.frac() (1.3.1)</remarks>
[MI(IL)] public static float4 frac(this float4 f) => f - (int4)f;
/// <inheritdoc cref="frac(float4)"/>
[MI(IL)] public static float3 frac(this float3 f) => f - (int3)f;
/// <inheritdoc cref="frac(float4)"/>
[MI(IL)] public static float2 frac(this float2 f) => f - (int2)f;
/// <inheritdoc cref="frac(float4)"/>
[MI(IL)] public static float frac(this float f) => f - (int)f;
#endregion
#region csum
/// Returns the csum of all components of the vector
[MI(IL)] public static float csum(this float4 f) => math.csum(f);
/// <inheritdoc cref="csum(float4)"/>
[MI(IL)] public static float csum(this float3 f) => math.csum(f);
/// <inheritdoc cref="csum(float4)"/>
[MI(IL)] public static float csum(this float2 f) => math.csum(f);
#endregion
#region cmul
/// Returns the product of all components of the vector
[MI(IL)] public static float cmul(this float4 f) => f.x * f.y * f.z * f.w;
/// <inheritdoc cref="cmul(float4)"/>
[MI(IL)] public static float cmul(this float3 f) => f.x * f.y * f.z;
/// <inheritdoc cref="cmul(float4)"/>
[MI(IL)] public static float cmul(this float2 f) => f.x * f.y;
#endregion
#region inv
/// Returns one minus the given value. => ex : color inversion
[MI(IL)] public static float4 inv(this float4 f) => 1 - f;
/// <inheritdoc cref="inv(float4)"/>
[MI(IL)] public static float3 inv(this float3 f) => 1 - f;
/// <inheritdoc cref="inv(float4)"/>
[MI(IL)] public static float2 inv(this float2 f) => 1 - f;
/// <inheritdoc cref="inv(float4)"/>
[MI(IL)] public static float inv(this float f) => 1 - f;
#endregion
#region neg
/// Returns the negation of the given value.
[MI(IL)] public static float4 neg(this float4 f) => -f;
/// <inheritdoc cref="neg(float4)"/>
[MI(IL)] public static float3 neg(this float3 f) => -f;
/// <inheritdoc cref="neg(float4)"/>
[MI(IL)] public static float2 neg(this float2 f) => -f;
/// <inheritdoc cref="neg(float4)"/>
[MI(IL)] public static float neg(this float f) => -f;
#endregion
#region rcp
/// Returns the componentwise reciprocal a vector.
[MI(IL)] public static float4 rcp(this float4 f) => math.rcp(f);
/// <inheritdoc cref="rcp(float4)"/>
[MI(IL)] public static float3 rcp(this float3 f) => math.rcp(f);
/// <inheritdoc cref="rcp(float4)"/>
[MI(IL)] public static float2 rcp(this float2 f) => math.rcp(f);
/// <inheritdoc cref="rcp(float4)"/>
[MI(IL)] public static float rcp(this float f) => math.rcp(f);
#endregion
#region pow
/// <summary>Returns the componentwise result of raising x to the power y.</summary>
[MI(IL)] public static float4 pow(this float4 f, float4 pow) => math.pow(f, pow);
/// <inheritdoc cref="pow(float4,float4)"/>
[MI(IL)] public static float3 pow(this float3 f, float3 y) => math.pow(f, y);
/// <inheritdoc cref="pow(float4,float4)"/>
[MI(IL)] public static float2 pow(this float2 f, float2 y) => math.pow(f, y);
/// <inheritdoc cref="pow(float4,float4)"/>
[MI(IL)] public static float pow(this float f, float y) => math.pow(f, y);
/// <inheritdoc cref="pow(float4,float4)"/>
[MI(IL)] public static float4 pow(this float4 f, float pow) => new(math.pow(f.x, pow), math.pow(f.y, pow), math.pow(f.z, pow), math.pow(f.w, pow));
/// <inheritdoc cref="pow(float4,float4)"/>
[MI(IL)] public static float3 pow(this float3 f, float y) => new(math.pow(f.x, y), math.pow(f.y, y), math.pow(f.z, y));
/// <inheritdoc cref="pow(float4,float4)"/>
[MI(IL)] public static float2 pow(this float2 f, float y) => new(math.pow(f.x, y), math.pow(f.y, y));
#endregion
#region sq
/// Returns x^2
[MI(IL)] public static float4 sq(this float4 f) => f * f;
/// <inheritdoc cref="sq(float4)"/>
[MI(IL)] public static float3 sq(this float3 f) => f * f;
/// <inheritdoc cref="sq(float4)"/>
[MI(IL)] public static float2 sq(this float2 f) => f * f;
/// <inheritdoc cref="sq(float4)"/>
[MI(IL)] public static float sq(this float f) => f * f;
#endregion
#region cube
/// <summary> Returns x^3 </summary>
[MI(IL)] public static float4 cube(this float4 f) => f * f * f;
/// <inheritdoc cref="cube(float4)"/>
[MI(IL)] public static float3 cube(this float3 f) => f * f * f;
/// <inheritdoc cref="cube(float4)"/>
[MI(IL)] public static float2 cube(this float2 f) => f * f * f;
/// <inheritdoc cref="cube(float4)"/>
[MI(IL)] public static float cube(this float f) => f * f * f;
#endregion
#region pow4
/// <summary> Returns x^4 </summary>
[MI(IL)] public static float4 pow4(this float4 f) => f.sq().sq();
/// <inheritdoc cref="pow4(float4)"/>
[MI(IL)] public static float3 pow4(this float3 f) => f.sq().sq();
/// <inheritdoc cref="pow4(float4)"/>
[MI(IL)] public static float2 pow4(this float2 f) => f.sq().sq();
/// <inheritdoc cref="pow4(float4)"/>
[MI(IL)] public static float pow4(this float f) => f.sq().sq();
#endregion
#region pow5
/// <summary> Returns x^5 </summary>
[MI(IL)] public static float4 pow5(this float4 f) => f.sq().sq() * f;
/// <inheritdoc cref="pow5(float4)" />
[MI(IL)] public static float3 pow5(this float3 f) => f.sq().sq() * f;
/// <inheritdoc cref="pow5(float4)" />
[MI(IL)] public static float2 pow5(this float2 f) => f.sq().sq() * f;
/// <inheritdoc cref="pow5(float4)" />
[MI(IL)] public static float pow5(this float f) => f.sq().sq() * f;
#endregion
#region saturate
/// <inheritdoc cref="math.saturate(float4)" />
[MI(IL)] public static float4 saturate(this float4 f) => math.saturate(f);
/// <inheritdoc cref="math.saturate(float3)" />
[MI(IL)] public static float3 saturate(this float3 f) => math.saturate(f);
/// <inheritdoc cref="math.saturate(float2)" />
[MI(IL)] public static float2 saturate(this float2 f) => math.saturate(f);
/// <inheritdoc cref="math.saturate(float)" />
[MI(IL)] public static float saturate(this float f) => math.saturate(f);
#endregion
#region snap
/// <summary> Rounds a value to the closest multiplier of snap. </summary>
[MI(IL)] public static float4 snap(this float4 x, float4 snap) => round(x / snap) * snap;
/// <inheritdoc cref="snap(float4,float4)" />
[MI(IL)] public static float4 snap(this float4 x, float snap) => round(x / snap) * snap;
/// <inheritdoc cref="snap(float4,float4)" />
[MI(IL)] public static float3 snap(this float3 x, float3 snap) => round(x / snap) * snap;
/// <inheritdoc cref="snap(float4,float4)" />
[MI(IL)] public static float3 snap(this float3 x, float snap) => round(x / snap) * snap;
/// <inheritdoc cref="snap(float4,float4)" />
[MI(IL)] public static float2 snap(this float2 x, float2 snap) => round(x / snap) * snap;
/// <inheritdoc cref="snap(float4,float4)" />
[MI(IL)] public static float2 snap(this float2 x, float snap) => round(x / snap) * snap;
/// <inheritdoc cref="snap(float4,float4)" />
[MI(IL)] public static float snap(this float x, float snap) => round(x / snap) * snap;
#endregion
#region bitwave
/// <summary> Samples a square wave that goes between 0 and 1. </summary>
[MI(IL)] public static float4 bitwave(this float4 x) => floor(math.fmod(x, 2));
/// <inheritdoc cref="bitwave(float4)" />
[MI(IL)] public static float3 bitwave(this float3 x) => floor(math.fmod(x, 2));
/// <inheritdoc cref="bitwave(float4)" />
[MI(IL)] public static float2 bitwave(this float2 x) => floor(math.fmod(x, 2));
/// <inheritdoc cref="bitwave(float4)" />
[MI(IL)] public static float bitwave(this float x) => floor(math.fmod(x, 2));
#endregion
#region bitwave
/// <summary> Samples a square wave that goes between 0 and 1. </summary>
[MI(IL)] public static float4 bitwave2(this float4 x) => (int4)x & 1;
/// <inheritdoc cref="bitwave2(float4)" />
[MI(IL)] public static float3 bitwave2(this float3 x) => (int3)x & 1;
/// <inheritdoc cref="bitwave2(float4)" />
[MI(IL)] public static float2 bitwave2(this float2 x) => (int2)x & 1;
/// <inheritdoc cref="bitwave2(float4)" />
[MI(IL)] public static float bitwave2(this float x) => (int)x & 1;
#endregion
#region triwave
/// <summary> Samples a triangle wave between +0.5f and -0.5f. </summary>
[MI(IL)] public static float4 triwave(this float4 x) => abs(frac(x) - 0.5f);
/// <inheritdoc cref="triwave(float4)" />
[MI(IL)] public static float3 triwave(this float3 x) => abs(frac(x) - 0.5f);
/// <inheritdoc cref="triwave(float4)" />
[MI(IL)] public static float2 triwave(this float2 x) => abs(frac(x) - 0.5f);
/// <inheritdoc cref="triwave(float4)" />
[MI(IL)] public static float triwave(this float x) => abs(frac(x) - 0.5f);
#endregion
#region Component-wise Math
/// <inheritdoc cref="math.sqrt(float4)"/>
[MI(IL)] public static float4 sqrt(this float4 f) => math.sqrt(f);
/// <inheritdoc cref="math.sqrt(float3)"/>
[MI(IL)] public static float3 sqrt(this float3 f) => math.sqrt(f);
/// <inheritdoc cref="math.sqrt(float2)"/>
[MI(IL)] public static float2 sqrt(this float2 f) => math.sqrt(f);
/// <inheritdoc cref="math.sqrt(float)"/>
[MI(IL)] public static float sqrt(this float f) => math.sqrt(f);
/// Cube Root Function
[MI(IL)] public static float4 cbrt(this float4 f) => f.sign() * f.abs().pow(THIRD);
/// <inheritdoc cref="cbrt(float4)"/>
[MI(IL)] public static float3 cbrt(this float3 f) => f.sign() * f.abs().pow(THIRD);
/// <inheritdoc cref="cbrt(float4)"/>
[MI(IL)] public static float2 cbrt(this float2 f) => f.sign() * f.abs().pow(THIRD);
/// <inheritdoc cref="cbrt(float4)"/>
[MI(IL)] public static float cbrt(this float f) => f.sign() * f.abs().pow(THIRD);
/// returns 1 / cbrt(f) : inverse Cube root
[MI(IL)] public static float4 rcbrt(this float4 f) => 1 / f.cbrt();
/// <inheritdoc cref="rcbrt(float4)"/>
[MI(IL)] public static float3 rcbrt(this float3 f) => 1 / f.cbrt();
/// <inheritdoc cref="rcbrt(float4)"/>
[MI(IL)] public static float2 rcbrt(this float2 f) => 1 / f.cbrt();
/// <inheritdoc cref="rcbrt(float4)"/>
[MI(IL)] public static float rcbrt(this float f) => 1 / f.cbrt();
/// <inheritdoc cref="math.rsqrt(float4)"/>
[MI(IL)] public static float4 rsqrt(this float4 f) => math.rsqrt(f);
/// <inheritdoc cref="math.rsqrt(float3)"/>
[MI(IL)] public static float3 rsqrt(this float3 f) => math.rsqrt(f);
/// <inheritdoc cref="math.rsqrt(float2)"/>
[MI(IL)] public static float2 rsqrt(this float2 f) => math.rsqrt(f);
/// <inheritdoc cref="math.rsqrt(float)"/>
[MI(IL)] public static float rsqrt(this float f) => math.rsqrt(f);
#endregion Component-wise Math
/// Returns input * 2 - 1
/// Effectively remaps the range [0, 1] to [-1, 1]
[MI(IL)] public static float m2n1(this float f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float2 m2n1(this float2 f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float3 m2n1(this float3 f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float4 m2n1(this float4 f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float2x2 m2n1(this float2x2 f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float2x3 m2n1(this float2x3 f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float2x4 m2n1(this float2x4 f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float3x2 m2n1(this float3x2 f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float3x3 m2n1(this float3x3 f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float3x4 m2n1(this float3x4 f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float4x2 m2n1(this float4x2 f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float4x3 m2n1(this float4x3 f) => f * 2 - 1;
/// <inheritdoc cref="m2n1(float)"/>
[MI(IL)] public static float4x4 m2n1(this float4x4 f) => f * 2 - 1;
/// Addition Operation
[MI(IL)] public static float add(this float x, float y) => x + y;
/// <inheritdoc cref="add(float, float)"/>
[MI(IL)] public static float2 add(this float2 x, float2 y) => x + y;
/// <inheritdoc cref="add(float, float)"/>
[MI(IL)] public static float3 add(this float3 x, float3 y) => x + y;
/// <inheritdoc cref="add(float, float)"/>
[MI(IL)] public static float4 add(this float4 x, float4 y) => x + y;
/// <inheritdoc cref="add(float, float)"/>
[MI(IL)] public static float2 add(this float2 x, float y) => x + y;
/// <inheritdoc cref="add(float, float)"/>
[MI(IL)] public static float3 add(this float3 x, float y) => x + y;
/// <inheritdoc cref="add(float, float)"/>
[MI(IL)] public static float4 add(this float4 x, float y) => x + y;
/// <inheritdoc cref="add(float, float)"/>
[MI(IL)] public static float2 add(this float x, float2 y) => x + y;
/// <inheritdoc cref="add(float, float)"/>
[MI(IL)] public static float3 add(this float x, float3 y) => x + y;
/// <inheritdoc cref="add(float, float)"/>
[MI(IL)] public static float4 add(this float x, float4 y) => x + y;
/// Subtraction Operation
[MI(IL)] public static float sub(this float x, float y) => x - y;
/// <inheritdoc cref="sub(float, float)"/>
[MI(IL)] public static float2 sub(this float2 x, float2 y) => x - y;
/// <inheritdoc cref="sub(float, float)"/>
[MI(IL)] public static float3 sub(this float3 x, float3 y) => x - y;
/// <inheritdoc cref="sub(float, float)"/>
[MI(IL)] public static float4 sub(this float4 x, float4 y) => x - y;
/// <inheritdoc cref="sub(float, float)"/>
[MI(IL)] public static float2 sub(this float2 x, float y) => x - y;
/// <inheritdoc cref="sub(float, float)"/>
[MI(IL)] public static float3 sub(this float3 x, float y) => x - y;
/// <inheritdoc cref="sub(float, float)"/>
[MI(IL)] public static float4 sub(this float4 x, float y) => x - y;
/// <inheritdoc cref="sub(float, float)"/>
[MI(IL)] public static float2 sub(this float x, float2 y) => x - y;
/// <inheritdoc cref="sub(float, float)"/>
[MI(IL)] public static float3 sub(this float x, float3 y) => x - y;
/// <inheritdoc cref="sub(float, float)"/>
[MI(IL)] public static float4 sub(this float x, float4 y) => x - y;
/// Division Operation
[MI(IL)] public static float div(this float x, float y) => x / y;
/// <inheritdoc cref="div(float, float)"/>
[MI(IL)] public static float2 div(this float2 x, float2 y) => x / y;
/// <inheritdoc cref="div(float, float)"/>
[MI(IL)] public static float3 div(this float3 x, float3 y) => x / y;
/// <inheritdoc cref="div(float, float)"/>
[MI(IL)] public static float4 div(this float4 x, float4 y) => x / y;
/// <inheritdoc cref="div(float, float)"/>
[MI(IL)] public static float2 div(this float2 x, float y) => x / y;
/// <inheritdoc cref="div(float, float)"/>
[MI(IL)] public static float3 div(this float3 x, float y) => x / y;
/// <inheritdoc cref="div(float, float)"/>
[MI(IL)] public static float4 div(this float4 x, float y) => x / y;
/// <inheritdoc cref="div(float, float)"/>
[MI(IL)] public static float2 div(this float x, float2 y) => x / y;
/// <inheritdoc cref="div(float, float)"/>
[MI(IL)] public static float3 div(this float x, float3 y) => x / y;
/// <inheritdoc cref="div(float, float)"/>
[MI(IL)] public static float4 div(this float x, float4 y) => x / y;
/// Cycle components from x to y to z to w and back to x
[MI(IL)] public static float2 cycle(this float2 f) => f.yx;
/// <inheritdoc cref="cycle(float2)"/>
[MI(IL)] public static float3 cycle(this float3 f) => f.yzx;
/// <inheritdoc cref="cycle(float2)"/>
[MI(IL)] public static float4 cycle(this float4 f) => f.yzwx;
/// cycles the components n times
[MI(IL)] public static float2 cycle(this float2 f, int n) => f.apply(cycle, n % 2);
/// cycles the components n times
[MI(IL)] public static float3 cycle(this float3 f, int n) => f.apply(cycle, n % 3);
/// cycles the components n times
[MI(IL)] public static float4 cycle(this float4 f, int n) => f.apply(cycle, n % 4);
// Swap components
/// <inheritdoc cref="swapx(Unity.Mathematics.float4,float)"/>
[MI(IL)] public static float2 swapx(this float2 f, float x) => new(x, f.y);
/// <inheritdoc cref="swapy(Unity.Mathematics.float4,float)"/>
[MI(IL)] public static float2 swapy(this float2 f, float y) => new(f.x, y);
/// <inheritdoc cref="swapx(Unity.Mathematics.float4,float)"/>
[MI(IL)] public static float3 swapx(this float3 f, float x) => new(x, f.y, f.z);
/// <inheritdoc cref="swapy(Unity.Mathematics.float4,float)"/>
[MI(IL)] public static float3 swapy(this float3 f, float y) => new(f.x, y, f.z);
/// <inheritdoc cref="swapz(Unity.Mathematics.float4,float)"/>
[MI(IL)] public static float3 swapz(this float3 f, float z) => new(f.x, f.y, z);
/// substitutes the component x
[MI(IL)] public static float4 swapx(this float4 f, float x) => new(x, f.y, f.z, f.w);
/// substitutes the component y
[MI(IL)] public static float4 swapy(this float4 f, float y) => new(f.x, y, f.z, f.w);
/// substitutes the component z
[MI(IL)] public static float4 swapz(this float4 f, float z) => new(f.x, f.y, z, f.w);
/// substitutes the component w
[MI(IL)] public static float4 swapw(this float4 f, float w) => new(f.x, f.y, f.z, w);
}
}