A game about forced loneliness, made by TACStudios
1using System;
2using System.Runtime.InteropServices;
3using System.Runtime.CompilerServices;
4using Unity.IL2CPP.CompilerServices;
5
6namespace Unity.Mathematics
7{
8 /// <summary>
9 /// A static class to contain various math functions and constants.
10 /// </summary>
11 [Il2CppEagerStaticClassConstruction]
12 public static partial class math
13 {
14 /// <summary>Extrinsic rotation order. Specifies in which order rotations around the principal axes (x, y and z) are to be applied.</summary>
15 public enum RotationOrder : byte
16 {
17 /// <summary>Extrinsic rotation around the x axis, then around the y axis and finally around the z axis.</summary>
18 XYZ,
19 /// <summary>Extrinsic rotation around the x axis, then around the z axis and finally around the y axis.</summary>
20 XZY,
21 /// <summary>Extrinsic rotation around the y axis, then around the x axis and finally around the z axis.</summary>
22 YXZ,
23 /// <summary>Extrinsic rotation around the y axis, then around the z axis and finally around the x axis.</summary>
24 YZX,
25 /// <summary>Extrinsic rotation around the z axis, then around the x axis and finally around the y axis.</summary>
26 ZXY,
27 /// <summary>Extrinsic rotation around the z axis, then around the y axis and finally around the x axis.</summary>
28 ZYX,
29 /// <summary>Unity default rotation order. Extrinsic Rotation around the z axis, then around the x axis and finally around the y axis.</summary>
30 Default = ZXY
31 };
32
33 /// <summary>Specifies a shuffle component.</summary>
34 public enum ShuffleComponent : byte
35 {
36 /// <summary>Specified the x component of the left vector.</summary>
37 LeftX,
38 /// <summary>Specified the y component of the left vector.</summary>
39 LeftY,
40 /// <summary>Specified the z component of the left vector.</summary>
41 LeftZ,
42 /// <summary>Specified the w component of the left vector.</summary>
43 LeftW,
44
45 /// <summary>Specified the x component of the right vector.</summary>
46 RightX,
47 /// <summary>Specified the y component of the right vector.</summary>
48 RightY,
49 /// <summary>Specified the z component of the right vector.</summary>
50 RightZ,
51 /// <summary>Specified the w component of the right vector.</summary>
52 RightW
53 };
54
55 /// <summary>The mathematical constant e also known as Euler's number. Approximately 2.72. This is a f64/double precision constant.</summary>
56 public const double E_DBL = 2.71828182845904523536;
57
58 /// <summary>The base 2 logarithm of e. Approximately 1.44. This is a f64/double precision constant.</summary>
59 public const double LOG2E_DBL = 1.44269504088896340736;
60
61 /// <summary>The base 10 logarithm of e. Approximately 0.43. This is a f64/double precision constant.</summary>
62 public const double LOG10E_DBL = 0.434294481903251827651;
63
64 /// <summary>The natural logarithm of 2. Approximately 0.69. This is a f64/double precision constant.</summary>
65 public const double LN2_DBL = 0.693147180559945309417;
66
67 /// <summary>The natural logarithm of 10. Approximately 2.30. This is a f64/double precision constant.</summary>
68 public const double LN10_DBL = 2.30258509299404568402;
69
70 /// <summary>The mathematical constant pi. Approximately 3.14. This is a f64/double precision constant.</summary>
71 public const double PI_DBL = 3.14159265358979323846;
72
73 /// <summary>
74 /// The mathematical constant (2 * pi). Approximately 6.28. This is a f64/double precision constant. Also known as <see cref="TAU_DBL"/>.
75 /// </summary>
76 public const double PI2_DBL = PI_DBL * 2.0;
77
78 /// <summary>
79 /// The mathematical constant (pi / 2). Approximately 1.57. This is a f64/double precision constant.
80 /// </summary>
81 public const double PIHALF_DBL = PI_DBL * 0.5;
82
83 /// <summary>
84 /// The mathematical constant tau. Approximately 6.28. This is a f64/double precision constant. Also known as <see cref="PI2_DBL"/>.
85 /// </summary>
86 public const double TAU_DBL = PI2_DBL;
87
88 /// <summary>
89 /// The conversion constant used to convert radians to degrees. Multiply the radian value by this constant to get degrees.
90 /// </summary>
91 /// <remarks>Multiplying by this constant is equivalent to using <see cref="math.degrees(double)"/>.</remarks>
92 public const double TODEGREES_DBL = 57.29577951308232;
93
94 /// <summary>
95 /// The conversion constant used to convert degrees to radians. Multiply the degree value by this constant to get radians.
96 /// </summary>
97 /// <remarks>Multiplying by this constant is equivalent to using <see cref="math.radians(double)"/>.</remarks>
98 public const double TORADIANS_DBL = 0.017453292519943296;
99
100 /// <summary>The square root 2. Approximately 1.41. This is a f64/double precision constant.</summary>
101 public const double SQRT2_DBL = 1.41421356237309504880;
102
103 /// <summary>
104 /// The difference between 1.0 and the next representable f64/double precision number.
105 ///
106 /// Beware:
107 /// This value is different from System.Double.Epsilon, which is the smallest, positive, denormalized f64/double.
108 /// </summary>
109 public const double EPSILON_DBL = 2.22044604925031308085e-16;
110
111 /// <summary>
112 /// Double precision constant for positive infinity.
113 /// </summary>
114 public const double INFINITY_DBL = Double.PositiveInfinity;
115
116 /// <summary>
117 /// Double precision constant for Not a Number.
118 ///
119 /// NAN_DBL is considered unordered, which means all comparisons involving it are false except for not equal (operator !=).
120 /// As a consequence, NAN_DBL == NAN_DBL is false but NAN_DBL != NAN_DBL is true.
121 ///
122 /// Additionally, there are multiple bit representations for Not a Number, so if you must test if your value
123 /// is NAN_DBL, use isnan().
124 /// </summary>
125 public const double NAN_DBL = Double.NaN;
126
127 /// <summary>The smallest positive normal number representable in a float.</summary>
128 public const float FLT_MIN_NORMAL = 1.175494351e-38F;
129
130 /// <summary>The smallest positive normal number representable in a double. This is a f64/double precision constant.</summary>
131 public const double DBL_MIN_NORMAL = 2.2250738585072014e-308;
132
133 /// <summary>The mathematical constant e also known as Euler's number. Approximately 2.72.</summary>
134 public const float E = (float)E_DBL;
135
136 /// <summary>The base 2 logarithm of e. Approximately 1.44.</summary>
137 public const float LOG2E = (float)LOG2E_DBL;
138
139 /// <summary>The base 10 logarithm of e. Approximately 0.43.</summary>
140 public const float LOG10E = (float)LOG10E_DBL;
141
142 /// <summary>The natural logarithm of 2. Approximately 0.69.</summary>
143 public const float LN2 = (float)LN2_DBL;
144
145 /// <summary>The natural logarithm of 10. Approximately 2.30.</summary>
146 public const float LN10 = (float)LN10_DBL;
147
148 /// <summary>The mathematical constant pi. Approximately 3.14.</summary>
149 public const float PI = (float)PI_DBL;
150
151 /// <summary>
152 /// The mathematical constant (2 * pi). Approximately 6.28. Also known as <see cref="TAU"/>.
153 /// </summary>
154 public const float PI2 = (float)PI2_DBL;
155
156 /// <summary>
157 /// The mathematical constant (pi / 2). Approximately 1.57.
158 /// </summary>
159 public const float PIHALF = (float)PIHALF_DBL;
160
161 /// <summary>
162 /// The mathematical constant tau. Approximately 6.28. Also known as <see cref="PI2"/>.
163 /// </summary>
164 public const float TAU = (float)PI2_DBL;
165
166 /// <summary>
167 /// The conversion constant used to convert radians to degrees. Multiply the radian value by this constant to get degrees.
168 /// </summary>
169 /// <remarks>Multiplying by this constant is equivalent to using <see cref="math.degrees(float)"/>.</remarks>
170 public const float TODEGREES = (float)TODEGREES_DBL;
171
172 /// <summary>
173 /// The conversion constant used to convert degrees to radians. Multiply the degree value by this constant to get radians.
174 /// </summary>
175 /// <remarks>Multiplying by this constant is equivalent to using <see cref="math.radians(float)"/>.</remarks>
176 public const float TORADIANS = (float)TORADIANS_DBL;
177
178 /// <summary>The square root 2. Approximately 1.41.</summary>
179 public const float SQRT2 = (float)SQRT2_DBL;
180
181 /// <summary>
182 /// The difference between 1.0f and the next representable f32/single precision number.
183 ///
184 /// Beware:
185 /// This value is different from System.Single.Epsilon, which is the smallest, positive, denormalized f32/single.
186 /// </summary>
187 public const float EPSILON = 1.1920928955078125e-7f;
188
189 /// <summary>
190 /// Single precision constant for positive infinity.
191 /// </summary>
192 public const float INFINITY = Single.PositiveInfinity;
193
194 /// <summary>
195 /// Single precision constant for Not a Number.
196 ///
197 /// NAN is considered unordered, which means all comparisons involving it are false except for not equal (operator !=).
198 /// As a consequence, NAN == NAN is false but NAN != NAN is true.
199 ///
200 /// Additionally, there are multiple bit representations for Not a Number, so if you must test if your value
201 /// is NAN, use isnan().
202 /// </summary>
203 public const float NAN = Single.NaN;
204
205 /// <summary>Returns the bit pattern of a uint as an int.</summary>
206 /// <param name="x">The uint bits to copy.</param>
207 /// <returns>The int with the same bit pattern as the input.</returns>
208 [MethodImpl(MethodImplOptions.AggressiveInlining)]
209 public static int asint(uint x)
210 {
211 unsafe
212 {
213 return *(int*)&x;
214 }
215 }
216
217 /// <summary>Returns the bit pattern of a uint2 as an int2.</summary>
218 /// <param name="x">The uint2 bits to copy.</param>
219 /// <returns>The int2 with the same bit pattern as the input.</returns>
220 [MethodImpl(MethodImplOptions.AggressiveInlining)]
221 public static int2 asint(uint2 x)
222 {
223 unsafe
224 {
225 return *(int2*)&x;
226 }
227 }
228
229 /// <summary>Returns the bit pattern of a uint3 as an int3.</summary>
230 /// <param name="x">The uint3 bits to copy.</param>
231 /// <returns>The int3 with the same bit pattern as the input.</returns>
232 [MethodImpl(MethodImplOptions.AggressiveInlining)]
233 public static int3 asint(uint3 x)
234 {
235 unsafe
236 {
237 return *(int3*)&x;
238 }
239 }
240
241 /// <summary>Returns the bit pattern of a uint4 as an int4.</summary>
242 /// <param name="x">The uint4 bits to copy.</param>
243 /// <returns>The int4 with the same bit pattern as the input.</returns>
244 [MethodImpl(MethodImplOptions.AggressiveInlining)]
245 public static int4 asint(uint4 x)
246 {
247 unsafe
248 {
249 return *(int4*)&x;
250 }
251 }
252
253 /// <summary>Returns the bit pattern of a float as an int.</summary>
254 /// <param name="x">The float bits to copy.</param>
255 /// <returns>The int with the same bit pattern as the input.</returns>
256 [MethodImpl(MethodImplOptions.AggressiveInlining)]
257 public static int asint(float x)
258 {
259 unsafe
260 {
261 return *(int*)&x;
262 }
263 }
264
265 /// <summary>Returns the bit pattern of a float2 as an int2.</summary>
266 /// <param name="x">The float2 bits to copy.</param>
267 /// <returns>The int2 with the same bit pattern as the input.</returns>
268 [MethodImpl(MethodImplOptions.AggressiveInlining)]
269 public static int2 asint(float2 x)
270 {
271 unsafe
272 {
273 return *(int2*)&x;
274 }
275 }
276
277 /// <summary>Returns the bit pattern of a float3 as an int3.</summary>
278 /// <param name="x">The float3 bits to copy.</param>
279 /// <returns>The int3 with the same bit pattern as the input.</returns>
280 [MethodImpl(MethodImplOptions.AggressiveInlining)]
281 public static int3 asint(float3 x)
282 {
283 unsafe
284 {
285 return *(int3*)&x;
286 }
287 }
288
289 /// <summary>Returns the bit pattern of a float4 as an int4.</summary>
290 /// <param name="x">The float4 bits to copy.</param>
291 /// <returns>The int4 with the same bit pattern as the input.</returns>
292 [MethodImpl(MethodImplOptions.AggressiveInlining)]
293 public static int4 asint(float4 x)
294 {
295 unsafe
296 {
297 return *(int4*)&x;
298 }
299 }
300
301 /// <summary>Returns the bit pattern of an int as a uint.</summary>
302 /// <param name="x">The int bits to copy.</param>
303 /// <returns>The uint with the same bit pattern as the input.</returns>
304 [MethodImpl(MethodImplOptions.AggressiveInlining)]
305 public static uint asuint(int x) { return (uint)x; }
306
307 /// <summary>Returns the bit pattern of an int2 as a uint2.</summary>
308 /// <param name="x">The int2 bits to copy.</param>
309 /// <returns>The uint2 with the same bit pattern as the input.</returns>
310 [MethodImpl(MethodImplOptions.AggressiveInlining)]
311 public static uint2 asuint(int2 x)
312 {
313 unsafe
314 {
315 return *(uint2*)&x;
316 }
317 }
318
319 /// <summary>Returns the bit pattern of an int3 as a uint3.</summary>
320 /// <param name="x">The int3 bits to copy.</param>
321 /// <returns>The uint3 with the same bit pattern as the input.</returns>
322 [MethodImpl(MethodImplOptions.AggressiveInlining)]
323 public static uint3 asuint(int3 x)
324 {
325 unsafe
326 {
327 return *(uint3*)&x;
328 }
329 }
330
331 /// <summary>Returns the bit pattern of an int4 as a uint4.</summary>
332 /// <param name="x">The int4 bits to copy.</param>
333 /// <returns>The uint4 with the same bit pattern as the input.</returns>
334 [MethodImpl(MethodImplOptions.AggressiveInlining)]
335 public static uint4 asuint(int4 x)
336 {
337 unsafe
338 {
339 return *(uint4*)&x;
340 }
341 }
342
343 /// <summary>Returns the bit pattern of a float as a uint.</summary>
344 /// <param name="x">The float bits to copy.</param>
345 /// <returns>The uint with the same bit pattern as the input.</returns>
346 [MethodImpl(MethodImplOptions.AggressiveInlining)]
347 public static uint asuint(float x)
348 {
349 unsafe
350 {
351 return *(uint*)&x;
352 }
353 }
354
355 /// <summary>Returns the bit pattern of a float2 as a uint2.</summary>
356 /// <param name="x">The float2 bits to copy.</param>
357 /// <returns>The uint2 with the same bit pattern as the input.</returns>
358 [MethodImpl(MethodImplOptions.AggressiveInlining)]
359 public static uint2 asuint(float2 x)
360 {
361 unsafe
362 {
363 return *(uint2*)&x;
364 }
365 }
366
367 /// <summary>Returns the bit pattern of a float3 as a uint3.</summary>
368 /// <param name="x">The float3 bits to copy.</param>
369 /// <returns>The uint3 with the same bit pattern as the input.</returns>
370 [MethodImpl(MethodImplOptions.AggressiveInlining)]
371 public static uint3 asuint(float3 x)
372 {
373 unsafe
374 {
375 return *(uint3*)&x;
376 }
377 }
378
379 /// <summary>Returns the bit pattern of a float4 as a uint4.</summary>
380 /// <param name="x">The float4 bits to copy.</param>
381 /// <returns>The uint4 with the same bit pattern as the input.</returns>
382 [MethodImpl(MethodImplOptions.AggressiveInlining)]
383 public static uint4 asuint(float4 x)
384 {
385 unsafe
386 {
387 return *(uint4*)&x;
388 }
389 }
390
391 /// <summary>Returns the bit pattern of a ulong as a long.</summary>
392 /// <param name="x">The ulong bits to copy.</param>
393 /// <returns>The long with the same bit pattern as the input.</returns>
394 [MethodImpl(MethodImplOptions.AggressiveInlining)]
395 public static long aslong(ulong x) { return (long)x; }
396
397 /// <summary>Returns the bit pattern of a double as a long.</summary>
398 /// <param name="x">The double bits to copy.</param>
399 /// <returns>The long with the same bit pattern as the input.</returns>
400 [MethodImpl(MethodImplOptions.AggressiveInlining)]
401 public static long aslong(double x)
402 {
403 unsafe
404 {
405 return *(long*)&x;
406 }
407 }
408
409 /// <summary>Returns the bit pattern of a long as a ulong.</summary>
410 /// <param name="x">The long bits to copy.</param>
411 /// <returns>The ulong with the same bit pattern as the input.</returns>
412 [MethodImpl(MethodImplOptions.AggressiveInlining)]
413 public static ulong asulong(long x) { return (ulong)x; }
414
415 /// <summary>Returns the bit pattern of a double as a ulong.</summary>
416 /// <param name="x">The double bits to copy.</param>
417 /// <returns>The ulong with the same bit pattern as the input.</returns>
418 [MethodImpl(MethodImplOptions.AggressiveInlining)]
419 public static ulong asulong(double x)
420 {
421 unsafe
422 {
423 return *(ulong*)&x;
424 }
425 }
426
427 /// <summary>Returns the bit pattern of an int as a float.</summary>
428 /// <param name="x">The int bits to copy.</param>
429 /// <returns>The float with the same bit pattern as the input.</returns>
430 [MethodImpl(MethodImplOptions.AggressiveInlining)]
431 public static float asfloat(int x)
432 {
433 unsafe
434 {
435 return *(float*)&x;
436 }
437 }
438
439 /// <summary>Returns the bit pattern of an int2 as a float2.</summary>
440 /// <param name="x">The int2 bits to copy.</param>
441 /// <returns>The float2 with the same bit pattern as the input.</returns>
442 [MethodImpl(MethodImplOptions.AggressiveInlining)]
443 public static float2 asfloat(int2 x)
444 {
445 unsafe
446 {
447 return *(float2*)&x;
448 }
449 }
450
451 /// <summary>Returns the bit pattern of an int3 as a float3.</summary>
452 /// <param name="x">The int3 bits to copy.</param>
453 /// <returns>The float3 with the same bit pattern as the input.</returns>
454 [MethodImpl(MethodImplOptions.AggressiveInlining)]
455 public static float3 asfloat(int3 x)
456 {
457 unsafe
458 {
459 return *(float3*)&x;
460 }
461 }
462
463 /// <summary>Returns the bit pattern of an int4 as a float4.</summary>
464 /// <param name="x">The int4 bits to copy.</param>
465 /// <returns>The float4 with the same bit pattern as the input.</returns>
466 [MethodImpl(MethodImplOptions.AggressiveInlining)]
467 public static float4 asfloat(int4 x)
468 {
469 unsafe
470 {
471 return *(float4*)&x;
472 }
473 }
474
475 /// <summary>Returns the bit pattern of a uint as a float.</summary>
476 /// <param name="x">The uint bits to copy.</param>
477 /// <returns>The float with the same bit pattern as the input.</returns>
478 [MethodImpl(MethodImplOptions.AggressiveInlining)]
479 public static float asfloat(uint x)
480 {
481 unsafe
482 {
483 return *(float*)&x;
484 }
485 }
486
487 /// <summary>Returns the bit pattern of a uint2 as a float2.</summary>
488 /// <param name="x">The uint2 bits to copy.</param>
489 /// <returns>The float2 with the same bit pattern as the input.</returns>
490 [MethodImpl(MethodImplOptions.AggressiveInlining)]
491 public static float2 asfloat(uint2 x)
492 {
493 unsafe
494 {
495 return *(float2*)&x;
496 }
497 }
498
499 /// <summary>Returns the bit pattern of a uint3 as a float3.</summary>
500 /// <param name="x">The uint3 bits to copy.</param>
501 /// <returns>The float3 with the same bit pattern as the input.</returns>
502 [MethodImpl(MethodImplOptions.AggressiveInlining)]
503 public static float3 asfloat(uint3 x)
504 {
505 unsafe
506 {
507 return *(float3*)&x;
508 }
509 }
510
511 /// <summary>Returns the bit pattern of a uint4 as a float4.</summary>
512 /// <param name="x">The uint4 bits to copy.</param>
513 /// <returns>The float4 with the same bit pattern as the input.</returns>
514 [MethodImpl(MethodImplOptions.AggressiveInlining)]
515 public static float4 asfloat(uint4 x)
516 {
517 unsafe
518 {
519 return *(float4*)&x;
520 }
521 }
522
523 /// <summary>
524 /// Returns a bitmask representation of a bool4. Storing one 1 bit per component
525 /// in LSB order, from lower to higher bits (so 4 bits in total).
526 /// The component x is stored at bit 0,
527 /// The component y is stored at bit 1,
528 /// The component z is stored at bit 2,
529 /// The component w is stored at bit 3
530 /// The bool4(x = true, y = true, z = false, w = true) would produce the value 1011 = 0xB
531 /// </summary>
532 /// <param name="value">The input bool4 to calculate the bitmask for</param>
533 /// <returns>A bitmask representation of the bool4, in LSB order</returns>
534 public static int bitmask(bool4 value)
535 {
536 int mask = 0;
537 if (value.x) mask |= 0x01;
538 if (value.y) mask |= 0x02;
539 if (value.z) mask |= 0x04;
540 if (value.w) mask |= 0x08;
541 return mask;
542 }
543
544 /// <summary>Returns the bit pattern of a long as a double.</summary>
545 /// <param name="x">The long bits to copy.</param>
546 /// <returns>The double with the same bit pattern as the input.</returns>
547 [MethodImpl(MethodImplOptions.AggressiveInlining)]
548 public static double asdouble(long x)
549 {
550 unsafe
551 {
552 return *(double*)&x;
553 }
554 }
555
556 /// <summary>Returns the bit pattern of a ulong as a double.</summary>
557 /// <param name="x">The ulong bits to copy.</param>
558 /// <returns>The double with the same bit pattern as the input.</returns>
559 [MethodImpl(MethodImplOptions.AggressiveInlining)]
560 public static double asdouble(ulong x)
561 {
562 unsafe
563 {
564 return *(double*)&x;
565 }
566 }
567
568 /// <summary>Returns true if the input float is a finite floating point value, false otherwise.</summary>
569 /// <param name="x">The float value to test.</param>
570 /// <returns>True if the float is finite, false otherwise.</returns>
571 [MethodImpl(MethodImplOptions.AggressiveInlining)]
572 public static bool isfinite(float x) { return abs(x) < float.PositiveInfinity; }
573
574 /// <summary>Returns a bool2 indicating for each component of a float2 whether it is a finite floating point value.</summary>
575 /// <param name="x">The float2 value to test.</param>
576 /// <returns>A bool2 where it is true in a component if that component is finite, false otherwise.</returns>
577 [MethodImpl(MethodImplOptions.AggressiveInlining)]
578 public static bool2 isfinite(float2 x) { return abs(x) < float.PositiveInfinity; }
579
580 /// <summary>Returns a bool3 indicating for each component of a float3 whether it is a finite floating point value.</summary>
581 /// <param name="x">The float3 value to test.</param>
582 /// <returns>A bool3 where it is true in a component if that component is finite, false otherwise.</returns>
583 [MethodImpl(MethodImplOptions.AggressiveInlining)]
584 public static bool3 isfinite(float3 x) { return abs(x) < float.PositiveInfinity; }
585
586 /// <summary>Returns a bool4 indicating for each component of a float4 whether it is a finite floating point value.</summary>
587 /// <param name="x">The float4 value to test.</param>
588 /// <returns>A bool4 where it is true in a component if that component is finite, false otherwise.</returns>
589 [MethodImpl(MethodImplOptions.AggressiveInlining)]
590 public static bool4 isfinite(float4 x) { return abs(x) < float.PositiveInfinity; }
591
592
593 /// <summary>Returns true if the input double is a finite floating point value, false otherwise.</summary>
594 /// <param name="x">The double value to test.</param>
595 /// <returns>True if the double is finite, false otherwise.</returns>
596 [MethodImpl(MethodImplOptions.AggressiveInlining)]
597 public static bool isfinite(double x) { return abs(x) < double.PositiveInfinity; }
598
599 /// <summary>Returns a bool2 indicating for each component of a double2 whether it is a finite floating point value.</summary>
600 /// <param name="x">The double2 value to test.</param>
601 /// <returns>A bool2 where it is true in a component if that component is finite, false otherwise.</returns>
602 [MethodImpl(MethodImplOptions.AggressiveInlining)]
603 public static bool2 isfinite(double2 x) { return abs(x) < double.PositiveInfinity; }
604
605 /// <summary>Returns a bool3 indicating for each component of a double3 whether it is a finite floating point value.</summary>
606 /// <param name="x">The double3 value to test.</param>
607 /// <returns>A bool3 where it is true in a component if that component is finite, false otherwise.</returns>
608 [MethodImpl(MethodImplOptions.AggressiveInlining)]
609 public static bool3 isfinite(double3 x) { return abs(x) < double.PositiveInfinity; }
610
611 /// <summary>Returns a bool4 indicating for each component of a double4 whether it is a finite floating point value.</summary>
612 /// <param name="x">The double4 value to test.</param>
613 /// <returns>A bool4 where it is true in a component if that component is finite, false otherwise.</returns>
614 [MethodImpl(MethodImplOptions.AggressiveInlining)]
615 public static bool4 isfinite(double4 x) { return abs(x) < double.PositiveInfinity; }
616
617
618 /// <summary>Returns true if the input float is an infinite floating point value, false otherwise.</summary>
619 /// <param name="x">Input value.</param>
620 /// <returns>True if the input was an infinite value; false otherwise.</returns>
621 [MethodImpl(MethodImplOptions.AggressiveInlining)]
622 public static bool isinf(float x) { return abs(x) == float.PositiveInfinity; }
623
624 /// <summary>Returns a bool2 indicating for each component of a float2 whether it is an infinite floating point value.</summary>
625 /// <param name="x">Input value.</param>
626 /// <returns>True if the component was an infinite value; false otherwise.</returns>
627 [MethodImpl(MethodImplOptions.AggressiveInlining)]
628 public static bool2 isinf(float2 x) { return abs(x) == float.PositiveInfinity; }
629
630 /// <summary>Returns a bool3 indicating for each component of a float3 whether it is an infinite floating point value.</summary>
631 /// <param name="x">Input value.</param>
632 /// <returns>True if the component was an infinite value; false otherwise.</returns>
633 [MethodImpl(MethodImplOptions.AggressiveInlining)]
634 public static bool3 isinf(float3 x) { return abs(x) == float.PositiveInfinity; }
635
636 /// <summary>Returns a bool4 indicating for each component of a float4 whether it is an infinite floating point value.</summary>
637 /// <param name="x">Input value.</param>
638 /// <returns>True if the component was an infinite value; false otherwise.</returns>
639 [MethodImpl(MethodImplOptions.AggressiveInlining)]
640 public static bool4 isinf(float4 x) { return abs(x) == float.PositiveInfinity; }
641
642 /// <summary>Returns true if the input double is an infinite floating point value, false otherwise.</summary>
643 /// <param name="x">Input value.</param>
644 /// <returns>True if the input was an infinite value; false otherwise.</returns>
645 [MethodImpl(MethodImplOptions.AggressiveInlining)]
646 public static bool isinf(double x) { return abs(x) == double.PositiveInfinity; }
647
648 /// <summary>Returns a bool2 indicating for each component of a double2 whether it is an infinite floating point value.</summary>
649 /// <param name="x">Input value.</param>
650 /// <returns>True if the component was an infinite value; false otherwise.</returns>
651 [MethodImpl(MethodImplOptions.AggressiveInlining)]
652 public static bool2 isinf(double2 x) { return abs(x) == double.PositiveInfinity; }
653
654 /// <summary>Returns a bool3 indicating for each component of a double3 whether it is an infinite floating point value.</summary>
655 /// <param name="x">Input value.</param>
656 /// <returns>True if the component was an infinite value; false otherwise.</returns>
657 [MethodImpl(MethodImplOptions.AggressiveInlining)]
658 public static bool3 isinf(double3 x) { return abs(x) == double.PositiveInfinity; }
659
660 /// <summary>Returns a bool4 indicating for each component of a double4 whether it is an infinite floating point value.</summary>
661 /// <param name="x">Input value.</param>
662 /// <returns>True if the component was an infinite value; false otherwise.</returns>
663 [MethodImpl(MethodImplOptions.AggressiveInlining)]
664 public static bool4 isinf(double4 x) { return abs(x) == double.PositiveInfinity; }
665
666
667 /// <summary>Returns true if the input float is a NaN (not a number) floating point value, false otherwise.</summary>
668 /// <remarks>
669 /// NaN has several representations and may vary across architectures. Use this function to check if you have a NaN.
670 /// </remarks>
671 /// <param name="x">Input value.</param>
672 /// <returns>True if the value was NaN; false otherwise.</returns>
673 [MethodImpl(MethodImplOptions.AggressiveInlining)]
674 public static bool isnan(float x) { return (asuint(x) & 0x7FFFFFFF) > 0x7F800000; }
675
676 /// <summary>Returns a bool2 indicating for each component of a float2 whether it is a NaN (not a number) floating point value.</summary>
677 /// <remarks>
678 /// NaN has several representations and may vary across architectures. Use this function to check if you have a NaN.
679 /// </remarks>
680 /// <param name="x">Input value.</param>
681 /// <returns>True if the component was NaN; false otherwise.</returns>
682 [MethodImpl(MethodImplOptions.AggressiveInlining)]
683 public static bool2 isnan(float2 x) { return (asuint(x) & 0x7FFFFFFF) > 0x7F800000; }
684
685 /// <summary>Returns a bool3 indicating for each component of a float3 whether it is a NaN (not a number) floating point value.</summary>
686 /// <remarks>
687 /// NaN has several representations and may vary across architectures. Use this function to check if you have a NaN.
688 /// </remarks>
689 /// <param name="x">Input value.</param>
690 /// <returns>True if the component was NaN; false otherwise.</returns>
691 [MethodImpl(MethodImplOptions.AggressiveInlining)]
692 public static bool3 isnan(float3 x) { return (asuint(x) & 0x7FFFFFFF) > 0x7F800000; }
693
694 /// <summary>Returns a bool4 indicating for each component of a float4 whether it is a NaN (not a number) floating point value.</summary>
695 /// <remarks>
696 /// NaN has several representations and may vary across architectures. Use this function to check if you have a NaN.
697 /// </remarks>
698 /// <param name="x">Input value.</param>
699 /// <returns>True if the component was NaN; false otherwise.</returns>
700 [MethodImpl(MethodImplOptions.AggressiveInlining)]
701 public static bool4 isnan(float4 x) { return (asuint(x) & 0x7FFFFFFF) > 0x7F800000; }
702
703
704 /// <summary>Returns true if the input double is a NaN (not a number) floating point value, false otherwise.</summary>
705 /// <remarks>
706 /// NaN has several representations and may vary across architectures. Use this function to check if you have a NaN.
707 /// </remarks>
708 /// <param name="x">Input value.</param>
709 /// <returns>True if the value was NaN; false otherwise.</returns>
710 [MethodImpl(MethodImplOptions.AggressiveInlining)]
711 public static bool isnan(double x) { return (asulong(x) & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000; }
712
713 /// <summary>Returns a bool2 indicating for each component of a double2 whether it is a NaN (not a number) floating point value.</summary>
714 /// <remarks>
715 /// NaN has several representations and may vary across architectures. Use this function to check if you have a NaN.
716 /// </remarks>
717 /// <param name="x">Input value.</param>
718 /// <returns>True if the component was NaN; false otherwise.</returns>
719 [MethodImpl(MethodImplOptions.AggressiveInlining)]
720 public static bool2 isnan(double2 x) {
721 return bool2((asulong(x.x) & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000,
722 (asulong(x.y) & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000);
723 }
724
725 /// <summary>Returns a bool3 indicating for each component of a double3 whether it is a NaN (not a number) floating point value.</summary>
726 /// <remarks>
727 /// NaN has several representations and may vary across architectures. Use this function to check if you have a NaN.
728 /// </remarks>
729 /// <param name="x">Input value.</param>
730 /// <returns>True if the component was NaN; false otherwise.</returns>
731 [MethodImpl(MethodImplOptions.AggressiveInlining)]
732 public static bool3 isnan(double3 x)
733 {
734 return bool3((asulong(x.x) & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000,
735 (asulong(x.y) & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000,
736 (asulong(x.z) & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000);
737 }
738
739 /// <summary>Returns a bool4 indicating for each component of a double4 whether it is a NaN (not a number) floating point value.</summary>
740 /// <remarks>
741 /// NaN has several representations and may vary across architectures. Use this function to check if you have a NaN.
742 /// </remarks>
743 /// <param name="x">Input value.</param>
744 /// <returns>True if the component was NaN; false otherwise.</returns>
745 [MethodImpl(MethodImplOptions.AggressiveInlining)]
746 public static bool4 isnan(double4 x)
747 {
748 return bool4((asulong(x.x) & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000,
749 (asulong(x.y) & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000,
750 (asulong(x.z) & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000,
751 (asulong(x.w) & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000);
752 }
753
754 /// <summary>
755 /// Checks if the input is a power of two.
756 /// </summary>
757 /// <remarks>If x is less than or equal to zero, then this function returns false.</remarks>
758 /// <param name="x">Integer input.</param>
759 /// <returns>bool where true indicates that input was a power of two.</returns>
760 [MethodImpl(MethodImplOptions.AggressiveInlining)]
761 public static bool ispow2(int x)
762 {
763 return x > 0 && ((x & (x - 1)) == 0);
764 }
765
766 /// <summary>
767 /// Checks if each component of the input is a power of two.
768 /// </summary>
769 /// <remarks>If a component of x is less than or equal to zero, then this function returns false in that component.</remarks>
770 /// <param name="x">int2 input</param>
771 /// <returns>bool2 where true in a component indicates the same component in the input was a power of two.</returns>
772 [MethodImpl(MethodImplOptions.AggressiveInlining)]
773 public static bool2 ispow2(int2 x)
774 {
775 return new bool2(ispow2(x.x), ispow2(x.y));
776 }
777
778 /// <summary>
779 /// Checks if each component of the input is a power of two.
780 /// </summary>
781 /// <remarks>If a component of x is less than or equal to zero, then this function returns false in that component.</remarks>
782 /// <param name="x">int3 input</param>
783 /// <returns>bool3 where true in a component indicates the same component in the input was a power of two.</returns>
784 [MethodImpl(MethodImplOptions.AggressiveInlining)]
785 public static bool3 ispow2(int3 x)
786 {
787 return new bool3(ispow2(x.x), ispow2(x.y), ispow2(x.z));
788 }
789
790 /// <summary>
791 /// Checks if each component of the input is a power of two.
792 /// </summary>
793 /// <remarks>If a component of x is less than or equal to zero, then this function returns false in that component.</remarks>
794 /// <param name="x">int4 input</param>
795 /// <returns>bool4 where true in a component indicates the same component in the input was a power of two.</returns>
796 [MethodImpl(MethodImplOptions.AggressiveInlining)]
797 public static bool4 ispow2(int4 x)
798 {
799 return new bool4(ispow2(x.x), ispow2(x.y), ispow2(x.z), ispow2(x.w));
800 }
801
802 /// <summary>
803 /// Checks if the input is a power of two.
804 /// </summary>
805 /// <remarks>If x is less than or equal to zero, then this function returns false.</remarks>
806 /// <param name="x">Unsigned integer input.</param>
807 /// <returns>bool where true indicates that input was a power of two.</returns>
808 [MethodImpl(MethodImplOptions.AggressiveInlining)]
809 public static bool ispow2(uint x)
810 {
811 return x > 0 && ((x & (x - 1)) == 0);
812 }
813
814 /// <summary>
815 /// Checks if each component of the input is a power of two.
816 /// </summary>
817 /// <remarks>If a component of x is less than or equal to zero, then this function returns false in that component.</remarks>
818 /// <param name="x">uint2 input</param>
819 /// <returns>bool2 where true in a component indicates the same component in the input was a power of two.</returns>
820 [MethodImpl(MethodImplOptions.AggressiveInlining)]
821 public static bool2 ispow2(uint2 x)
822 {
823 return new bool2(ispow2(x.x), ispow2(x.y));
824 }
825
826 /// <summary>
827 /// Checks if each component of the input is a power of two.
828 /// </summary>
829 /// <remarks>If a component of x is less than or equal to zero, then this function returns false in that component.</remarks>
830 /// <param name="x">uint3 input</param>
831 /// <returns>bool3 where true in a component indicates the same component in the input was a power of two.</returns>
832 [MethodImpl(MethodImplOptions.AggressiveInlining)]
833 public static bool3 ispow2(uint3 x)
834 {
835 return new bool3(ispow2(x.x), ispow2(x.y), ispow2(x.z));
836 }
837
838 /// <summary>
839 /// Checks if each component of the input is a power of two.
840 /// </summary>
841 /// <remarks>If a component of x is less than or equal to zero, then this function returns false in that component.</remarks>
842 /// <param name="x">uint4 input</param>
843 /// <returns>bool4 where true in a component indicates the same component in the input was a power of two.</returns>
844 [MethodImpl(MethodImplOptions.AggressiveInlining)]
845 public static bool4 ispow2(uint4 x)
846 {
847 return new bool4(ispow2(x.x), ispow2(x.y), ispow2(x.z), ispow2(x.w));
848 }
849
850 /// <summary>Returns the minimum of two int values.</summary>
851 /// <param name="x">The first input value.</param>
852 /// <param name="y">The second input value.</param>
853 /// <returns>The minimum of the two input values.</returns>
854 [MethodImpl(MethodImplOptions.AggressiveInlining)]
855 public static int min(int x, int y) { return x < y ? x : y; }
856
857 /// <summary>Returns the componentwise minimum of two int2 vectors.</summary>
858 /// <param name="x">The first input value.</param>
859 /// <param name="y">The second input value.</param>
860 /// <returns>The componentwise minimum of the two input values.</returns>
861 [MethodImpl(MethodImplOptions.AggressiveInlining)]
862 public static int2 min(int2 x, int2 y) { return new int2(min(x.x, y.x), min(x.y, y.y)); }
863
864 /// <summary>Returns the componentwise minimum of two int3 vectors.</summary>
865 /// <param name="x">The first input value.</param>
866 /// <param name="y">The second input value.</param>
867 /// <returns>The componentwise minimum of the two input values.</returns>
868 [MethodImpl(MethodImplOptions.AggressiveInlining)]
869 public static int3 min(int3 x, int3 y) { return new int3(min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)); }
870
871 /// <summary>Returns the componentwise minimum of two int4 vectors.</summary>
872 /// <param name="x">The first input value.</param>
873 /// <param name="y">The second input value.</param>
874 /// <returns>The componentwise minimum of the two input values.</returns>
875 [MethodImpl(MethodImplOptions.AggressiveInlining)]
876 public static int4 min(int4 x, int4 y) { return new int4(min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)); }
877
878
879 /// <summary>Returns the minimum of two uint values.</summary>
880 /// <param name="x">The first input value.</param>
881 /// <param name="y">The second input value.</param>
882 /// <returns>The minimum of the two input values.</returns>
883 [MethodImpl(MethodImplOptions.AggressiveInlining)]
884 public static uint min(uint x, uint y) { return x < y ? x : y; }
885
886 /// <summary>Returns the componentwise minimum of two uint2 vectors.</summary>
887 /// <param name="x">The first input value.</param>
888 /// <param name="y">The second input value.</param>
889 /// <returns>The componentwise minimum of the two input values.</returns>
890 [MethodImpl(MethodImplOptions.AggressiveInlining)]
891 public static uint2 min(uint2 x, uint2 y) { return new uint2(min(x.x, y.x), min(x.y, y.y)); }
892
893 /// <summary>Returns the componentwise minimum of two uint3 vectors.</summary>
894 /// <param name="x">The first input value.</param>
895 /// <param name="y">The second input value.</param>
896 /// <returns>The componentwise minimum of the two input values.</returns>
897 [MethodImpl(MethodImplOptions.AggressiveInlining)]
898 public static uint3 min(uint3 x, uint3 y) { return new uint3(min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)); }
899
900 /// <summary>Returns the componentwise minimum of two uint4 vectors.</summary>
901 /// <param name="x">The first input value.</param>
902 /// <param name="y">The second input value.</param>
903 /// <returns>The componentwise minimum of the two input values.</returns>
904 [MethodImpl(MethodImplOptions.AggressiveInlining)]
905 public static uint4 min(uint4 x, uint4 y) { return new uint4(min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)); }
906
907
908 /// <summary>Returns the minimum of two long values.</summary>
909 /// <param name="x">The first input value.</param>
910 /// <param name="y">The second input value.</param>
911 /// <returns>The minimum of the two input values.</returns>
912 [MethodImpl(MethodImplOptions.AggressiveInlining)]
913 public static long min(long x, long y) { return x < y ? x : y; }
914
915
916 /// <summary>Returns the minimum of two ulong values.</summary>
917 /// <param name="x">The first input value.</param>
918 /// <param name="y">The second input value.</param>
919 /// <returns>The minimum of the two input values.</returns>
920 [MethodImpl(MethodImplOptions.AggressiveInlining)]
921 public static ulong min(ulong x, ulong y) { return x < y ? x : y; }
922
923
924 /// <summary>Returns the minimum of two float values.</summary>
925 /// <param name="x">The first input value.</param>
926 /// <param name="y">The second input value.</param>
927 /// <returns>The minimum of the two input values.</returns>
928 [MethodImpl(MethodImplOptions.AggressiveInlining)]
929 public static float min(float x, float y) { return float.IsNaN(y) || x < y ? x : y; }
930
931 /// <summary>Returns the componentwise minimum of two float2 vectors.</summary>
932 /// <param name="x">The first input value.</param>
933 /// <param name="y">The second input value.</param>
934 /// <returns>The componentwise minimum of the two input values.</returns>
935 [MethodImpl(MethodImplOptions.AggressiveInlining)]
936 public static float2 min(float2 x, float2 y) { return new float2(min(x.x, y.x), min(x.y, y.y)); }
937
938 /// <summary>Returns the componentwise minimum of two float3 vectors.</summary>
939 /// <param name="x">The first input value.</param>
940 /// <param name="y">The second input value.</param>
941 /// <returns>The componentwise minimum of the two input values.</returns>
942 [MethodImpl(MethodImplOptions.AggressiveInlining)]
943 public static float3 min(float3 x, float3 y) { return new float3(min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)); }
944
945 /// <summary>Returns the componentwise minimum of two float4 vectors.</summary>
946 /// <param name="x">The first input value.</param>
947 /// <param name="y">The second input value.</param>
948 /// <returns>The componentwise minimum of the two input values.</returns>
949 [MethodImpl(MethodImplOptions.AggressiveInlining)]
950 public static float4 min(float4 x, float4 y) { return new float4(min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)); }
951
952
953 /// <summary>Returns the minimum of two double values.</summary>
954 /// <param name="x">The first input value.</param>
955 /// <param name="y">The second input value.</param>
956 /// <returns>The minimum of the two input values.</returns>
957 [MethodImpl(MethodImplOptions.AggressiveInlining)]
958 public static double min(double x, double y) { return double.IsNaN(y) || x < y ? x : y; }
959
960 /// <summary>Returns the componentwise minimum of two double2 vectors.</summary>
961 /// <param name="x">The first input value.</param>
962 /// <param name="y">The second input value.</param>
963 /// <returns>The componentwise minimum of the two input values.</returns>
964 [MethodImpl(MethodImplOptions.AggressiveInlining)]
965 public static double2 min(double2 x, double2 y) { return new double2(min(x.x, y.x), min(x.y, y.y)); }
966
967 /// <summary>Returns the componentwise minimum of two double3 vectors.</summary>
968 /// <param name="x">The first input value.</param>
969 /// <param name="y">The second input value.</param>
970 /// <returns>The componentwise minimum of the two input values.</returns>
971 [MethodImpl(MethodImplOptions.AggressiveInlining)]
972 public static double3 min(double3 x, double3 y) { return new double3(min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)); }
973
974 /// <summary>Returns the componentwise minimum of two double4 vectors.</summary>
975 /// <param name="x">The first input value.</param>
976 /// <param name="y">The second input value.</param>
977 /// <returns>The componentwise minimum of the two input values.</returns>
978 [MethodImpl(MethodImplOptions.AggressiveInlining)]
979 public static double4 min(double4 x, double4 y) { return new double4(min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)); }
980
981
982 /// <summary>Returns the maximum of two int values.</summary>
983 /// <param name="x">The first input value.</param>
984 /// <param name="y">The second input value.</param>
985 /// <returns>The maximum of the two input values.</returns>
986 [MethodImpl(MethodImplOptions.AggressiveInlining)]
987 public static int max(int x, int y) { return x > y ? x : y; }
988
989 /// <summary>Returns the componentwise maximum of two int2 vectors.</summary>
990 /// <param name="x">The first input value.</param>
991 /// <param name="y">The second input value.</param>
992 /// <returns>The componentwise maximum of the two input values.</returns>
993 [MethodImpl(MethodImplOptions.AggressiveInlining)]
994 public static int2 max(int2 x, int2 y) { return new int2(max(x.x, y.x), max(x.y, y.y)); }
995
996 /// <summary>Returns the componentwise maximum of two int3 vectors.</summary>
997 /// <param name="x">The first input value.</param>
998 /// <param name="y">The second input value.</param>
999 /// <returns>The componentwise maximum of the two input values.</returns>
1000 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1001 public static int3 max(int3 x, int3 y) { return new int3(max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)); }
1002
1003 /// <summary>Returns the componentwise maximum of two int4 vectors.</summary>
1004 /// <param name="x">The first input value.</param>
1005 /// <param name="y">The second input value.</param>
1006 /// <returns>The componentwise maximum of the two input values.</returns>
1007 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1008 public static int4 max(int4 x, int4 y) { return new int4(max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)); }
1009
1010
1011 /// <summary>Returns the maximum of two uint values.</summary>
1012 /// <param name="x">The first input value.</param>
1013 /// <param name="y">The second input value.</param>
1014 /// <returns>The maximum of the two input values.</returns>
1015 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1016 public static uint max(uint x, uint y) { return x > y ? x : y; }
1017
1018 /// <summary>Returns the componentwise maximum of two uint2 vectors.</summary>
1019 /// <param name="x">The first input value.</param>
1020 /// <param name="y">The second input value.</param>
1021 /// <returns>The componentwise maximum of the two input values.</returns>
1022 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1023 public static uint2 max(uint2 x, uint2 y) { return new uint2(max(x.x, y.x), max(x.y, y.y)); }
1024
1025 /// <summary>Returns the componentwise maximum of two uint3 vectors.</summary>
1026 /// <param name="x">The first input value.</param>
1027 /// <param name="y">The second input value.</param>
1028 /// <returns>The componentwise maximum of the two input values.</returns>
1029 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1030 public static uint3 max(uint3 x, uint3 y) { return new uint3(max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)); }
1031
1032 /// <summary>Returns the componentwise maximum of two uint4 vectors.</summary>
1033 /// <param name="x">The first input value.</param>
1034 /// <param name="y">The second input value.</param>
1035 /// <returns>The componentwise maximum of the two input values.</returns>
1036 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1037 public static uint4 max(uint4 x, uint4 y) { return new uint4(max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)); }
1038
1039
1040 /// <summary>Returns the maximum of two long values.</summary>
1041 /// <param name="x">The first input value.</param>
1042 /// <param name="y">The second input value.</param>
1043 /// <returns>The maximum of the two input values.</returns>
1044 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1045 public static long max(long x, long y) { return x > y ? x : y; }
1046
1047
1048 /// <summary>Returns the maximum of two ulong values.</summary>
1049 /// <param name="x">The first input value.</param>
1050 /// <param name="y">The second input value.</param>
1051 /// <returns>The maximum of the two input values.</returns>
1052 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1053 public static ulong max(ulong x, ulong y) { return x > y ? x : y; }
1054
1055
1056 /// <summary>Returns the maximum of two float values.</summary>
1057 /// <param name="x">The first input value.</param>
1058 /// <param name="y">The second input value.</param>
1059 /// <returns>The maximum of the two input values.</returns>
1060 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1061 public static float max(float x, float y) { return float.IsNaN(y) || x > y ? x : y; }
1062
1063 /// <summary>Returns the componentwise maximum of two float2 vectors.</summary>
1064 /// <param name="x">The first input value.</param>
1065 /// <param name="y">The second input value.</param>
1066 /// <returns>The componentwise maximum of the two input values.</returns>
1067 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1068 public static float2 max(float2 x, float2 y) { return new float2(max(x.x, y.x), max(x.y, y.y)); }
1069
1070 /// <summary>Returns the componentwise maximum of two float3 vectors.</summary>
1071 /// <param name="x">The first input value.</param>
1072 /// <param name="y">The second input value.</param>
1073 /// <returns>The componentwise maximum of the two input values.</returns>
1074 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1075 public static float3 max(float3 x, float3 y) { return new float3(max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)); }
1076
1077 /// <summary>Returns the componentwise maximum of two float4 vectors.</summary>
1078 /// <param name="x">The first input value.</param>
1079 /// <param name="y">The second input value.</param>
1080 /// <returns>The componentwise maximum of the two input values.</returns>
1081 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1082 public static float4 max(float4 x, float4 y) { return new float4(max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)); }
1083
1084
1085 /// <summary>Returns the maximum of two double values.</summary>
1086 /// <param name="x">The first input value.</param>
1087 /// <param name="y">The second input value.</param>
1088 /// <returns>The maximum of the two input values.</returns>
1089 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1090 public static double max(double x, double y) { return double.IsNaN(y) || x > y ? x : y; }
1091
1092 /// <summary>Returns the componentwise maximum of two double2 vectors.</summary>
1093 /// <param name="x">The first input value.</param>
1094 /// <param name="y">The second input value.</param>
1095 /// <returns>The componentwise maximum of the two input values.</returns>
1096 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1097 public static double2 max(double2 x, double2 y) { return new double2(max(x.x, y.x), max(x.y, y.y)); }
1098
1099 /// <summary>Returns the componentwise maximum of two double3 vectors.</summary>
1100 /// <param name="x">The first input value.</param>
1101 /// <param name="y">The second input value.</param>
1102 /// <returns>The componentwise maximum of the two input values.</returns>
1103 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1104 public static double3 max(double3 x, double3 y) { return new double3(max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)); }
1105
1106 /// <summary>Returns the componentwise maximum of two double4 vectors.</summary>
1107 /// <param name="x">The first input value.</param>
1108 /// <param name="y">The second input value.</param>
1109 /// <returns>The componentwise maximum of the two input values.</returns>
1110 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1111 public static double4 max(double4 x, double4 y) { return new double4(max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)); }
1112
1113
1114 /// <summary>Returns the result of linearly interpolating from start to end using the interpolation parameter t.</summary>
1115 /// <remarks>
1116 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1117 /// </remarks>
1118 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1119 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1120 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1121 /// <returns>The interpolation from start to end.</returns>
1122 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1123 public static float lerp(float start, float end, float t) { return start + t * (end - start); }
1124
1125 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the interpolation parameter t.</summary>
1126 /// <remarks>
1127 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1128 /// </remarks>
1129 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1130 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1131 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1132 /// <returns>The componentwise interpolation from x to y.</returns>
1133 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1134 public static float2 lerp(float2 start, float2 end, float t) { return start + t * (end - start); }
1135
1136 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the interpolation parameter t.</summary>
1137 /// <remarks>
1138 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1139 /// </remarks>
1140 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1141 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1142 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1143 /// <returns>The componentwise interpolation from x to y.</returns>
1144 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1145 public static float3 lerp(float3 start, float3 end, float t) { return start + t * (end - start); }
1146
1147 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the interpolation parameter t.</summary>
1148 /// <remarks>
1149 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1150 /// </remarks>
1151 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1152 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1153 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1154 /// <returns>The componentwise interpolation from x to y.</returns>
1155 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1156 public static float4 lerp(float4 start, float4 end, float t) { return start + t * (end - start); }
1157
1158
1159 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the corresponding components of the interpolation parameter t.</summary>
1160 /// <remarks>
1161 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1162 /// </remarks>
1163 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1164 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1165 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1166 /// <returns>The componentwise interpolation from x to y.</returns>
1167 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1168 public static float2 lerp(float2 start, float2 end, float2 t) { return start + t * (end - start); }
1169
1170 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the corresponding components of the interpolation parameter t.</summary>
1171 /// <remarks>
1172 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1173 /// </remarks>
1174 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1175 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1176 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1177 /// <returns>The componentwise interpolation from x to y.</returns>
1178 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1179 public static float3 lerp(float3 start, float3 end, float3 t) { return start + t * (end - start); }
1180
1181 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the corresponding components of the interpolation parameter t.</summary>
1182 /// <remarks>
1183 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1184 /// </remarks>
1185 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1186 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1187 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1188 /// <returns>The componentwise interpolation from x to y.</returns>
1189 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1190 public static float4 lerp(float4 start, float4 end, float4 t) { return start + t * (end - start); }
1191
1192
1193 /// <summary>Returns the result of linearly interpolating from x to y using the interpolation parameter t.</summary>
1194 /// <remarks>
1195 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1196 /// </remarks>
1197 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1198 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1199 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1200 /// <returns>The interpolation from x to y.</returns>
1201 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1202 public static double lerp(double start, double end, double t) { return start + t * (end - start); }
1203
1204 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the interpolation parameter t.</summary>
1205 /// <remarks>
1206 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1207 /// </remarks>
1208 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1209 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1210 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1211 /// <returns>The componentwise interpolation from x to y.</returns>
1212 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1213 public static double2 lerp(double2 start, double2 end, double t) { return start + t * (end - start); }
1214
1215 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the interpolation parameter t.</summary>
1216 /// <remarks>
1217 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1218 /// </remarks>
1219 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1220 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1221 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1222 /// <returns>The componentwise interpolation from x to y.</returns>
1223 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1224 public static double3 lerp(double3 start, double3 end, double t) { return start + t * (end - start); }
1225
1226 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the interpolation parameter t.</summary>
1227 /// <remarks>
1228 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1229 /// </remarks>
1230 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1231 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1232 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1233 /// <returns>The componentwise interpolation from x to y.</returns>
1234 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1235 public static double4 lerp(double4 start, double4 end, double t) { return start + t * (end - start); }
1236
1237
1238 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the corresponding components of the interpolation parameter t.</summary>
1239 /// <remarks>
1240 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1241 /// </remarks>
1242 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1243 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1244 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1245 /// <returns>The componentwise interpolation from x to y.</returns>
1246 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1247 public static double2 lerp(double2 start, double2 end, double2 t) { return start + t * (end - start); }
1248
1249 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the corresponding components of the interpolation parameter t.</summary>
1250 /// <remarks>
1251 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1252 /// </remarks>
1253 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1254 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1255 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1256 /// <returns>The componentwise interpolation from x to y.</returns>
1257 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1258 public static double3 lerp(double3 start, double3 end, double3 t) { return start + t * (end - start); }
1259
1260 /// <summary>Returns the result of a componentwise linear interpolating from x to y using the corresponding components of the interpolation parameter t.</summary>
1261 /// <remarks>
1262 /// If the interpolation parameter is not in the range [0, 1], then this function extrapolates.
1263 /// </remarks>
1264 /// <param name="start">The start point, corresponding to the interpolation parameter value of 0.</param>
1265 /// <param name="end">The end point, corresponding to the interpolation parameter value of 1.</param>
1266 /// <param name="t">The interpolation parameter. May be a value outside the interval [0, 1].</param>
1267 /// <returns>The componentwise interpolation from x to y.</returns>
1268 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1269 public static double4 lerp(double4 start, double4 end, double4 t) { return start + t * (end - start); }
1270
1271
1272 /// <summary>Returns the result of normalizing a floating point value x to a range [a, b]. The opposite of lerp. Equivalent to (x - a) / (b - a).</summary>
1273 /// <param name="start">The start point of the range.</param>
1274 /// <param name="end">The end point of the range.</param>
1275 /// <param name="x">The value to normalize to the range.</param>
1276 /// <returns>The interpolation parameter of x with respect to the input range [a, b].</returns>
1277 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1278 public static float unlerp(float start, float end, float x) { return (x - start) / (end - start); }
1279
1280 /// <summary>Returns the componentwise result of normalizing a floating point value x to a range [a, b]. The opposite of lerp. Equivalent to (x - a) / (b - a).</summary>
1281 /// <param name="start">The start point of the range.</param>
1282 /// <param name="end">The end point of the range.</param>
1283 /// <param name="x">The value to normalize to the range.</param>
1284 /// <returns>The componentwise interpolation parameter of x with respect to the input range [a, b].</returns>
1285 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1286 public static float2 unlerp(float2 start, float2 end, float2 x) { return (x - start) / (end - start); }
1287
1288 /// <summary>Returns the componentwise result of normalizing a floating point value x to a range [a, b]. The opposite of lerp. Equivalent to (x - a) / (b - a).</summary>
1289 /// <param name="start">The start point of the range.</param>
1290 /// <param name="end">The end point of the range.</param>
1291 /// <param name="x">The value to normalize to the range.</param>
1292 /// <returns>The componentwise interpolation parameter of x with respect to the input range [a, b].</returns>
1293 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1294 public static float3 unlerp(float3 start, float3 end, float3 x) { return (x - start) / (end - start); }
1295
1296 /// <summary>Returns the componentwise result of normalizing a floating point value x to a range [a, b]. The opposite of lerp. Equivalent to (x - a) / (b - a).</summary>
1297 /// <param name="start">The start point of the range.</param>
1298 /// <param name="end">The end point of the range.</param>
1299 /// <param name="x">The value to normalize to the range.</param>
1300 /// <returns>The componentwise interpolation parameter of x with respect to the input range [a, b].</returns>
1301 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1302 public static float4 unlerp(float4 start, float4 end, float4 x) { return (x - start) / (end - start); }
1303
1304
1305 /// <summary>Returns the result of normalizing a floating point value x to a range [a, b]. The opposite of lerp. Equivalent to (x - a) / (b - a).</summary>
1306 /// <param name="start">The start point of the range.</param>
1307 /// <param name="end">The end point of the range.</param>
1308 /// <param name="x">The value to normalize to the range.</param>
1309 /// <returns>The interpolation parameter of x with respect to the input range [a, b].</returns>
1310 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1311 public static double unlerp(double start, double end, double x) { return (x - start) / (end - start); }
1312
1313 /// <summary>Returns the componentwise result of normalizing a floating point value x to a range [a, b]. The opposite of lerp. Equivalent to (x - a) / (b - a).</summary>
1314 /// <param name="start">The start point of the range.</param>
1315 /// <param name="end">The end point of the range.</param>
1316 /// <param name="x">The value to normalize to the range.</param>
1317 /// <returns>The componentwise interpolation parameter of x with respect to the input range [a, b].</returns>
1318 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1319 public static double2 unlerp(double2 start, double2 end, double2 x) { return (x - start) / (end - start); }
1320
1321 /// <summary>Returns the componentwise result of normalizing a floating point value x to a range [a, b]. The opposite of lerp. Equivalent to (x - a) / (b - a).</summary>
1322 /// <param name="start">The start point of the range.</param>
1323 /// <param name="end">The end point of the range.</param>
1324 /// <param name="x">The value to normalize to the range.</param>
1325 /// <returns>The componentwise interpolation parameter of x with respect to the input range [a, b].</returns>
1326 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1327 public static double3 unlerp(double3 start, double3 end, double3 x) { return (x - start) / (end - start); }
1328
1329 /// <summary>Returns the componentwise result of normalizing a floating point value x to a range [a, b]. The opposite of lerp. Equivalent to (x - a) / (b - a).</summary>
1330 /// <param name="start">The start point of the range.</param>
1331 /// <param name="end">The end point of the range.</param>
1332 /// <param name="x">The value to normalize to the range.</param>
1333 /// <returns>The componentwise interpolation parameter of x with respect to the input range [a, b].</returns>
1334 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1335 public static double4 unlerp(double4 start, double4 end, double4 x) { return (x - start) / (end - start); }
1336
1337
1338 /// <summary>Returns the result of a non-clamping linear remapping of a value x from source range [srcStart, srcEnd] to the destination range [dstStart, dstEnd].</summary>
1339 /// <param name="srcStart">The start point of the source range [srcStart, srcEnd].</param>
1340 /// <param name="srcEnd">The end point of the source range [srcStart, srcEnd].</param>
1341 /// <param name="dstStart">The start point of the destination range [dstStart, dstEnd].</param>
1342 /// <param name="dstEnd">The end point of the destination range [dstStart, dstEnd].</param>
1343 /// <param name="x">The value to remap from the source to destination range.</param>
1344 /// <returns>The remap of input x from the source range to the destination range.</returns>
1345 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1346 public static float remap(float srcStart, float srcEnd, float dstStart, float dstEnd, float x) { return lerp(dstStart, dstEnd, unlerp(srcStart, srcEnd, x)); }
1347
1348 /// <summary>Returns the componentwise result of a non-clamping linear remapping of a value x from source range [srcStart, srcEnd] to the destination range [dstStart, dstEnd].</summary>
1349 /// <param name="srcStart">The start point of the source range [srcStart, srcEnd].</param>
1350 /// <param name="srcEnd">The end point of the source range [srcStart, srcEnd].</param>
1351 /// <param name="dstStart">The start point of the destination range [dstStart, dstEnd].</param>
1352 /// <param name="dstEnd">The end point of the destination range [dstStart, dstEnd].</param>
1353 /// <param name="x">The value to remap from the source to destination range.</param>
1354 /// <returns>The componentwise remap of input x from the source range to the destination range.</returns>
1355 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1356 public static float2 remap(float2 srcStart, float2 srcEnd, float2 dstStart, float2 dstEnd, float2 x) { return lerp(dstStart, dstEnd, unlerp(srcStart, srcEnd, x)); }
1357
1358 /// <summary>Returns the componentwise result of a non-clamping linear remapping of a value x from source range [srcStart, srcEnd] to the destination range [dstStart, dstEnd].</summary>
1359 /// <param name="srcStart">The start point of the source range [srcStart, srcEnd].</param>
1360 /// <param name="srcEnd">The end point of the source range [srcStart, srcEnd].</param>
1361 /// <param name="dstStart">The start point of the destination range [dstStart, dstEnd].</param>
1362 /// <param name="dstEnd">The end point of the destination range [dstStart, dstEnd].</param>
1363 /// <param name="x">The value to remap from the source to destination range.</param>
1364 /// <returns>The componentwise remap of input x from the source range to the destination range.</returns>
1365 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1366 public static float3 remap(float3 srcStart, float3 srcEnd, float3 dstStart, float3 dstEnd, float3 x) { return lerp(dstStart, dstEnd, unlerp(srcStart, srcEnd, x)); }
1367
1368 /// <summary>Returns the componentwise result of a non-clamping linear remapping of a value x from source range [srcStart, srcEnd] to the destination range [dstStart, dstEnd].</summary>
1369 /// <param name="srcStart">The start point of the source range [srcStart, srcEnd].</param>
1370 /// <param name="srcEnd">The end point of the source range [srcStart, srcEnd].</param>
1371 /// <param name="dstStart">The start point of the destination range [dstStart, dstEnd].</param>
1372 /// <param name="dstEnd">The end point of the destination range [dstStart, dstEnd].</param>
1373 /// <param name="x">The value to remap from the source to destination range.</param>
1374 /// <returns>The componentwise remap of input x from the source range to the destination range.</returns>
1375 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1376 public static float4 remap(float4 srcStart, float4 srcEnd, float4 dstStart, float4 dstEnd, float4 x) { return lerp(dstStart, dstEnd, unlerp(srcStart, srcEnd, x)); }
1377
1378
1379 /// <summary>Returns the result of a non-clamping linear remapping of a value x from source range [srcStart, srcEnd] to the destination range [dstStart, dstEnd].</summary>
1380 /// <param name="srcStart">The start point of the source range [srcStart, srcEnd].</param>
1381 /// <param name="srcEnd">The end point of the source range [srcStart, srcEnd].</param>
1382 /// <param name="dstStart">The start point of the destination range [dstStart, dstEnd].</param>
1383 /// <param name="dstEnd">The end point of the destination range [dstStart, dstEnd].</param>
1384 /// <param name="x">The value to remap from the source to destination range.</param>
1385 /// <returns>The remap of input x from the source range to the destination range.</returns>
1386 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1387 public static double remap(double srcStart, double srcEnd, double dstStart, double dstEnd, double x) { return lerp(dstStart, dstEnd, unlerp(srcStart, srcEnd, x)); }
1388
1389 /// <summary>Returns the componentwise result of a non-clamping linear remapping of a value x from source range [srcStart, srcEnd] to the destination range [dstStart, dstEnd].</summary>
1390 /// <param name="srcStart">The start point of the source range [srcStart, srcEnd].</param>
1391 /// <param name="srcEnd">The end point of the source range [srcStart, srcEnd].</param>
1392 /// <param name="dstStart">The start point of the destination range [dstStart, dstEnd].</param>
1393 /// <param name="dstEnd">The end point of the destination range [dstStart, dstEnd].</param>
1394 /// <param name="x">The value to remap from the source to destination range.</param>
1395 /// <returns>The componentwise remap of input x from the source range to the destination range.</returns>
1396 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1397 public static double2 remap(double2 srcStart, double2 srcEnd, double2 dstStart, double2 dstEnd, double2 x) { return lerp(dstStart, dstEnd, unlerp(srcStart, srcEnd, x)); }
1398
1399 /// <summary>Returns the componentwise result of a non-clamping linear remapping of a value x from source range [srcStart, srcEnd] to the destination range [dstStart, dstEnd].</summary>
1400 /// <param name="srcStart">The start point of the source range [srcStart, srcEnd].</param>
1401 /// <param name="srcEnd">The end point of the source range [srcStart, srcEnd].</param>
1402 /// <param name="dstStart">The start point of the destination range [dstStart, dstEnd].</param>
1403 /// <param name="dstEnd">The end point of the destination range [dstStart, dstEnd].</param>
1404 /// <param name="x">The value to remap from the source to destination range.</param>
1405 /// <returns>The componentwise remap of input x from the source range to the destination range.</returns>
1406 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1407 public static double3 remap(double3 srcStart, double3 srcEnd, double3 dstStart, double3 dstEnd, double3 x) { return lerp(dstStart, dstEnd, unlerp(srcStart, srcEnd, x)); }
1408
1409 /// <summary>Returns the componentwise result of a non-clamping linear remapping of a value x from source range [srcStart, srcEnd] to the destination range [dstStart, dstEnd].</summary>
1410 /// <param name="srcStart">The start point of the source range [srcStart, srcEnd].</param>
1411 /// <param name="srcEnd">The end point of the source range [srcStart, srcEnd].</param>
1412 /// <param name="dstStart">The start point of the destination range [dstStart, dstEnd].</param>
1413 /// <param name="dstEnd">The end point of the destination range [dstStart, dstEnd].</param>
1414 /// <param name="x">The value to remap from the source to destination range.</param>
1415 /// <returns>The componentwise remap of input x from the source range to the destination range.</returns>
1416 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1417 public static double4 remap(double4 srcStart, double4 srcEnd, double4 dstStart, double4 dstEnd, double4 x) { return lerp(dstStart, dstEnd, unlerp(srcStart, srcEnd, x)); }
1418
1419
1420 /// <summary>Returns the result of a multiply-add operation (a * b + c) on 3 int values.</summary>
1421 /// <param name="mulA">First value to multiply.</param>
1422 /// <param name="mulB">Second value to multiply.</param>
1423 /// <param name="addC">Third value to add to the product of a and b.</param>
1424 /// <returns>The multiply-add of the inputs.</returns>
1425 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1426 public static int mad(int mulA, int mulB, int addC) { return mulA * mulB + addC; }
1427
1428 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 int2 vectors.</summary>
1429 /// <param name="mulA">First value to multiply.</param>
1430 /// <param name="mulB">Second value to multiply.</param>
1431 /// <param name="addC">Third value to add to the product of a and b.</param>
1432 /// <returns>The componentwise multiply-add of the inputs.</returns>
1433 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1434 public static int2 mad(int2 mulA, int2 mulB, int2 addC) { return mulA * mulB + addC; }
1435
1436 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 int3 vectors.</summary>
1437 /// <param name="mulA">First value to multiply.</param>
1438 /// <param name="mulB">Second value to multiply.</param>
1439 /// <param name="addC">Third value to add to the product of a and b.</param>
1440 /// <returns>The componentwise multiply-add of the inputs.</returns>
1441 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1442 public static int3 mad(int3 mulA, int3 mulB, int3 addC) { return mulA * mulB + addC; }
1443
1444 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 int4 vectors.</summary>
1445 /// <param name="mulA">First value to multiply.</param>
1446 /// <param name="mulB">Second value to multiply.</param>
1447 /// <param name="addC">Third value to add to the product of a and b.</param>
1448 /// <returns>The componentwise multiply-add of the inputs.</returns>
1449 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1450 public static int4 mad(int4 mulA, int4 mulB, int4 addC) { return mulA * mulB + addC; }
1451
1452
1453 /// <summary>Returns the result of a multiply-add operation (a * b + c) on 3 uint values.</summary>
1454 /// <param name="mulA">First value to multiply.</param>
1455 /// <param name="mulB">Second value to multiply.</param>
1456 /// <param name="addC">Third value to add to the product of a and b.</param>
1457 /// <returns>The multiply-add of the inputs.</returns>
1458 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1459 public static uint mad(uint mulA, uint mulB, uint addC) { return mulA * mulB + addC; }
1460
1461 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 uint2 vectors.</summary>
1462 /// <param name="mulA">First value to multiply.</param>
1463 /// <param name="mulB">Second value to multiply.</param>
1464 /// <param name="addC">Third value to add to the product of a and b.</param>
1465 /// <returns>The componentwise multiply-add of the inputs.</returns>
1466 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1467 public static uint2 mad(uint2 mulA, uint2 mulB, uint2 addC) { return mulA * mulB + addC; }
1468
1469 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 uint3 vectors.</summary>
1470 /// <param name="mulA">First value to multiply.</param>
1471 /// <param name="mulB">Second value to multiply.</param>
1472 /// <param name="addC">Third value to add to the product of a and b.</param>
1473 /// <returns>The componentwise multiply-add of the inputs.</returns>
1474 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1475 public static uint3 mad(uint3 mulA, uint3 mulB, uint3 addC) { return mulA * mulB + addC; }
1476
1477 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 uint4 vectors.</summary>
1478 /// <param name="mulA">First value to multiply.</param>
1479 /// <param name="mulB">Second value to multiply.</param>
1480 /// <param name="addC">Third value to add to the product of a and b.</param>
1481 /// <returns>The componentwise multiply-add of the inputs.</returns>
1482 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1483 public static uint4 mad(uint4 mulA, uint4 mulB, uint4 addC) { return mulA * mulB + addC; }
1484
1485
1486 /// <summary>Returns the result of a multiply-add operation (a * b + c) on 3 long values.</summary>
1487 /// <param name="mulA">First value to multiply.</param>
1488 /// <param name="mulB">Second value to multiply.</param>
1489 /// <param name="addC">Third value to add to the product of a and b.</param>
1490 /// <returns>The multiply-add of the inputs.</returns>
1491 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1492 public static long mad(long mulA, long mulB, long addC) { return mulA * mulB + addC; }
1493
1494
1495 /// <summary>Returns the result of a multiply-add operation (a * b + c) on 3 ulong values.</summary>
1496 /// <param name="mulA">First value to multiply.</param>
1497 /// <param name="mulB">Second value to multiply.</param>
1498 /// <param name="addC">Third value to add to the product of a and b.</param>
1499 /// <returns>The multiply-add of the inputs.</returns>
1500 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1501 public static ulong mad(ulong mulA, ulong mulB, ulong addC) { return mulA * mulB + addC; }
1502
1503
1504 /// <summary>Returns the result of a multiply-add operation (a * b + c) on 3 float values.</summary>
1505 /// <remarks>
1506 /// When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA).
1507 /// FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when
1508 /// this computation is not fused.
1509 /// </remarks>
1510 /// <param name="mulA">First value to multiply.</param>
1511 /// <param name="mulB">Second value to multiply.</param>
1512 /// <param name="addC">Third value to add to the product of a and b.</param>
1513 /// <returns>The multiply-add of the inputs.</returns>
1514 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1515 public static float mad(float mulA, float mulB, float addC) { return mulA * mulB + addC; }
1516
1517 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 float2 vectors.</summary>
1518 /// <remarks>
1519 /// When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA).
1520 /// FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when
1521 /// this computation is not fused.
1522 /// </remarks>
1523 /// <param name="mulA">First value to multiply.</param>
1524 /// <param name="mulB">Second value to multiply.</param>
1525 /// <param name="addC">Third value to add to the product of a and b.</param>
1526 /// <returns>The componentwise multiply-add of the inputs.</returns>
1527 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1528 public static float2 mad(float2 mulA, float2 mulB, float2 addC) { return mulA * mulB + addC; }
1529
1530 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 float3 vectors.</summary>
1531 /// <remarks>
1532 /// When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA).
1533 /// FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when
1534 /// this computation is not fused.
1535 /// </remarks>
1536 /// <param name="mulA">First value to multiply.</param>
1537 /// <param name="mulB">Second value to multiply.</param>
1538 /// <param name="addC">Third value to add to the product of a and b.</param>
1539 /// <returns>The componentwise multiply-add of the inputs.</returns>
1540 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1541 public static float3 mad(float3 mulA, float3 mulB, float3 addC) { return mulA * mulB + addC; }
1542
1543 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 float4 vectors.</summary>
1544 /// <remarks>
1545 /// When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA).
1546 /// FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when
1547 /// this computation is not fused.
1548 /// </remarks>
1549 /// <param name="mulA">First value to multiply.</param>
1550 /// <param name="mulB">Second value to multiply.</param>
1551 /// <param name="addC">Third value to add to the product of a and b.</param>
1552 /// <returns>The componentwise multiply-add of the inputs.</returns>
1553 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1554 public static float4 mad(float4 mulA, float4 mulB, float4 addC) { return mulA * mulB + addC; }
1555
1556
1557 /// <summary>Returns the result of a multiply-add operation (a * b + c) on 3 double values.</summary>
1558 /// <remarks>
1559 /// When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA).
1560 /// FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when
1561 /// this computation is not fused.
1562 /// </remarks>
1563 /// <param name="mulA">First value to multiply.</param>
1564 /// <param name="mulB">Second value to multiply.</param>
1565 /// <param name="addC">Third value to add to the product of a and b.</param>
1566 /// <returns>The multiply-add of the inputs.</returns>
1567 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1568 public static double mad(double mulA, double mulB, double addC) { return mulA * mulB + addC; }
1569
1570 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 double2 vectors.</summary>
1571 /// <remarks>
1572 /// When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA).
1573 /// FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when
1574 /// this computation is not fused.
1575 /// </remarks>
1576 /// <param name="mulA">First value to multiply.</param>
1577 /// <param name="mulB">Second value to multiply.</param>
1578 /// <param name="addC">Third value to add to the product of a and b.</param>
1579 /// <returns>The componentwise multiply-add of the inputs.</returns>
1580 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1581 public static double2 mad(double2 mulA, double2 mulB, double2 addC) { return mulA * mulB + addC; }
1582
1583 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 double3 vectors.</summary>
1584 /// <remarks>
1585 /// When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA).
1586 /// FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when
1587 /// this computation is not fused.
1588 /// </remarks>
1589 /// <param name="mulA">First value to multiply.</param>
1590 /// <param name="mulB">Second value to multiply.</param>
1591 /// <param name="addC">Third value to add to the product of a and b.</param>
1592 /// <returns>The componentwise multiply-add of the inputs.</returns>
1593 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1594 public static double3 mad(double3 mulA, double3 mulB, double3 addC) { return mulA * mulB + addC; }
1595
1596 /// <summary>Returns the result of a componentwise multiply-add operation (a * b + c) on 3 double4 vectors.</summary>
1597 /// <remarks>
1598 /// When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA).
1599 /// FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when
1600 /// this computation is not fused.
1601 /// </remarks>
1602 /// <param name="mulA">First value to multiply.</param>
1603 /// <param name="mulB">Second value to multiply.</param>
1604 /// <param name="addC">Third value to add to the product of a and b.</param>
1605 /// <returns>The componentwise multiply-add of the inputs.</returns>
1606 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1607 public static double4 mad(double4 mulA, double4 mulB, double4 addC) { return mulA * mulB + addC; }
1608
1609
1610 /// <summary>Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are int values.</summary>
1611 /// <param name="valueToClamp">Input value to be clamped.</param>
1612 /// <param name="lowerBound">Lower bound of the interval.</param>
1613 /// <param name="upperBound">Upper bound of the interval.</param>
1614 /// <returns>The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1615 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1616 public static int clamp(int valueToClamp, int lowerBound, int upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1617
1618 /// <summary>Returns the result of a componentwise clamping of the int2 x into the interval [a, b], where a and b are int2 vectors.</summary>
1619 /// <param name="valueToClamp">Input value to be clamped.</param>
1620 /// <param name="lowerBound">Lower bound of the interval.</param>
1621 /// <param name="upperBound">Upper bound of the interval.</param>
1622 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1623 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1624 public static int2 clamp(int2 valueToClamp, int2 lowerBound, int2 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1625
1626 /// <summary>Returns the result of a componentwise clamping of the int3 x into the interval [a, b], where x, a and b are int3 vectors.</summary>
1627 /// <param name="valueToClamp">Input value to be clamped.</param>
1628 /// <param name="lowerBound">Lower bound of the interval.</param>
1629 /// <param name="upperBound">Upper bound of the interval.</param>
1630 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1631 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1632 public static int3 clamp(int3 valueToClamp, int3 lowerBound, int3 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1633
1634 /// <summary>Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are int4 vectors.</summary>
1635 /// <param name="valueToClamp">Input value to be clamped.</param>
1636 /// <param name="lowerBound">Lower bound of the interval.</param>
1637 /// <param name="upperBound">Upper bound of the interval.</param>
1638 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1639 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1640 public static int4 clamp(int4 valueToClamp, int4 lowerBound, int4 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1641
1642
1643 /// <summary>Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are uint values.</summary>
1644 /// <param name="valueToClamp">Input value to be clamped.</param>
1645 /// <param name="lowerBound">Lower bound of the interval.</param>
1646 /// <param name="upperBound">Upper bound of the interval.</param>
1647 /// <returns>The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1648 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1649 public static uint clamp(uint valueToClamp, uint lowerBound, uint upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1650
1651 /// <summary>Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are uint2 vectors.</summary>
1652 /// <param name="valueToClamp">Input value to be clamped.</param>
1653 /// <param name="lowerBound">Lower bound of the interval.</param>
1654 /// <param name="upperBound">Upper bound of the interval.</param>
1655 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1656 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1657 public static uint2 clamp(uint2 valueToClamp, uint2 lowerBound, uint2 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1658
1659 /// <summary>Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are uint3 vectors.</summary>
1660 /// <param name="valueToClamp">Input value to be clamped.</param>
1661 /// <param name="lowerBound">Lower bound of the interval.</param>
1662 /// <param name="upperBound">Upper bound of the interval.</param>
1663 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1664 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1665 public static uint3 clamp(uint3 valueToClamp, uint3 lowerBound, uint3 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1666
1667 /// <summary>Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are uint4 vectors.</summary>
1668 /// <param name="valueToClamp">Input value to be clamped.</param>
1669 /// <param name="lowerBound">Lower bound of the interval.</param>
1670 /// <param name="upperBound">Upper bound of the interval.</param>
1671 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1672 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1673 public static uint4 clamp(uint4 valueToClamp, uint4 lowerBound, uint4 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1674
1675
1676 /// <summary>Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are long values.</summary>
1677 /// <param name="valueToClamp">Input value to be clamped.</param>
1678 /// <param name="lowerBound">Lower bound of the interval.</param>
1679 /// <param name="upperBound">Upper bound of the interval.</param>
1680 /// <returns>The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1681 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1682 public static long clamp(long valueToClamp, long lowerBound, long upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1683
1684 /// <summary>Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are ulong values.</summary>
1685 /// <param name="valueToClamp">Input value to be clamped.</param>
1686 /// <param name="lowerBound">Lower bound of the interval.</param>
1687 /// <param name="upperBound">Upper bound of the interval.</param>
1688 /// <returns>The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1689 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1690 public static ulong clamp(ulong valueToClamp, ulong lowerBound, ulong upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1691
1692
1693 /// <summary>Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are float values.</summary>
1694 /// <param name="valueToClamp">Input value to be clamped.</param>
1695 /// <param name="lowerBound">Lower bound of the interval.</param>
1696 /// <param name="upperBound">Upper bound of the interval.</param>
1697 /// <returns>The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1698 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1699 public static float clamp(float valueToClamp, float lowerBound, float upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1700
1701 /// <summary>Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are float2 vectors.</summary>
1702 /// <param name="valueToClamp">Input value to be clamped.</param>
1703 /// <param name="lowerBound">Lower bound of the interval.</param>
1704 /// <param name="upperBound">Upper bound of the interval.</param>
1705 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1706 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1707 public static float2 clamp(float2 valueToClamp, float2 lowerBound, float2 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1708
1709 /// <summary>Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are float3 vectors.</summary>
1710 /// <param name="valueToClamp">Input value to be clamped.</param>
1711 /// <param name="lowerBound">Lower bound of the interval.</param>
1712 /// <param name="upperBound">Upper bound of the interval.</param>
1713 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1714 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1715 public static float3 clamp(float3 valueToClamp, float3 lowerBound, float3 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1716
1717 /// <summary>Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are float4 vectors.</summary>
1718 /// <param name="valueToClamp">Input value to be clamped.</param>
1719 /// <param name="lowerBound">Lower bound of the interval.</param>
1720 /// <param name="upperBound">Upper bound of the interval.</param>
1721 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1722 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1723 public static float4 clamp(float4 valueToClamp, float4 lowerBound, float4 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1724
1725
1726 /// <summary>Returns the result of clamping the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are double values.</summary>
1727 /// <param name="valueToClamp">Input value to be clamped.</param>
1728 /// <param name="lowerBound">Lower bound of the interval.</param>
1729 /// <param name="upperBound">Upper bound of the interval.</param>
1730 /// <returns>The clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1731 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1732 public static double clamp(double valueToClamp, double lowerBound, double upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1733
1734 /// <summary>Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are double2 vectors.</summary>
1735 /// <param name="valueToClamp">Input value to be clamped.</param>
1736 /// <param name="lowerBound">Lower bound of the interval.</param>
1737 /// <param name="upperBound">Upper bound of the interval.</param>
1738 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1739 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1740 public static double2 clamp(double2 valueToClamp, double2 lowerBound, double2 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1741
1742 /// <summary>Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are double3 vectors.</summary>
1743 /// <param name="valueToClamp">Input value to be clamped.</param>
1744 /// <param name="lowerBound">Lower bound of the interval.</param>
1745 /// <param name="upperBound">Upper bound of the interval.</param>
1746 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1747 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1748 public static double3 clamp(double3 valueToClamp, double3 lowerBound, double3 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1749
1750 /// <summary>Returns the result of a componentwise clamping of the value valueToClamp into the interval (inclusive) [lowerBound, upperBound], where valueToClamp, lowerBound and upperBound are double4 vectors.</summary>
1751 /// <param name="valueToClamp">Input value to be clamped.</param>
1752 /// <param name="lowerBound">Lower bound of the interval.</param>
1753 /// <param name="upperBound">Upper bound of the interval.</param>
1754 /// <returns>The componentwise clamping of the input valueToClamp into the interval (inclusive) [lowerBound, upperBound].</returns>
1755 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1756 public static double4 clamp(double4 valueToClamp, double4 lowerBound, double4 upperBound) { return max(lowerBound, min(upperBound, valueToClamp)); }
1757
1758
1759 /// <summary>Returns the result of clamping the float value x into the interval [0, 1].</summary>
1760 /// <param name="x">Input value.</param>
1761 /// <returns>The clamping of the input into the interval [0, 1].</returns>
1762 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1763 public static float saturate(float x) { return clamp(x, 0.0f, 1.0f); }
1764
1765 /// <summary>Returns the result of a componentwise clamping of the float2 vector x into the interval [0, 1].</summary>
1766 /// <param name="x">Input value.</param>
1767 /// <returns>The componentwise clamping of the input into the interval [0, 1].</returns>
1768 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1769 public static float2 saturate(float2 x) { return clamp(x, new float2(0.0f), new float2(1.0f)); }
1770
1771 /// <summary>Returns the result of a componentwise clamping of the float3 vector x into the interval [0, 1].</summary>
1772 /// <param name="x">Input value.</param>
1773 /// <returns>The componentwise clamping of the input into the interval [0, 1].</returns>
1774 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1775 public static float3 saturate(float3 x) { return clamp(x, new float3(0.0f), new float3(1.0f)); }
1776
1777 /// <summary>Returns the result of a componentwise clamping of the float4 vector x into the interval [0, 1].</summary>
1778 /// <param name="x">Input value.</param>
1779 /// <returns>The componentwise clamping of the input into the interval [0, 1].</returns>
1780 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1781 public static float4 saturate(float4 x) { return clamp(x, new float4(0.0f), new float4(1.0f)); }
1782
1783
1784 /// <summary>Returns the result of clamping the double value x into the interval [0, 1].</summary>
1785 /// <param name="x">Input value.</param>
1786 /// <returns>The clamping of the input into the interval [0, 1].</returns>
1787 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1788 public static double saturate(double x) { return clamp(x, 0.0, 1.0); }
1789
1790 /// <summary>Returns the result of a componentwise clamping of the double2 vector x into the interval [0, 1].</summary>
1791 /// <param name="x">Input value.</param>
1792 /// <returns>The componentwise clamping of the input into the interval [0, 1].</returns>
1793 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1794 public static double2 saturate(double2 x) { return clamp(x, new double2(0.0), new double2(1.0)); }
1795
1796 /// <summary>Returns the result of a componentwise clamping of the double3 vector x into the interval [0, 1].</summary>
1797 /// <param name="x">Input value.</param>
1798 /// <returns>The componentwise clamping of the input into the interval [0, 1].</returns>
1799 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1800 public static double3 saturate(double3 x) { return clamp(x, new double3(0.0), new double3(1.0)); }
1801
1802 /// <summary>Returns the result of a componentwise clamping of the double4 vector x into the interval [0, 1].</summary>
1803 /// <param name="x">Input value.</param>
1804 /// <returns>The componentwise clamping of the input into the interval [0, 1].</returns>
1805 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1806 public static double4 saturate(double4 x) { return clamp(x, new double4(0.0), new double4(1.0)); }
1807
1808
1809 /// <summary>Returns the absolute value of a int value.</summary>
1810 /// <param name="x">Input value.</param>
1811 /// <returns>The absolute value of the input.</returns>
1812 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1813 public static int abs(int x) { return max(-x, x); }
1814
1815 /// <summary>Returns the componentwise absolute value of a int2 vector.</summary>
1816 /// <param name="x">Input value.</param>
1817 /// <returns>The componentwise absolute value of the input.</returns>
1818 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1819 public static int2 abs(int2 x) { return max(-x, x); }
1820
1821 /// <summary>Returns the componentwise absolute value of a int3 vector.</summary>
1822 /// <param name="x">Input value.</param>
1823 /// <returns>The componentwise absolute value of the input.</returns>
1824 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1825 public static int3 abs(int3 x) { return max(-x, x); }
1826
1827 /// <summary>Returns the componentwise absolute value of a int4 vector.</summary>
1828 /// <param name="x">Input value.</param>
1829 /// <returns>The componentwise absolute value of the input.</returns>
1830 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1831 public static int4 abs(int4 x) { return max(-x, x); }
1832
1833 /// <summary>Returns the absolute value of a long value.</summary>
1834 /// <param name="x">Input value.</param>
1835 /// <returns>The absolute value of the input.</returns>
1836 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1837 public static long abs(long x) { return max(-x, x); }
1838
1839
1840 /// <summary>Returns the absolute value of a float value.</summary>
1841 /// <param name="x">Input value.</param>
1842 /// <returns>The absolute value of the input.</returns>
1843 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1844 public static float abs(float x) { return asfloat(asuint(x) & 0x7FFFFFFF); }
1845
1846 /// <summary>Returns the componentwise absolute value of a float2 vector.</summary>
1847 /// <param name="x">Input value.</param>
1848 /// <returns>The componentwise absolute value of the input.</returns>
1849 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1850 public static float2 abs(float2 x) { return asfloat(asuint(x) & 0x7FFFFFFF); }
1851
1852 /// <summary>Returns the componentwise absolute value of a float3 vector.</summary>
1853 /// <param name="x">Input value.</param>
1854 /// <returns>The componentwise absolute value of the input.</returns>
1855 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1856 public static float3 abs(float3 x) { return asfloat(asuint(x) & 0x7FFFFFFF); }
1857
1858 /// <summary>Returns the componentwise absolute value of a float4 vector.</summary>
1859 /// <param name="x">Input value.</param>
1860 /// <returns>The componentwise absolute value of the input.</returns>
1861 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1862 public static float4 abs(float4 x) { return asfloat(asuint(x) & 0x7FFFFFFF); }
1863
1864
1865 /// <summary>Returns the absolute value of a double value.</summary>
1866 /// <param name="x">Input value.</param>
1867 /// <returns>The absolute value of the input.</returns>
1868 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1869 public static double abs(double x) { return asdouble(asulong(x) & 0x7FFFFFFFFFFFFFFF); }
1870
1871 /// <summary>Returns the componentwise absolute value of a double2 vector.</summary>
1872 /// <param name="x">Input value.</param>
1873 /// <returns>The componentwise absolute value of the input.</returns>
1874 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1875 public static double2 abs(double2 x) { return double2(asdouble(asulong(x.x) & 0x7FFFFFFFFFFFFFFF), asdouble(asulong(x.y) & 0x7FFFFFFFFFFFFFFF)); }
1876
1877 /// <summary>Returns the componentwise absolute value of a double3 vector.</summary>
1878 /// <param name="x">Input value.</param>
1879 /// <returns>The componentwise absolute value of the input.</returns>
1880 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1881 public static double3 abs(double3 x) { return double3(asdouble(asulong(x.x) & 0x7FFFFFFFFFFFFFFF), asdouble(asulong(x.y) & 0x7FFFFFFFFFFFFFFF), asdouble(asulong(x.z) & 0x7FFFFFFFFFFFFFFF)); }
1882
1883 /// <summary>Returns the componentwise absolute value of a double4 vector.</summary>
1884 /// <param name="x">Input value.</param>
1885 /// <returns>The componentwise absolute value of the input.</returns>
1886 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1887 public static double4 abs(double4 x) { return double4(asdouble(asulong(x.x) & 0x7FFFFFFFFFFFFFFF), asdouble(asulong(x.y) & 0x7FFFFFFFFFFFFFFF), asdouble(asulong(x.z) & 0x7FFFFFFFFFFFFFFF), asdouble(asulong(x.w) & 0x7FFFFFFFFFFFFFFF)); }
1888
1889
1890 /// <summary>Returns the dot product of two int values. Equivalent to multiplication.</summary>
1891 /// <param name="x">The first value.</param>
1892 /// <param name="y">The second value.</param>
1893 /// <returns>The dot product of two values.</returns>
1894 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1895 public static int dot(int x, int y) { return x * y; }
1896
1897 /// <summary>Returns the dot product of two int2 vectors.</summary>
1898 /// <param name="x">The first vector.</param>
1899 /// <param name="y">The second vector.</param>
1900 /// <returns>The dot product of two vectors.</returns>
1901 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1902 public static int dot(int2 x, int2 y) { return x.x * y.x + x.y * y.y; }
1903
1904 /// <summary>Returns the dot product of two int3 vectors.</summary>
1905 /// <param name="x">The first vector.</param>
1906 /// <param name="y">The second vector.</param>
1907 /// <returns>The dot product of two vectors.</returns>
1908 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1909 public static int dot(int3 x, int3 y) { return x.x * y.x + x.y * y.y + x.z * y.z; }
1910
1911 /// <summary>Returns the dot product of two int4 vectors.</summary>
1912 /// <param name="x">The first vector.</param>
1913 /// <param name="y">The second vector.</param>
1914 /// <returns>The dot product of two vectors.</returns>
1915 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1916 public static int dot(int4 x, int4 y) { return x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w; }
1917
1918
1919 /// <summary>Returns the dot product of two uint values. Equivalent to multiplication.</summary>
1920 /// <param name="x">The first value.</param>
1921 /// <param name="y">The second value.</param>
1922 /// <returns>The dot product of two values.</returns>
1923 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1924 public static uint dot(uint x, uint y) { return x * y; }
1925
1926 /// <summary>Returns the dot product of two uint2 vectors.</summary>
1927 /// <param name="x">The first vector.</param>
1928 /// <param name="y">The second vector.</param>
1929 /// <returns>The dot product of two vectors.</returns>
1930 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1931 public static uint dot(uint2 x, uint2 y) { return x.x * y.x + x.y * y.y; }
1932
1933 /// <summary>Returns the dot product of two uint3 vectors.</summary>
1934 /// <param name="x">The first vector.</param>
1935 /// <param name="y">The second vector.</param>
1936 /// <returns>The dot product of two vectors.</returns>
1937 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1938 public static uint dot(uint3 x, uint3 y) { return x.x * y.x + x.y * y.y + x.z * y.z; }
1939
1940 /// <summary>Returns the dot product of two uint4 vectors.</summary>
1941 /// <param name="x">The first vector.</param>
1942 /// <param name="y">The second vector.</param>
1943 /// <returns>The dot product of two vectors.</returns>
1944 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1945 public static uint dot(uint4 x, uint4 y) { return x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w; }
1946
1947
1948 /// <summary>Returns the dot product of two float values. Equivalent to multiplication.</summary>
1949 /// <param name="x">The first value.</param>
1950 /// <param name="y">The second value.</param>
1951 /// <returns>The dot product of two values.</returns>
1952 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1953 public static float dot(float x, float y) { return x * y; }
1954
1955 /// <summary>Returns the dot product of two float2 vectors.</summary>
1956 /// <param name="x">The first vector.</param>
1957 /// <param name="y">The second vector.</param>
1958 /// <returns>The dot product of two vectors.</returns>
1959 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1960 public static float dot(float2 x, float2 y) { return x.x * y.x + x.y * y.y; }
1961
1962 /// <summary>Returns the dot product of two float3 vectors.</summary>
1963 /// <param name="x">The first vector.</param>
1964 /// <param name="y">The second vector.</param>
1965 /// <returns>The dot product of two vectors.</returns>
1966 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1967 public static float dot(float3 x, float3 y) { return x.x * y.x + x.y * y.y + x.z * y.z; }
1968
1969 /// <summary>Returns the dot product of two float4 vectors.</summary>
1970 /// <param name="x">The first vector.</param>
1971 /// <param name="y">The second vector.</param>
1972 /// <returns>The dot product of two vectors.</returns>
1973 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1974 public static float dot(float4 x, float4 y) { return x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w; }
1975
1976
1977 /// <summary>Returns the dot product of two double values. Equivalent to multiplication.</summary>
1978 /// <param name="x">The first value.</param>
1979 /// <param name="y">The second value.</param>
1980 /// <returns>The dot product of two values.</returns>
1981 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1982 public static double dot(double x, double y) { return x * y; }
1983
1984 /// <summary>Returns the dot product of two double2 vectors.</summary>
1985 /// <param name="x">The first vector.</param>
1986 /// <param name="y">The second vector.</param>
1987 /// <returns>The dot product of two vectors.</returns>
1988 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1989 public static double dot(double2 x, double2 y) { return x.x * y.x + x.y * y.y; }
1990
1991 /// <summary>Returns the dot product of two double3 vectors.</summary>
1992 /// <param name="x">The first vector.</param>
1993 /// <param name="y">The second vector.</param>
1994 /// <returns>The dot product of two vectors.</returns>
1995 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1996 public static double dot(double3 x, double3 y) { return x.x * y.x + x.y * y.y + x.z * y.z; }
1997
1998 /// <summary>Returns the dot product of two double4 vectors.</summary>
1999 /// <param name="x">The first vector.</param>
2000 /// <param name="y">The second vector.</param>
2001 /// <returns>The dot product of two vectors.</returns>
2002 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2003 public static double dot(double4 x, double4 y) { return x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w; }
2004
2005
2006 /// <summary>Returns the tangent of a float value.</summary>
2007 /// <param name="x">Input value.</param>
2008 /// <returns>The tangent of the input.</returns>
2009 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2010 public static float tan(float x) { return (float)System.Math.Tan(x); }
2011
2012 /// <summary>Returns the componentwise tangent of a float2 vector.</summary>
2013 /// <param name="x">Input value.</param>
2014 /// <returns>The componentwise tangent of the input.</returns>
2015 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2016 public static float2 tan(float2 x) { return new float2(tan(x.x), tan(x.y)); }
2017
2018 /// <summary>Returns the componentwise tangent of a float3 vector.</summary>
2019 /// <param name="x">Input value.</param>
2020 /// <returns>The componentwise tangent of the input.</returns>
2021 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2022 public static float3 tan(float3 x) { return new float3(tan(x.x), tan(x.y), tan(x.z)); }
2023
2024 /// <summary>Returns the componentwise tangent of a float4 vector.</summary>
2025 /// <param name="x">Input value.</param>
2026 /// <returns>The componentwise tangent of the input.</returns>
2027 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2028 public static float4 tan(float4 x) { return new float4(tan(x.x), tan(x.y), tan(x.z), tan(x.w)); }
2029
2030
2031 /// <summary>Returns the tangent of a double value.</summary>
2032 /// <param name="x">Input value.</param>
2033 /// <returns>The tangent of the input.</returns>
2034 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2035 public static double tan(double x) { return System.Math.Tan(x); }
2036
2037 /// <summary>Returns the componentwise tangent of a double2 vector.</summary>
2038 /// <param name="x">Input value.</param>
2039 /// <returns>The componentwise tangent of the input.</returns>
2040 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2041 public static double2 tan(double2 x) { return new double2(tan(x.x), tan(x.y)); }
2042
2043 /// <summary>Returns the componentwise tangent of a double3 vector.</summary>
2044 /// <param name="x">Input value.</param>
2045 /// <returns>The componentwise tangent of the input.</returns>
2046 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2047 public static double3 tan(double3 x) { return new double3(tan(x.x), tan(x.y), tan(x.z)); }
2048
2049 /// <summary>Returns the componentwise tangent of a double4 vector.</summary>
2050 /// <param name="x">Input value.</param>
2051 /// <returns>The componentwise tangent of the input.</returns>
2052 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2053 public static double4 tan(double4 x) { return new double4(tan(x.x), tan(x.y), tan(x.z), tan(x.w)); }
2054
2055
2056 /// <summary>Returns the hyperbolic tangent of a float value.</summary>
2057 /// <param name="x">Input value.</param>
2058 /// <returns>The hyperbolic tangent of the input.</returns>
2059 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2060 public static float tanh(float x) { return (float)System.Math.Tanh(x); }
2061
2062 /// <summary>Returns the componentwise hyperbolic tangent of a float2 vector.</summary>
2063 /// <param name="x">Input value.</param>
2064 /// <returns>The componentwise hyperbolic tangent of the input.</returns>
2065 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2066 public static float2 tanh(float2 x) { return new float2(tanh(x.x), tanh(x.y)); }
2067
2068 /// <summary>Returns the componentwise hyperbolic tangent of a float3 vector.</summary>
2069 /// <param name="x">Input value.</param>
2070 /// <returns>The componentwise hyperbolic tangent of the input.</returns>
2071 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2072 public static float3 tanh(float3 x) { return new float3(tanh(x.x), tanh(x.y), tanh(x.z)); }
2073
2074 /// <summary>Returns the componentwise hyperbolic tangent of a float4 vector.</summary>
2075 /// <param name="x">Input value.</param>
2076 /// <returns>The componentwise hyperbolic tangent of the input.</returns>
2077 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2078 public static float4 tanh(float4 x) { return new float4(tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)); }
2079
2080
2081 /// <summary>Returns the hyperbolic tangent of a double value.</summary>
2082 /// <param name="x">Input value.</param>
2083 /// <returns>The hyperbolic tangent of the input.</returns>
2084 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2085 public static double tanh(double x) { return System.Math.Tanh(x); }
2086
2087 /// <summary>Returns the componentwise hyperbolic tangent of a double2 vector.</summary>
2088 /// <param name="x">Input value.</param>
2089 /// <returns>The componentwise hyperbolic tangent of the input.</returns>
2090 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2091 public static double2 tanh(double2 x) { return new double2(tanh(x.x), tanh(x.y)); }
2092
2093 /// <summary>Returns the componentwise hyperbolic tangent of a double3 vector.</summary>
2094 /// <param name="x">Input value.</param>
2095 /// <returns>The componentwise hyperbolic tangent of the input.</returns>
2096 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2097 public static double3 tanh(double3 x) { return new double3(tanh(x.x), tanh(x.y), tanh(x.z)); }
2098
2099 /// <summary>Returns the componentwise hyperbolic tangent of a double4 vector.</summary>
2100 /// <param name="x">Input value.</param>
2101 /// <returns>The componentwise hyperbolic tangent of the input.</returns>
2102 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2103 public static double4 tanh(double4 x) { return new double4(tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)); }
2104
2105
2106 /// <summary>Returns the arctangent of a float value.</summary>
2107 /// <param name="x">A tangent value, usually the ratio y/x on the unit circle.</param>
2108 /// <returns>The arctangent of the input, in radians.</returns>
2109 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2110 public static float atan(float x) { return (float)System.Math.Atan(x); }
2111
2112 /// <summary>Returns the componentwise arctangent of a float2 vector.</summary>
2113 /// <param name="x">A tangent value, usually the ratio y/x on the unit circle.</param>
2114 /// <returns>The componentwise arctangent of the input, in radians.</returns>
2115 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2116 public static float2 atan(float2 x) { return new float2(atan(x.x), atan(x.y)); }
2117
2118 /// <summary>Returns the componentwise arctangent of a float3 vector.</summary>
2119 /// <param name="x">A tangent value, usually the ratio y/x on the unit circle.</param>
2120 /// <returns>The componentwise arctangent of the input, in radians.</returns>
2121 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2122 public static float3 atan(float3 x) { return new float3(atan(x.x), atan(x.y), atan(x.z)); }
2123
2124 /// <summary>Returns the componentwise arctangent of a float4 vector.</summary>
2125 /// <param name="x">A tangent value, usually the ratio y/x on the unit circle.</param>
2126 /// <returns>The componentwise arctangent of the input, in radians.</returns>
2127 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2128 public static float4 atan(float4 x) { return new float4(atan(x.x), atan(x.y), atan(x.z), atan(x.w)); }
2129
2130
2131 /// <summary>Returns the arctangent of a double value.</summary>
2132 /// <param name="x">A tangent value, usually the ratio y/x on the unit circle.</param>
2133 /// <returns>The arctangent of the input, in radians.</returns>
2134 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2135 public static double atan(double x) { return System.Math.Atan(x); }
2136
2137 /// <summary>Returns the componentwise arctangent of a double2 vector.</summary>
2138 /// <param name="x">A tangent value, usually the ratio y/x on the unit circle.</param>
2139 /// <returns>The componentwise arctangent of the input, in radians.</returns>
2140 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2141 public static double2 atan(double2 x) { return new double2(atan(x.x), atan(x.y)); }
2142
2143 /// <summary>Returns the componentwise arctangent of a double3 vector.</summary>
2144 /// <param name="x">A tangent value, usually the ratio y/x on the unit circle.</param>
2145 /// <returns>The componentwise arctangent of the input, in radians.</returns>
2146 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2147 public static double3 atan(double3 x) { return new double3(atan(x.x), atan(x.y), atan(x.z)); }
2148
2149 /// <summary>Returns the componentwise arctangent of a double4 vector.</summary>
2150 /// <param name="x">A tangent value, usually the ratio y/x on the unit circle.</param>
2151 /// <returns>The componentwise arctangent of the input, in radians.</returns>
2152 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2153 public static double4 atan(double4 x) { return new double4(atan(x.x), atan(x.y), atan(x.z), atan(x.w)); }
2154
2155
2156 /// <summary>Returns the 2-argument arctangent of a pair of float values.</summary>
2157 /// <param name="y">Numerator of the ratio y/x, usually the y component on the unit circle.</param>
2158 /// <param name="x">Denominator of the ratio y/x, usually the x component on the unit circle.</param>
2159 /// <returns>The arctangent of the ratio y/x, in radians.</returns>
2160 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2161 public static float atan2(float y, float x) { return (float)System.Math.Atan2(y, x); }
2162
2163 /// <summary>Returns the componentwise 2-argument arctangent of a pair of floats2 vectors.</summary>
2164 /// <param name="y">Numerator of the ratio y/x, usually the y component on the unit circle.</param>
2165 /// <param name="x">Denominator of the ratio y/x, usually the x component on the unit circle.</param>
2166 /// <returns>The componentwise arctangent of the ratio y/x, in radians.</returns>
2167 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2168 public static float2 atan2(float2 y, float2 x) { return new float2(atan2(y.x, x.x), atan2(y.y, x.y)); }
2169
2170 /// <summary>Returns the componentwise 2-argument arctangent of a pair of floats3 vectors.</summary>
2171 /// <param name="y">Numerator of the ratio y/x, usually the y component on the unit circle.</param>
2172 /// <param name="x">Denominator of the ratio y/x, usually the x component on the unit circle.</param>
2173 /// <returns>The componentwise arctangent of the ratio y/x, in radians.</returns>
2174 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2175 public static float3 atan2(float3 y, float3 x) { return new float3(atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z)); }
2176
2177 /// <summary>Returns the componentwise 2-argument arctangent of a pair of floats4 vectors.</summary>
2178 /// <param name="y">Numerator of the ratio y/x, usually the y component on the unit circle.</param>
2179 /// <param name="x">Denominator of the ratio y/x, usually the x component on the unit circle.</param>
2180 /// <returns>The componentwise arctangent of the ratio y/x, in radians.</returns>
2181 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2182 public static float4 atan2(float4 y, float4 x) { return new float4(atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)); }
2183
2184
2185 /// <summary>Returns the 2-argument arctangent of a pair of double values.</summary>
2186 /// <param name="y">Numerator of the ratio y/x, usually the y component on the unit circle.</param>
2187 /// <param name="x">Denominator of the ratio y/x, usually the x component on the unit circle.</param>
2188 /// <returns>The arctangent of the ratio y/x, in radians.</returns>
2189 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2190 public static double atan2(double y, double x) { return System.Math.Atan2(y, x); }
2191
2192 /// <summary>Returns the 2-argument arctangent of a pair of double2 vectors.</summary>
2193 /// <param name="y">Numerator of the ratio y/x, usually the y component on the unit circle.</param>
2194 /// <param name="x">Denominator of the ratio y/x, usually the x component on the unit circle.</param>
2195 /// <returns>The componentwise arctangent of the ratio y/x, in radians.</returns>
2196 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2197 public static double2 atan2(double2 y, double2 x) { return new double2(atan2(y.x, x.x), atan2(y.y, x.y)); }
2198
2199 /// <summary>Returns the 2-argument arctangent of a pair of double3 vectors.</summary>
2200 /// <param name="y">Numerator of the ratio y/x, usually the y component on the unit circle.</param>
2201 /// <param name="x">Denominator of the ratio y/x, usually the x component on the unit circle.</param>
2202 /// <returns>The componentwise arctangent of the ratio y/x, in radians.</returns>
2203 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2204 public static double3 atan2(double3 y, double3 x) { return new double3(atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z)); }
2205
2206 /// <summary>Returns the 2-argument arctangent of a pair of double4 vectors.</summary>
2207 /// <param name="y">Numerator of the ratio y/x, usually the y component on the unit circle.</param>
2208 /// <param name="x">Denominator of the ratio y/x, usually the x component on the unit circle.</param>
2209 /// <returns>The componentwise arctangent of the ratio y/x, in radians.</returns>
2210 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2211 public static double4 atan2(double4 y, double4 x) { return new double4(atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)); }
2212
2213
2214 /// <summary>Returns the cosine of a float value.</summary>
2215 /// <param name="x">Input value.</param>
2216 /// <returns>The cosine cosine of the input.</returns>
2217 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2218 public static float cos(float x) { return (float)System.Math.Cos(x); }
2219
2220 /// <summary>Returns the componentwise cosine of a float2 vector.</summary>
2221 /// <param name="x">Input value.</param>
2222 /// <returns>The componentwise cosine cosine of the input.</returns>
2223 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2224 public static float2 cos(float2 x) { return new float2(cos(x.x), cos(x.y)); }
2225
2226 /// <summary>Returns the componentwise cosine of a float3 vector.</summary>
2227 /// <param name="x">Input value.</param>
2228 /// <returns>The componentwise cosine cosine of the input.</returns>
2229 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2230 public static float3 cos(float3 x) { return new float3(cos(x.x), cos(x.y), cos(x.z)); }
2231
2232 /// <summary>Returns the componentwise cosine of a float4 vector.</summary>
2233 /// <param name="x">Input value.</param>
2234 /// <returns>The componentwise cosine cosine of the input.</returns>
2235 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2236 public static float4 cos(float4 x) { return new float4(cos(x.x), cos(x.y), cos(x.z), cos(x.w)); }
2237
2238
2239 /// <summary>Returns the cosine of a double value.</summary>
2240 /// <param name="x">Input value.</param>
2241 /// <returns>The cosine cosine of the input.</returns>
2242 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2243 public static double cos(double x) { return System.Math.Cos(x); }
2244
2245 /// <summary>Returns the componentwise cosine of a double2 vector.</summary>
2246 /// <param name="x">Input value.</param>
2247 /// <returns>The componentwise cosine cosine of the input.</returns>
2248 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2249 public static double2 cos(double2 x) { return new double2(cos(x.x), cos(x.y)); }
2250
2251 /// <summary>Returns the componentwise cosine of a double3 vector.</summary>
2252 /// <param name="x">Input value.</param>
2253 /// <returns>The componentwise cosine cosine of the input.</returns>
2254 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2255 public static double3 cos(double3 x) { return new double3(cos(x.x), cos(x.y), cos(x.z)); }
2256
2257 /// <summary>Returns the componentwise cosine of a double4 vector.</summary>
2258 /// <param name="x">Input value.</param>
2259 /// <returns>The componentwise cosine cosine of the input.</returns>
2260 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2261 public static double4 cos(double4 x) { return new double4(cos(x.x), cos(x.y), cos(x.z), cos(x.w)); }
2262
2263
2264 /// <summary>Returns the hyperbolic cosine of a float value.</summary>
2265 /// <param name="x">Input value.</param>
2266 /// <returns>The hyperbolic cosine of the input.</returns>
2267 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2268 public static float cosh(float x) { return (float)System.Math.Cosh(x); }
2269
2270 /// <summary>Returns the componentwise hyperbolic cosine of a float2 vector.</summary>
2271 /// <param name="x">Input value.</param>
2272 /// <returns>The componentwise hyperbolic cosine of the input.</returns>
2273 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2274 public static float2 cosh(float2 x) { return new float2(cosh(x.x), cosh(x.y)); }
2275
2276 /// <summary>Returns the componentwise hyperbolic cosine of a float3 vector.</summary>
2277 /// <param name="x">Input value.</param>
2278 /// <returns>The componentwise hyperbolic cosine of the input.</returns>
2279 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2280 public static float3 cosh(float3 x) { return new float3(cosh(x.x), cosh(x.y), cosh(x.z)); }
2281
2282 /// <summary>Returns the componentwise hyperbolic cosine of a float4 vector.</summary>
2283 /// <param name="x">Input value.</param>
2284 /// <returns>The componentwise hyperbolic cosine of the input.</returns>
2285 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2286 public static float4 cosh(float4 x) { return new float4(cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)); }
2287
2288
2289 /// <summary>Returns the hyperbolic cosine of a double value.</summary>
2290 /// <param name="x">Input value.</param>
2291 /// <returns>The hyperbolic cosine of the input.</returns>
2292 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2293 public static double cosh(double x) { return System.Math.Cosh(x); }
2294
2295 /// <summary>Returns the componentwise hyperbolic cosine of a double2 vector.</summary>
2296 /// <param name="x">Input value.</param>
2297 /// <returns>The componentwise hyperbolic cosine of the input.</returns>
2298 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2299 public static double2 cosh(double2 x) { return new double2(cosh(x.x), cosh(x.y)); }
2300
2301 /// <summary>Returns the componentwise hyperbolic cosine of a double3 vector.</summary>
2302 /// <param name="x">Input value.</param>
2303 /// <returns>The componentwise hyperbolic cosine of the input.</returns>
2304 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2305 public static double3 cosh(double3 x) { return new double3(cosh(x.x), cosh(x.y), cosh(x.z)); }
2306
2307 /// <summary>Returns the componentwise hyperbolic cosine of a double4 vector.</summary>
2308 /// <param name="x">Input value.</param>
2309 /// <returns>The componentwise hyperbolic cosine of the input.</returns>
2310 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2311 public static double4 cosh(double4 x) { return new double4(cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)); }
2312
2313
2314 /// <summary>Returns the arccosine of a float value.</summary>
2315 /// <param name="x">Input value.</param>
2316 /// <returns>The arccosine of the input.</returns>
2317 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2318 public static float acos(float x) { return (float)System.Math.Acos((float)x); }
2319
2320 /// <summary>Returns the componentwise arccosine of a float2 vector.</summary>
2321 /// <param name="x">Input value.</param>
2322 /// <returns>The componentwise arccosine of the input.</returns>
2323 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2324 public static float2 acos(float2 x) { return new float2(acos(x.x), acos(x.y)); }
2325
2326 /// <summary>Returns the componentwise arccosine of a float3 vector.</summary>
2327 /// <param name="x">Input value.</param>
2328 /// <returns>The componentwise arccosine of the input.</returns>
2329 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2330 public static float3 acos(float3 x) { return new float3(acos(x.x), acos(x.y), acos(x.z)); }
2331
2332 /// <summary>Returns the componentwise arccosine of a float4 vector.</summary>
2333 /// <param name="x">Input value.</param>
2334 /// <returns>The componentwise arccosine of the input.</returns>
2335 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2336 public static float4 acos(float4 x) { return new float4(acos(x.x), acos(x.y), acos(x.z), acos(x.w)); }
2337
2338
2339 /// <summary>Returns the arccosine of a double value.</summary>
2340 /// <param name="x">Input value.</param>
2341 /// <returns>The arccosine of the input.</returns>
2342 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2343 public static double acos(double x) { return System.Math.Acos(x); }
2344
2345 /// <summary>Returns the componentwise arccosine of a double2 vector.</summary>
2346 /// <param name="x">Input value.</param>
2347 /// <returns>The componentwise arccosine of the input.</returns>
2348 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2349 public static double2 acos(double2 x) { return new double2(acos(x.x), acos(x.y)); }
2350
2351 /// <summary>Returns the componentwise arccosine of a double3 vector.</summary>
2352 /// <param name="x">Input value.</param>
2353 /// <returns>The componentwise arccosine of the input.</returns>
2354 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2355 public static double3 acos(double3 x) { return new double3(acos(x.x), acos(x.y), acos(x.z)); }
2356
2357 /// <summary>Returns the componentwise arccosine of a double4 vector.</summary>
2358 /// <param name="x">Input value.</param>
2359 /// <returns>The componentwise arccosine of the input.</returns>
2360 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2361 public static double4 acos(double4 x) { return new double4(acos(x.x), acos(x.y), acos(x.z), acos(x.w)); }
2362
2363
2364 /// <summary>Returns the sine of a float value.</summary>
2365 /// <param name="x">Input value.</param>
2366 /// <returns>The sine of the input.</returns>
2367 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2368 public static float sin(float x) { return (float)System.Math.Sin((float)x); }
2369
2370 /// <summary>Returns the componentwise sine of a float2 vector.</summary>
2371 /// <param name="x">Input value.</param>
2372 /// <returns>The componentwise sine of the input.</returns>
2373 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2374 public static float2 sin(float2 x) { return new float2(sin(x.x), sin(x.y)); }
2375
2376 /// <summary>Returns the componentwise sine of a float3 vector.</summary>
2377 /// <param name="x">Input value.</param>
2378 /// <returns>The componentwise sine of the input.</returns>
2379 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2380 public static float3 sin(float3 x) { return new float3(sin(x.x), sin(x.y), sin(x.z)); }
2381
2382 /// <summary>Returns the componentwise sine of a float4 vector.</summary>
2383 /// <param name="x">Input value.</param>
2384 /// <returns>The componentwise sine of the input.</returns>
2385 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2386 public static float4 sin(float4 x) { return new float4(sin(x.x), sin(x.y), sin(x.z), sin(x.w)); }
2387
2388
2389 /// <summary>Returns the sine of a double value.</summary>
2390 /// <param name="x">Input value.</param>
2391 /// <returns>The sine of the input.</returns>
2392 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2393 public static double sin(double x) { return System.Math.Sin(x); }
2394
2395 /// <summary>Returns the componentwise sine of a double2 vector.</summary>
2396 /// <param name="x">Input value.</param>
2397 /// <returns>The componentwise sine of the input.</returns>
2398 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2399 public static double2 sin(double2 x) { return new double2(sin(x.x), sin(x.y)); }
2400
2401 /// <summary>Returns the componentwise sine of a double3 vector.</summary>
2402 /// <param name="x">Input value.</param>
2403 /// <returns>The componentwise sine of the input.</returns>
2404 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2405 public static double3 sin(double3 x) { return new double3(sin(x.x), sin(x.y), sin(x.z)); }
2406
2407 /// <summary>Returns the componentwise sine of a double4 vector.</summary>
2408 /// <param name="x">Input value.</param>
2409 /// <returns>The componentwise sine of the input.</returns>
2410 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2411 public static double4 sin(double4 x) { return new double4(sin(x.x), sin(x.y), sin(x.z), sin(x.w)); }
2412
2413
2414 /// <summary>Returns the hyperbolic sine of a float value.</summary>
2415 /// <param name="x">Input value.</param>
2416 /// <returns>The hyperbolic sine of the input.</returns>
2417 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2418 public static float sinh(float x) { return (float)System.Math.Sinh((float)x); }
2419
2420 /// <summary>Returns the componentwise hyperbolic sine of a float2 vector.</summary>
2421 /// <param name="x">Input value.</param>
2422 /// <returns>The componentwise hyperbolic sine of the input.</returns>
2423 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2424 public static float2 sinh(float2 x) { return new float2(sinh(x.x), sinh(x.y)); }
2425
2426 /// <summary>Returns the componentwise hyperbolic sine of a float3 vector.</summary>
2427 /// <param name="x">Input value.</param>
2428 /// <returns>The componentwise hyperbolic sine of the input.</returns>
2429 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2430 public static float3 sinh(float3 x) { return new float3(sinh(x.x), sinh(x.y), sinh(x.z)); }
2431
2432 /// <summary>Returns the componentwise hyperbolic sine of a float4 vector.</summary>
2433 /// <param name="x">Input value.</param>
2434 /// <returns>The componentwise hyperbolic sine of the input.</returns>
2435 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2436 public static float4 sinh(float4 x) { return new float4(sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)); }
2437
2438
2439 /// <summary>Returns the hyperbolic sine of a double value.</summary>
2440 /// <param name="x">Input value.</param>
2441 /// <returns>The hyperbolic sine of the input.</returns>
2442 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2443 public static double sinh(double x) { return System.Math.Sinh(x); }
2444
2445 /// <summary>Returns the componentwise hyperbolic sine of a double2 vector.</summary>
2446 /// <param name="x">Input value.</param>
2447 /// <returns>The componentwise hyperbolic sine of the input.</returns>
2448 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2449 public static double2 sinh(double2 x) { return new double2(sinh(x.x), sinh(x.y)); }
2450
2451 /// <summary>Returns the componentwise hyperbolic sine of a double3 vector.</summary>
2452 /// <param name="x">Input value.</param>
2453 /// <returns>The componentwise hyperbolic sine of the input.</returns>
2454 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2455 public static double3 sinh(double3 x) { return new double3(sinh(x.x), sinh(x.y), sinh(x.z)); }
2456
2457 /// <summary>Returns the componentwise hyperbolic sine of a double4 vector.</summary>
2458 /// <param name="x">Input value.</param>
2459 /// <returns>The componentwise hyperbolic sine of the input.</returns>
2460 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2461 public static double4 sinh(double4 x) { return new double4(sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)); }
2462
2463
2464 /// <summary>Returns the arcsine of a float value.</summary>
2465 /// <param name="x">Input value.</param>
2466 /// <returns>The arcsine of the input.</returns>
2467 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2468 public static float asin(float x) { return (float)System.Math.Asin((float)x); }
2469
2470 /// <summary>Returns the componentwise arcsine of a float2 vector.</summary>
2471 /// <param name="x">Input value.</param>
2472 /// <returns>The componentwise arcsine of the input.</returns>
2473 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2474 public static float2 asin(float2 x) { return new float2(asin(x.x), asin(x.y)); }
2475
2476 /// <summary>Returns the componentwise arcsine of a float3 vector.</summary>
2477 /// <param name="x">Input value.</param>
2478 /// <returns>The componentwise arcsine of the input.</returns>
2479 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2480 public static float3 asin(float3 x) { return new float3(asin(x.x), asin(x.y), asin(x.z)); }
2481
2482 /// <summary>Returns the componentwise arcsine of a float4 vector.</summary>
2483 /// <param name="x">Input value.</param>
2484 /// <returns>The componentwise arcsine of the input.</returns>
2485 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2486 public static float4 asin(float4 x) { return new float4(asin(x.x), asin(x.y), asin(x.z), asin(x.w)); }
2487
2488
2489 /// <summary>Returns the arcsine of a double value.</summary>
2490 /// <param name="x">Input value.</param>
2491 /// <returns>The arcsine of the input.</returns>
2492 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2493 public static double asin(double x) { return System.Math.Asin(x); }
2494
2495 /// <summary>Returns the componentwise arcsine of a double2 vector.</summary>
2496 /// <param name="x">Input value.</param>
2497 /// <returns>The componentwise arcsine of the input.</returns>
2498 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2499 public static double2 asin(double2 x) { return new double2(asin(x.x), asin(x.y)); }
2500
2501 /// <summary>Returns the componentwise arcsine of a double3 vector.</summary>
2502 /// <param name="x">Input value.</param>
2503 /// <returns>The componentwise arcsine of the input.</returns>
2504 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2505 public static double3 asin(double3 x) { return new double3(asin(x.x), asin(x.y), asin(x.z)); }
2506
2507 /// <summary>Returns the componentwise arcsine of a double4 vector.</summary>
2508 /// <param name="x">Input value.</param>
2509 /// <returns>The componentwise arcsine of the input.</returns>
2510 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2511 public static double4 asin(double4 x) { return new double4(asin(x.x), asin(x.y), asin(x.z), asin(x.w)); }
2512
2513
2514 /// <summary>Returns the result of rounding a float value up to the nearest integral value less or equal to the original value.</summary>
2515 /// <param name="x">Input value.</param>
2516 /// <returns>The round down to nearest integral value of the input.</returns>
2517 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2518 public static float floor(float x) { return (float)System.Math.Floor((float)x); }
2519
2520 /// <summary>Returns the result of rounding each component of a float2 vector value down to the nearest value less or equal to the original value.</summary>
2521 /// <param name="x">Input value.</param>
2522 /// <returns>The componentwise round down to nearest integral value of the input.</returns>
2523 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2524 public static float2 floor(float2 x) { return new float2(floor(x.x), floor(x.y)); }
2525
2526 /// <summary>Returns the result of rounding each component of a float3 vector value down to the nearest value less or equal to the original value.</summary>
2527 /// <param name="x">Input value.</param>
2528 /// <returns>The componentwise round down to nearest integral value of the input.</returns>
2529 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2530 public static float3 floor(float3 x) { return new float3(floor(x.x), floor(x.y), floor(x.z)); }
2531
2532 /// <summary>Returns the result of rounding each component of a float4 vector value down to the nearest value less or equal to the original value.</summary>
2533 /// <param name="x">Input value.</param>
2534 /// <returns>The componentwise round down to nearest integral value of the input.</returns>
2535 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2536 public static float4 floor(float4 x) { return new float4(floor(x.x), floor(x.y), floor(x.z), floor(x.w)); }
2537
2538
2539 /// <summary>Returns the result of rounding a double value up to the nearest integral value less or equal to the original value.</summary>
2540 /// <param name="x">Input value.</param>
2541 /// <returns>The round down to nearest integral value of the input.</returns>
2542 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2543 public static double floor(double x) { return System.Math.Floor(x); }
2544
2545 /// <summary>Returns the result of rounding each component of a double2 vector value down to the nearest value less or equal to the original value.</summary>
2546 /// <param name="x">Input value.</param>
2547 /// <returns>The componentwise round down to nearest integral value of the input.</returns>
2548 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2549 public static double2 floor(double2 x) { return new double2(floor(x.x), floor(x.y)); }
2550
2551 /// <summary>Returns the result of rounding each component of a double3 vector value down to the nearest value less or equal to the original value.</summary>
2552 /// <param name="x">Input value.</param>
2553 /// <returns>The componentwise round down to nearest integral value of the input.</returns>
2554 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2555 public static double3 floor(double3 x) { return new double3(floor(x.x), floor(x.y), floor(x.z)); }
2556
2557 /// <summary>Returns the result of rounding each component of a double4 vector value down to the nearest value less or equal to the original value.</summary>
2558 /// <param name="x">Input value.</param>
2559 /// <returns>The componentwise round down to nearest integral value of the input.</returns>
2560 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2561 public static double4 floor(double4 x) { return new double4(floor(x.x), floor(x.y), floor(x.z), floor(x.w)); }
2562
2563
2564 /// <summary>Returns the result of rounding a float value up to the nearest integral value greater or equal to the original value.</summary>
2565 /// <param name="x">Input value.</param>
2566 /// <returns>The round up to nearest integral value of the input.</returns>
2567 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2568 public static float ceil(float x) { return (float)System.Math.Ceiling((float)x); }
2569
2570 /// <summary>Returns the result of rounding each component of a float2 vector value up to the nearest value greater or equal to the original value.</summary>
2571 /// <param name="x">Input value.</param>
2572 /// <returns>The componentwise round up to nearest integral value of the input.</returns>
2573 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2574 public static float2 ceil(float2 x) { return new float2(ceil(x.x), ceil(x.y)); }
2575
2576 /// <summary>Returns the result of rounding each component of a float3 vector value up to the nearest value greater or equal to the original value.</summary>
2577 /// <param name="x">Input value.</param>
2578 /// <returns>The componentwise round up to nearest integral value of the input.</returns>
2579 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2580 public static float3 ceil(float3 x) { return new float3(ceil(x.x), ceil(x.y), ceil(x.z)); }
2581
2582 /// <summary>Returns the result of rounding each component of a float4 vector value up to the nearest value greater or equal to the original value.</summary>
2583 /// <param name="x">Input value.</param>
2584 /// <returns>The componentwise round up to nearest integral value of the input.</returns>
2585 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2586 public static float4 ceil(float4 x) { return new float4(ceil(x.x), ceil(x.y), ceil(x.z), ceil(x.w)); }
2587
2588
2589 /// <summary>Returns the result of rounding a double value up to the nearest greater integral value greater or equal to the original value.</summary>
2590 /// <param name="x">Input value.</param>
2591 /// <returns>The round up to nearest integral value of the input.</returns>
2592 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2593 public static double ceil(double x) { return System.Math.Ceiling(x); }
2594
2595 /// <summary>Returns the result of rounding each component of a double2 vector value up to the nearest integral value greater or equal to the original value.</summary>
2596 /// <param name="x">Input value.</param>
2597 /// <returns>The componentwise round up to nearest integral value of the input.</returns>
2598 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2599 public static double2 ceil(double2 x) { return new double2(ceil(x.x), ceil(x.y)); }
2600
2601 /// <summary>Returns the result of rounding each component of a double3 vector value up to the nearest integral value greater or equal to the original value..</summary>
2602 /// <param name="x">Input value.</param>
2603 /// <returns>The componentwise round up to nearest integral value of the input.</returns>
2604 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2605 public static double3 ceil(double3 x) { return new double3(ceil(x.x), ceil(x.y), ceil(x.z)); }
2606
2607 /// <summary>Returns the result of rounding each component of a double4 vector value up to the nearest integral value greater or equal to the original value.</summary>
2608 /// <param name="x">Input value.</param>
2609 /// <returns>The componentwise round up to nearest integral value of the input.</returns>
2610 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2611 public static double4 ceil(double4 x) { return new double4(ceil(x.x), ceil(x.y), ceil(x.z), ceil(x.w)); }
2612
2613
2614 /// <summary>Returns the result of rounding a float value to the nearest integral value.</summary>
2615 /// <param name="x">Input value.</param>
2616 /// <returns>The round to nearest integral value of the input.</returns>
2617 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2618 public static float round(float x) { return (float)System.Math.Round((float)x); }
2619
2620 /// <summary>Returns the result of rounding each component of a float2 vector value to the nearest integral value.</summary>
2621 /// <param name="x">Input value.</param>
2622 /// <returns>The componentwise round to nearest integral value of the input.</returns>
2623 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2624 public static float2 round(float2 x) { return new float2(round(x.x), round(x.y)); }
2625
2626 /// <summary>Returns the result of rounding each component of a float3 vector value to the nearest integral value.</summary>
2627 /// <param name="x">Input value.</param>
2628 /// <returns>The componentwise round to nearest integral value of the input.</returns>
2629 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2630 public static float3 round(float3 x) { return new float3(round(x.x), round(x.y), round(x.z)); }
2631
2632 /// <summary>Returns the result of rounding each component of a float4 vector value to the nearest integral value.</summary>
2633 /// <param name="x">Input value.</param>
2634 /// <returns>The componentwise round to nearest integral value of the input.</returns>
2635 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2636 public static float4 round(float4 x) { return new float4(round(x.x), round(x.y), round(x.z), round(x.w)); }
2637
2638
2639 /// <summary>Returns the result of rounding a double value to the nearest integral value.</summary>
2640 /// <param name="x">Input value.</param>
2641 /// <returns>The round to nearest integral value of the input.</returns>
2642 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2643 public static double round(double x) { return System.Math.Round(x); }
2644
2645 /// <summary>Returns the result of rounding each component of a double2 vector value to the nearest integral value.</summary>
2646 /// <param name="x">Input value.</param>
2647 /// <returns>The componentwise round to nearest integral value of the input.</returns>
2648 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2649 public static double2 round(double2 x) { return new double2(round(x.x), round(x.y)); }
2650
2651 /// <summary>Returns the result of rounding each component of a double3 vector value to the nearest integral value.</summary>
2652 /// <param name="x">Input value.</param>
2653 /// <returns>The componentwise round to nearest integral value of the input.</returns>
2654 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2655 public static double3 round(double3 x) { return new double3(round(x.x), round(x.y), round(x.z)); }
2656
2657 /// <summary>Returns the result of rounding each component of a double4 vector value to the nearest integral value.</summary>
2658 /// <param name="x">Input value.</param>
2659 /// <returns>The componentwise round to nearest integral value of the input.</returns>
2660 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2661 public static double4 round(double4 x) { return new double4(round(x.x), round(x.y), round(x.z), round(x.w)); }
2662
2663
2664 /// <summary>Returns the result of truncating a float value to an integral float value.</summary>
2665 /// <param name="x">Input value.</param>
2666 /// <returns>The truncation of the input.</returns>
2667 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2668 public static float trunc(float x) { return (float)System.Math.Truncate((float)x); }
2669
2670 /// <summary>Returns the result of a componentwise truncation of a float2 value to an integral float2 value.</summary>
2671 /// <param name="x">Input value.</param>
2672 /// <returns>The componentwise truncation of the input.</returns>
2673 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2674 public static float2 trunc(float2 x) { return new float2(trunc(x.x), trunc(x.y)); }
2675
2676 /// <summary>Returns the result of a componentwise truncation of a float3 value to an integral float3 value.</summary>
2677 /// <param name="x">Input value.</param>
2678 /// <returns>The componentwise truncation of the input.</returns>
2679 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2680 public static float3 trunc(float3 x) { return new float3(trunc(x.x), trunc(x.y), trunc(x.z)); }
2681
2682 /// <summary>Returns the result of a componentwise truncation of a float4 value to an integral float4 value.</summary>
2683 /// <param name="x">Input value.</param>
2684 /// <returns>The componentwise truncation of the input.</returns>
2685 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2686 public static float4 trunc(float4 x) { return new float4(trunc(x.x), trunc(x.y), trunc(x.z), trunc(x.w)); }
2687
2688
2689 /// <summary>Returns the result of truncating a double value to an integral double value.</summary>
2690 /// <param name="x">Input value.</param>
2691 /// <returns>The truncation of the input.</returns>
2692 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2693 public static double trunc(double x) { return System.Math.Truncate(x); }
2694
2695 /// <summary>Returns the result of a componentwise truncation of a double2 value to an integral double2 value.</summary>
2696 /// <param name="x">Input value.</param>
2697 /// <returns>The componentwise truncation of the input.</returns>
2698 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2699 public static double2 trunc(double2 x) { return new double2(trunc(x.x), trunc(x.y)); }
2700
2701 /// <summary>Returns the result of a componentwise truncation of a double3 value to an integral double3 value.</summary>
2702 /// <param name="x">Input value.</param>
2703 /// <returns>The componentwise truncation of the input.</returns>
2704 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2705 public static double3 trunc(double3 x) { return new double3(trunc(x.x), trunc(x.y), trunc(x.z)); }
2706
2707 /// <summary>Returns the result of a componentwise truncation of a double4 value to an integral double4 value.</summary>
2708 /// <param name="x">Input value.</param>
2709 /// <returns>The componentwise truncation of the input.</returns>
2710 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2711 public static double4 trunc(double4 x) { return new double4(trunc(x.x), trunc(x.y), trunc(x.z), trunc(x.w)); }
2712
2713
2714 /// <summary>Returns the fractional part of a float value.</summary>
2715 /// <param name="x">Input value.</param>
2716 /// <returns>The fractional part of the input.</returns>
2717 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2718 public static float frac(float x) { return x - floor(x); }
2719
2720 /// <summary>Returns the componentwise fractional parts of a float2 vector.</summary>
2721 /// <param name="x">Input value.</param>
2722 /// <returns>The componentwise fractional part of the input.</returns>
2723 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2724 public static float2 frac(float2 x) { return x - floor(x); }
2725
2726 /// <summary>Returns the componentwise fractional parts of a float3 vector.</summary>
2727 /// <param name="x">Input value.</param>
2728 /// <returns>The componentwise fractional part of the input.</returns>
2729 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2730 public static float3 frac(float3 x) { return x - floor(x); }
2731
2732 /// <summary>Returns the componentwise fractional parts of a float4 vector.</summary>
2733 /// <param name="x">Input value.</param>
2734 /// <returns>The componentwise fractional part of the input.</returns>
2735 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2736 public static float4 frac(float4 x) { return x - floor(x); }
2737
2738
2739 /// <summary>Returns the fractional part of a double value.</summary>
2740 /// <param name="x">Input value.</param>
2741 /// <returns>The fractional part of the input.</returns>
2742 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2743 public static double frac(double x) { return x - floor(x); }
2744
2745 /// <summary>Returns the componentwise fractional parts of a double2 vector.</summary>
2746 /// <param name="x">Input value.</param>
2747 /// <returns>The componentwise fractional part of the input.</returns>
2748 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2749 public static double2 frac(double2 x) { return x - floor(x); }
2750
2751 /// <summary>Returns the componentwise fractional parts of a double3 vector.</summary>
2752 /// <param name="x">Input value.</param>
2753 /// <returns>The componentwise fractional part of the input.</returns>
2754 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2755 public static double3 frac(double3 x) { return x - floor(x); }
2756
2757 /// <summary>Returns the componentwise fractional parts of a double4 vector.</summary>
2758 /// <param name="x">Input value.</param>
2759 /// <returns>The componentwise fractional part of the input.</returns>
2760 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2761 public static double4 frac(double4 x) { return x - floor(x); }
2762
2763
2764 /// <summary>Returns the reciprocal a float value.</summary>
2765 /// <param name="x">Input value.</param>
2766 /// <returns>The reciprocal of the input.</returns>
2767 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2768 public static float rcp(float x) { return 1.0f / x; }
2769
2770 /// <summary>Returns the componentwise reciprocal a float2 vector.</summary>
2771 /// <param name="x">Input value.</param>
2772 /// <returns>The componentwise reciprocal of the input.</returns>
2773 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2774 public static float2 rcp(float2 x) { return 1.0f / x; }
2775
2776 /// <summary>Returns the componentwise reciprocal a float3 vector.</summary>
2777 /// <param name="x">Input value.</param>
2778 /// <returns>The componentwise reciprocal of the input.</returns>
2779 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2780 public static float3 rcp(float3 x) { return 1.0f / x; }
2781
2782 /// <summary>Returns the componentwise reciprocal a float4 vector.</summary>
2783 /// <param name="x">Input value.</param>
2784 /// <returns>The componentwise reciprocal of the input.</returns>
2785 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2786 public static float4 rcp(float4 x) { return 1.0f / x; }
2787
2788
2789 /// <summary>Returns the reciprocal a double value.</summary>
2790 /// <param name="x">Input value.</param>
2791 /// <returns>The reciprocal of the input.</returns>
2792 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2793 public static double rcp(double x) { return 1.0 / x; }
2794
2795 /// <summary>Returns the componentwise reciprocal a double2 vector.</summary>
2796 /// <param name="x">Input value.</param>
2797 /// <returns>The componentwise reciprocal of the input.</returns>
2798 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2799 public static double2 rcp(double2 x) { return 1.0 / x; }
2800
2801 /// <summary>Returns the componentwise reciprocal a double3 vector.</summary>
2802 /// <param name="x">Input value.</param>
2803 /// <returns>The componentwise reciprocal of the input.</returns>
2804 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2805 public static double3 rcp(double3 x) { return 1.0 / x; }
2806
2807 /// <summary>Returns the componentwise reciprocal a double4 vector.</summary>
2808 /// <param name="x">Input value.</param>
2809 /// <returns>The componentwise reciprocal of the input.</returns>
2810 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2811 public static double4 rcp(double4 x) { return 1.0 / x; }
2812
2813 /// <summary>Returns the sign of a int value. -1 if it is less than zero, 0 if it is zero and 1 if it greater than zero.</summary>
2814 /// <param name="x">Input value.</param>
2815 /// <returns>The sign of the input.</returns>
2816 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2817 public static int sign(int x) { return (x > 0 ? 1 : 0) - (x < 0 ? 1 : 0); }
2818
2819 /// <summary>Returns the componentwise sign of a int2 value. 1 for positive components, 0 for zero components and -1 for negative components.</summary>
2820 /// <param name="x">Input value.</param>
2821 /// <returns>The componentwise sign of the input.</returns>
2822 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2823 public static int2 sign(int2 x) { return new int2(sign(x.x), sign(x.y)); }
2824
2825 /// <summary>Returns the componentwise sign of a int3 value. 1 for positive components, 0 for zero components and -1 for negative components.</summary>
2826 /// <param name="x">Input value.</param>
2827 /// <returns>The componentwise sign of the input.</returns>
2828 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2829 public static int3 sign(int3 x) { return new int3(sign(x.x), sign(x.y), sign(x.z)); }
2830
2831 /// <summary>Returns the componentwise sign of a int4 value. 1 for positive components, 0 for zero components and -1 for negative components.</summary>
2832 /// <param name="x">Input value.</param>
2833 /// <returns>The componentwise sign of the input.</returns>
2834 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2835 public static int4 sign(int4 x) { return new int4(sign(x.x), sign(x.y), sign(x.z), sign(x.w)); }
2836
2837 /// <summary>Returns the sign of a float value. -1.0f if it is less than zero, 0.0f if it is zero and 1.0f if it greater than zero.</summary>
2838 /// <param name="x">Input value.</param>
2839 /// <returns>The sign of the input.</returns>
2840 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2841 public static float sign(float x) { return (x > 0.0f ? 1.0f : 0.0f) - (x < 0.0f ? 1.0f : 0.0f); }
2842
2843 /// <summary>Returns the componentwise sign of a float2 value. 1.0f for positive components, 0.0f for zero components and -1.0f for negative components.</summary>
2844 /// <param name="x">Input value.</param>
2845 /// <returns>The componentwise sign of the input.</returns>
2846 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2847 public static float2 sign(float2 x) { return new float2(sign(x.x), sign(x.y)); }
2848
2849 /// <summary>Returns the componentwise sign of a float3 value. 1.0f for positive components, 0.0f for zero components and -1.0f for negative components.</summary>
2850 /// <param name="x">Input value.</param>
2851 /// <returns>The componentwise sign of the input.</returns>
2852 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2853 public static float3 sign(float3 x) { return new float3(sign(x.x), sign(x.y), sign(x.z)); }
2854
2855 /// <summary>Returns the componentwise sign of a float4 value. 1.0f for positive components, 0.0f for zero components and -1.0f for negative components.</summary>
2856 /// <param name="x">Input value.</param>
2857 /// <returns>The componentwise sign of the input.</returns>
2858 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2859 public static float4 sign(float4 x) { return new float4(sign(x.x), sign(x.y), sign(x.z), sign(x.w)); }
2860
2861
2862 /// <summary>Returns the sign of a double value. -1.0 if it is less than zero, 0.0 if it is zero and 1.0 if it greater than zero.</summary>
2863 /// <param name="x">Input value.</param>
2864 /// <returns>The sign of the input.</returns>
2865 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2866 public static double sign(double x) { return x == 0 ? 0 : (x > 0.0 ? 1.0 : 0.0) - (x < 0.0 ? 1.0 : 0.0); }
2867
2868 /// <summary>Returns the componentwise sign of a double2 value. 1.0 for positive components, 0.0 for zero components and -1.0 for negative components.</summary>
2869 /// <param name="x">Input value.</param>
2870 /// <returns>The componentwise sign of the input.</returns>
2871 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2872 public static double2 sign(double2 x) { return new double2(sign(x.x), sign(x.y)); }
2873
2874 /// <summary>Returns the componentwise sign of a double3 value. 1.0 for positive components, 0.0 for zero components and -1.0 for negative components.</summary>
2875 /// <param name="x">Input value.</param>
2876 /// <returns>The componentwise sign of the input.</returns>
2877 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2878 public static double3 sign(double3 x) { return new double3(sign(x.x), sign(x.y), sign(x.z)); }
2879
2880 /// <summary>Returns the componentwise sign of a double4 value. 1.0 for positive components, 0.0 for zero components and -1.0 for negative components.</summary>
2881 /// <param name="x">Input value.</param>
2882 /// <returns>The componentwise sign of the input.</returns>
2883 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2884 public static double4 sign(double4 x) { return new double4(sign(x.x), sign(x.y), sign(x.z), sign(x.w)); }
2885
2886
2887 /// <summary>Returns x raised to the power y.</summary>
2888 /// <param name="x">The exponent base.</param>
2889 /// <param name="y">The exponent power.</param>
2890 /// <returns>The result of raising x to the power y.</returns>
2891 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2892 public static float pow(float x, float y) { return (float)System.Math.Pow((float)x, (float)y); }
2893
2894 /// <summary>Returns the componentwise result of raising x to the power y.</summary>
2895 /// <param name="x">The exponent base.</param>
2896 /// <param name="y">The exponent power.</param>
2897 /// <returns>The componentwise result of raising x to the power y.</returns>
2898 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2899 public static float2 pow(float2 x, float2 y) { return new float2(pow(x.x, y.x), pow(x.y, y.y)); }
2900
2901 /// <summary>Returns the componentwise result of raising x to the power y.</summary>
2902 /// <param name="x">The exponent base.</param>
2903 /// <param name="y">The exponent power.</param>
2904 /// <returns>The componentwise result of raising x to the power y.</returns>
2905 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2906 public static float3 pow(float3 x, float3 y) { return new float3(pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z)); }
2907
2908 /// <summary>Returns the componentwise result of raising x to the power y.</summary>
2909 /// <param name="x">The exponent base.</param>
2910 /// <param name="y">The exponent power.</param>
2911 /// <returns>The componentwise result of raising x to the power y.</returns>
2912 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2913 public static float4 pow(float4 x, float4 y) { return new float4(pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)); }
2914
2915
2916 /// <summary>Returns x raised to the power y.</summary>
2917 /// <param name="x">The exponent base.</param>
2918 /// <param name="y">The exponent power.</param>
2919 /// <returns>The result of raising x to the power y.</returns>
2920 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2921 public static double pow(double x, double y) { return System.Math.Pow(x, y); }
2922
2923 /// <summary>Returns the componentwise result of raising x to the power y.</summary>
2924 /// <param name="x">The exponent base.</param>
2925 /// <param name="y">The exponent power.</param>
2926 /// <returns>The componentwise result of raising x to the power y.</returns>
2927 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2928 public static double2 pow(double2 x, double2 y) { return new double2(pow(x.x, y.x), pow(x.y, y.y)); }
2929
2930 /// <summary>Returns the componentwise result of raising x to the power y.</summary>
2931 /// <param name="x">The exponent base.</param>
2932 /// <param name="y">The exponent power.</param>
2933 /// <returns>The componentwise result of raising x to the power y.</returns>
2934 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2935 public static double3 pow(double3 x, double3 y) { return new double3(pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z)); }
2936
2937 /// <summary>Returns the componentwise result of raising x to the power y.</summary>
2938 /// <param name="x">The exponent base.</param>
2939 /// <param name="y">The exponent power.</param>
2940 /// <returns>The componentwise result of raising x to the power y.</returns>
2941 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2942 public static double4 pow(double4 x, double4 y) { return new double4(pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)); }
2943
2944
2945 /// <summary>Returns the base-e exponential of x.</summary>
2946 /// <param name="x">Input value.</param>
2947 /// <returns>The base-e exponential of the input.</returns>
2948 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2949 public static float exp(float x) { return (float)System.Math.Exp((float)x); }
2950
2951 /// <summary>Returns the componentwise base-e exponential of x.</summary>
2952 /// <param name="x">Input value.</param>
2953 /// <returns>The componentwise base-e exponential of the input.</returns>
2954 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2955 public static float2 exp(float2 x) { return new float2(exp(x.x), exp(x.y)); }
2956
2957 /// <summary>Returns the componentwise base-e exponential of x.</summary>
2958 /// <param name="x">Input value.</param>
2959 /// <returns>The componentwise base-e exponential of the input.</returns>
2960 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2961 public static float3 exp(float3 x) { return new float3(exp(x.x), exp(x.y), exp(x.z)); }
2962
2963 /// <summary>Returns the componentwise base-e exponential of x.</summary>
2964 /// <param name="x">Input value.</param>
2965 /// <returns>The componentwise base-e exponential of the input.</returns>
2966 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2967 public static float4 exp(float4 x) { return new float4(exp(x.x), exp(x.y), exp(x.z), exp(x.w)); }
2968
2969
2970 /// <summary>Returns the base-e exponential of x.</summary>
2971 /// <param name="x">Input value.</param>
2972 /// <returns>The base-e exponential of the input.</returns>
2973 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2974 public static double exp(double x) { return System.Math.Exp(x); }
2975
2976 /// <summary>Returns the componentwise base-e exponential of x.</summary>
2977 /// <param name="x">Input value.</param>
2978 /// <returns>The componentwise base-e exponential of the input.</returns>
2979 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2980 public static double2 exp(double2 x) { return new double2(exp(x.x), exp(x.y)); }
2981
2982 /// <summary>Returns the componentwise base-e exponential of x.</summary>
2983 /// <param name="x">Input value.</param>
2984 /// <returns>The componentwise base-e exponential of the input.</returns>
2985 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2986 public static double3 exp(double3 x) { return new double3(exp(x.x), exp(x.y), exp(x.z)); }
2987
2988 /// <summary>Returns the componentwise base-e exponential of x.</summary>
2989 /// <param name="x">Input value.</param>
2990 /// <returns>The componentwise base-e exponential of the input.</returns>
2991 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2992 public static double4 exp(double4 x) { return new double4(exp(x.x), exp(x.y), exp(x.z), exp(x.w)); }
2993
2994
2995 /// <summary>Returns the base-2 exponential of x.</summary>
2996 /// <param name="x">Input value.</param>
2997 /// <returns>The base-2 exponential of the input.</returns>
2998 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2999 public static float exp2(float x) { return (float)System.Math.Exp((float)x * 0.69314718f); }
3000
3001 /// <summary>Returns the componentwise base-2 exponential of x.</summary>
3002 /// <param name="x">Input value.</param>
3003 /// <returns>The componentwise base-2 exponential of the input.</returns>
3004 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3005 public static float2 exp2(float2 x) { return new float2(exp2(x.x), exp2(x.y)); }
3006
3007 /// <summary>Returns the componentwise base-2 exponential of x.</summary>
3008 /// <param name="x">Input value.</param>
3009 /// <returns>The componentwise base-2 exponential of the input.</returns>
3010 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3011 public static float3 exp2(float3 x) { return new float3(exp2(x.x), exp2(x.y), exp2(x.z)); }
3012
3013 /// <summary>Returns the componentwise base-2 exponential of x.</summary>
3014 /// <param name="x">Input value.</param>
3015 /// <returns>The componentwise base-2 exponential of the input.</returns>
3016 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3017 public static float4 exp2(float4 x) { return new float4(exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)); }
3018
3019
3020 /// <summary>Returns the base-2 exponential of x.</summary>
3021 /// <param name="x">Input value.</param>
3022 /// <returns>The base-2 exponential of the input.</returns>
3023 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3024 public static double exp2(double x) { return System.Math.Exp(x * 0.693147180559945309); }
3025
3026 /// <summary>Returns the componentwise base-2 exponential of x.</summary>
3027 /// <param name="x">Input value.</param>
3028 /// <returns>The componentwise base-2 exponential of the input.</returns>
3029 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3030 public static double2 exp2(double2 x) { return new double2(exp2(x.x), exp2(x.y)); }
3031
3032 /// <summary>Returns the componentwise base-2 exponential of x.</summary>
3033 /// <param name="x">Input value.</param>
3034 /// <returns>The componentwise base-2 exponential of the input.</returns>
3035 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3036 public static double3 exp2(double3 x) { return new double3(exp2(x.x), exp2(x.y), exp2(x.z)); }
3037
3038 /// <summary>Returns the componentwise base-2 exponential of x.</summary>
3039 /// <param name="x">Input value.</param>
3040 /// <returns>The componentwise base-2 exponential of the input.</returns>
3041 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3042 public static double4 exp2(double4 x) { return new double4(exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)); }
3043
3044
3045 /// <summary>Returns the base-10 exponential of x.</summary>
3046 /// <param name="x">Input value.</param>
3047 /// <returns>The base-10 exponential of the input.</returns>
3048 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3049 public static float exp10(float x) { return (float)System.Math.Exp((float)x * 2.30258509f); }
3050
3051 /// <summary>Returns the componentwise base-10 exponential of x.</summary>
3052 /// <param name="x">Input value.</param>
3053 /// <returns>The componentwise base-10 exponential of the input.</returns>
3054 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3055 public static float2 exp10(float2 x) { return new float2(exp10(x.x), exp10(x.y)); }
3056
3057 /// <summary>Returns the componentwise base-10 exponential of x.</summary>
3058 /// <param name="x">Input value.</param>
3059 /// <returns>The componentwise base-10 exponential of the input.</returns>
3060 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3061 public static float3 exp10(float3 x) { return new float3(exp10(x.x), exp10(x.y), exp10(x.z)); }
3062
3063 /// <summary>Returns the componentwise base-10 exponential of x.</summary>
3064 /// <param name="x">Input value.</param>
3065 /// <returns>The componentwise base-10 exponential of the input.</returns>
3066 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3067 public static float4 exp10(float4 x) { return new float4(exp10(x.x), exp10(x.y), exp10(x.z), exp10(x.w)); }
3068
3069
3070 /// <summary>Returns the base-10 exponential of x.</summary>
3071 /// <param name="x">Input value.</param>
3072 /// <returns>The base-10 exponential of the input.</returns>
3073 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3074 public static double exp10(double x) { return System.Math.Exp(x * 2.302585092994045684); }
3075
3076 /// <summary>Returns the componentwise base-10 exponential of x.</summary>
3077 /// <param name="x">Input value.</param>
3078 /// <returns>The componentwise base-10 exponential of the input.</returns>
3079 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3080 public static double2 exp10(double2 x) { return new double2(exp10(x.x), exp10(x.y)); }
3081
3082 /// <summary>Returns the componentwise base-10 exponential of x.</summary>
3083 /// <param name="x">Input value.</param>
3084 /// <returns>The componentwise base-10 exponential of the input.</returns>
3085 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3086 public static double3 exp10(double3 x) { return new double3(exp10(x.x), exp10(x.y), exp10(x.z)); }
3087
3088 /// <summary>Returns the componentwise base-10 exponential of x.</summary>
3089 /// <param name="x">Input value.</param>
3090 /// <returns>The componentwise base-10 exponential of the input.</returns>
3091 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3092 public static double4 exp10(double4 x) { return new double4(exp10(x.x), exp10(x.y), exp10(x.z), exp10(x.w)); }
3093
3094
3095 /// <summary>Returns the natural logarithm of a float value.</summary>
3096 /// <param name="x">Input value.</param>
3097 /// <returns>The natural logarithm of the input.</returns>
3098 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3099 public static float log(float x) { return (float)System.Math.Log((float)x); }
3100
3101 /// <summary>Returns the componentwise natural logarithm of a float2 vector.</summary>
3102 /// <param name="x">Input value.</param>
3103 /// <returns>The componentwise natural logarithm of the input.</returns>
3104 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3105 public static float2 log(float2 x) { return new float2(log(x.x), log(x.y)); }
3106
3107 /// <summary>Returns the componentwise natural logarithm of a float3 vector.</summary>
3108 /// <param name="x">Input value.</param>
3109 /// <returns>The componentwise natural logarithm of the input.</returns>
3110 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3111 public static float3 log(float3 x) { return new float3(log(x.x), log(x.y), log(x.z)); }
3112
3113 /// <summary>Returns the componentwise natural logarithm of a float4 vector.</summary>
3114 /// <param name="x">Input value.</param>
3115 /// <returns>The componentwise natural logarithm of the input.</returns>
3116 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3117 public static float4 log(float4 x) { return new float4(log(x.x), log(x.y), log(x.z), log(x.w)); }
3118
3119
3120 /// <summary>Returns the natural logarithm of a double value.</summary>
3121 /// <param name="x">Input value.</param>
3122 /// <returns>The natural logarithm of the input.</returns>
3123 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3124 public static double log(double x) { return System.Math.Log(x); }
3125
3126 /// <summary>Returns the componentwise natural logarithm of a double2 vector.</summary>
3127 /// <param name="x">Input value.</param>
3128 /// <returns>The componentwise natural logarithm of the input.</returns>
3129 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3130 public static double2 log(double2 x) { return new double2(log(x.x), log(x.y)); }
3131
3132 /// <summary>Returns the componentwise natural logarithm of a double3 vector.</summary>
3133 /// <param name="x">Input value.</param>
3134 /// <returns>The componentwise natural logarithm of the input.</returns>
3135 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3136 public static double3 log(double3 x) { return new double3(log(x.x), log(x.y), log(x.z)); }
3137
3138 /// <summary>Returns the componentwise natural logarithm of a double4 vector.</summary>
3139 /// <param name="x">Input value.</param>
3140 /// <returns>The componentwise natural logarithm of the input.</returns>
3141 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3142 public static double4 log(double4 x) { return new double4(log(x.x), log(x.y), log(x.z), log(x.w)); }
3143
3144
3145 /// <summary>Returns the base-2 logarithm of a float value.</summary>
3146 /// <param name="x">Input value.</param>
3147 /// <returns>The base-2 logarithm of the input.</returns>
3148 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3149 public static float log2(float x) { return (float)System.Math.Log((float)x, 2.0f); }
3150
3151 /// <summary>Returns the componentwise base-2 logarithm of a float2 vector.</summary>
3152 /// <param name="x">Input value.</param>
3153 /// <returns>The componentwise base-2 logarithm of the input.</returns>
3154 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3155 public static float2 log2(float2 x) { return new float2(log2(x.x), log2(x.y)); }
3156
3157 /// <summary>Returns the componentwise base-2 logarithm of a float3 vector.</summary>
3158 /// <param name="x">Input value.</param>
3159 /// <returns>The componentwise base-2 logarithm of the input.</returns>
3160 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3161 public static float3 log2(float3 x) { return new float3(log2(x.x), log2(x.y), log2(x.z)); }
3162
3163 /// <summary>Returns the componentwise base-2 logarithm of a float4 vector.</summary>
3164 /// <param name="x">Input value.</param>
3165 /// <returns>The componentwise base-2 logarithm of the input.</returns>
3166 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3167 public static float4 log2(float4 x) { return new float4(log2(x.x), log2(x.y), log2(x.z), log2(x.w)); }
3168
3169
3170 /// <summary>Returns the base-2 logarithm of a double value.</summary>
3171 /// <param name="x">Input value.</param>
3172 /// <returns>The base-2 logarithm of the input.</returns>
3173 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3174 public static double log2(double x) { return System.Math.Log(x, 2.0); }
3175
3176 /// <summary>Returns the componentwise base-2 logarithm of a double2 vector.</summary>
3177 /// <param name="x">Input value.</param>
3178 /// <returns>The componentwise base-2 logarithm of the input.</returns>
3179 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3180 public static double2 log2(double2 x) { return new double2(log2(x.x), log2(x.y)); }
3181
3182 /// <summary>Returns the componentwise base-2 logarithm of a double3 vector.</summary>
3183 /// <param name="x">Input value.</param>
3184 /// <returns>The componentwise base-2 logarithm of the input.</returns>
3185 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3186 public static double3 log2(double3 x) { return new double3(log2(x.x), log2(x.y), log2(x.z)); }
3187
3188 /// <summary>Returns the componentwise base-2 logarithm of a double4 vector.</summary>
3189 /// <param name="x">Input value.</param>
3190 /// <returns>The componentwise base-2 logarithm of the input.</returns>
3191 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3192 public static double4 log2(double4 x) { return new double4(log2(x.x), log2(x.y), log2(x.z), log2(x.w)); }
3193
3194 /// <summary>Returns the base-10 logarithm of a float value.</summary>
3195 /// <param name="x">Input value.</param>
3196 /// <returns>The base-10 logarithm of the input.</returns>
3197 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3198 public static float log10(float x) { return (float)System.Math.Log10((float)x); }
3199
3200 /// <summary>Returns the componentwise base-10 logarithm of a float2 vector.</summary>
3201 /// <param name="x">Input value.</param>
3202 /// <returns>The componentwise base-10 logarithm of the input.</returns>
3203 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3204 public static float2 log10(float2 x) { return new float2(log10(x.x), log10(x.y)); }
3205
3206 /// <summary>Returns the componentwise base-10 logarithm of a float3 vector.</summary>
3207 /// <param name="x">Input value.</param>
3208 /// <returns>The componentwise base-10 logarithm of the input.</returns>
3209 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3210 public static float3 log10(float3 x) { return new float3(log10(x.x), log10(x.y), log10(x.z)); }
3211
3212 /// <summary>Returns the componentwise base-10 logarithm of a float4 vector.</summary>
3213 /// <param name="x">Input value.</param>
3214 /// <returns>The componentwise base-10 logarithm of the input.</returns>
3215 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3216 public static float4 log10(float4 x) { return new float4(log10(x.x), log10(x.y), log10(x.z), log10(x.w)); }
3217
3218
3219 /// <summary>Returns the base-10 logarithm of a double value.</summary>
3220 /// <param name="x">Input value.</param>
3221 /// <returns>The base-10 logarithm of the input.</returns>
3222 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3223 public static double log10(double x) { return System.Math.Log10(x); }
3224
3225 /// <summary>Returns the componentwise base-10 logarithm of a double2 vector.</summary>
3226 /// <param name="x">Input value.</param>
3227 /// <returns>The componentwise base-10 logarithm of the input.</returns>
3228 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3229 public static double2 log10(double2 x) { return new double2(log10(x.x), log10(x.y)); }
3230
3231 /// <summary>Returns the componentwise base-10 logarithm of a double3 vector.</summary>
3232 /// <param name="x">Input value.</param>
3233 /// <returns>The componentwise base-10 logarithm of the input.</returns>
3234 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3235 public static double3 log10(double3 x) { return new double3(log10(x.x), log10(x.y), log10(x.z)); }
3236
3237 /// <summary>Returns the componentwise base-10 logarithm of a double4 vector.</summary>
3238 /// <param name="x">Input value.</param>
3239 /// <returns>The componentwise base-10 logarithm of the input.</returns>
3240 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3241 public static double4 log10(double4 x) { return new double4(log10(x.x), log10(x.y), log10(x.z), log10(x.w)); }
3242
3243
3244 /// <summary>Returns the floating point remainder of x/y.</summary>
3245 /// <param name="x">The dividend in x/y.</param>
3246 /// <param name="y">The divisor in x/y.</param>
3247 /// <returns>The remainder of x/y.</returns>
3248 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3249 public static float fmod(float x, float y) { return x % y; }
3250
3251 /// <summary>Returns the componentwise floating point remainder of x/y.</summary>
3252 /// <param name="x">The dividend in x/y.</param>
3253 /// <param name="y">The divisor in x/y.</param>
3254 /// <returns>The componentwise remainder of x/y.</returns>
3255 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3256 public static float2 fmod(float2 x, float2 y) { return new float2(x.x % y.x, x.y % y.y); }
3257
3258 /// <summary>Returns the componentwise floating point remainder of x/y.</summary>
3259 /// <param name="x">The dividend in x/y.</param>
3260 /// <param name="y">The divisor in x/y.</param>
3261 /// <returns>The componentwise remainder of x/y.</returns>
3262 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3263 public static float3 fmod(float3 x, float3 y) { return new float3(x.x % y.x, x.y % y.y, x.z % y.z); }
3264
3265 /// <summary>Returns the componentwise floating point remainder of x/y.</summary>
3266 /// <param name="x">The dividend in x/y.</param>
3267 /// <param name="y">The divisor in x/y.</param>
3268 /// <returns>The componentwise remainder of x/y.</returns>
3269 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3270 public static float4 fmod(float4 x, float4 y) { return new float4(x.x % y.x, x.y % y.y, x.z % y.z, x.w % y.w); }
3271
3272
3273 /// <summary>Returns the double precision floating point remainder of x/y.</summary>
3274 /// <param name="x">The dividend in x/y.</param>
3275 /// <param name="y">The divisor in x/y.</param>
3276 /// <returns>The remainder of x/y.</returns>
3277 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3278 public static double fmod(double x, double y) { return x % y; }
3279
3280 /// <summary>Returns the componentwise double precision floating point remainder of x/y.</summary>
3281 /// <param name="x">The dividend in x/y.</param>
3282 /// <param name="y">The divisor in x/y.</param>
3283 /// <returns>The componentwise remainder of x/y.</returns>
3284 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3285 public static double2 fmod(double2 x, double2 y) { return new double2(x.x % y.x, x.y % y.y); }
3286
3287 /// <summary>Returns the componentwise double precision floating point remainder of x/y.</summary>
3288 /// <param name="x">The dividend in x/y.</param>
3289 /// <param name="y">The divisor in x/y.</param>
3290 /// <returns>The componentwise remainder of x/y.</returns>
3291 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3292 public static double3 fmod(double3 x, double3 y) { return new double3(x.x % y.x, x.y % y.y, x.z % y.z); }
3293
3294 /// <summary>Returns the componentwise double precision floating point remainder of x/y.</summary>
3295 /// <param name="x">The dividend in x/y.</param>
3296 /// <param name="y">The divisor in x/y.</param>
3297 /// <returns>The componentwise remainder of x/y.</returns>
3298 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3299 public static double4 fmod(double4 x, double4 y) { return new double4(x.x % y.x, x.y % y.y, x.z % y.z, x.w % y.w); }
3300
3301
3302 /// <summary>Splits a float value into an integral part i and a fractional part that gets returned. Both parts take the sign of the input.</summary>
3303 /// <param name="x">Value to split into integral and fractional part.</param>
3304 /// <param name="i">Output value containing integral part of x.</param>
3305 /// <returns>The fractional part of x.</returns>
3306 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3307 public static float modf(float x, out float i) { i = trunc(x); return x - i; }
3308
3309 /// <summary>
3310 /// Performs a componentwise split of a float2 vector into an integral part i and a fractional part that gets returned.
3311 /// Both parts take the sign of the corresponding input component.
3312 /// </summary>
3313 /// <param name="x">Value to split into integral and fractional part.</param>
3314 /// <param name="i">Output value containing integral part of x.</param>
3315 /// <returns>The componentwise fractional part of x.</returns>
3316 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3317 public static float2 modf(float2 x, out float2 i) { i = trunc(x); return x - i; }
3318
3319 /// <summary>
3320 /// Performs a componentwise split of a float3 vector into an integral part i and a fractional part that gets returned.
3321 /// Both parts take the sign of the corresponding input component.
3322 /// </summary>
3323 /// <param name="x">Value to split into integral and fractional part.</param>
3324 /// <param name="i">Output value containing integral part of x.</param>
3325 /// <returns>The componentwise fractional part of x.</returns>
3326 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3327 public static float3 modf(float3 x, out float3 i) { i = trunc(x); return x - i; }
3328
3329 /// <summary>
3330 /// Performs a componentwise split of a float4 vector into an integral part i and a fractional part that gets returned.
3331 /// Both parts take the sign of the corresponding input component.
3332 /// </summary>
3333 /// <param name="x">Value to split into integral and fractional part.</param>
3334 /// <param name="i">Output value containing integral part of x.</param>
3335 /// <returns>The componentwise fractional part of x.</returns>
3336 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3337 public static float4 modf(float4 x, out float4 i) { i = trunc(x); return x - i; }
3338
3339
3340 /// <summary>Splits a double value into an integral part i and a fractional part that gets returned. Both parts take the sign of the input.</summary>
3341 /// <param name="x">Value to split into integral and fractional part.</param>
3342 /// <param name="i">Output value containing integral part of x.</param>
3343 /// <returns>The fractional part of x.</returns>
3344 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3345 public static double modf(double x, out double i) { i = trunc(x); return x - i; }
3346
3347 /// <summary>
3348 /// Performs a componentwise split of a double2 vector into an integral part i and a fractional part that gets returned.
3349 /// Both parts take the sign of the corresponding input component.
3350 /// </summary>
3351 /// <param name="x">Value to split into integral and fractional part.</param>
3352 /// <param name="i">Output value containing integral part of x.</param>
3353 /// <returns>The componentwise fractional part of x.</returns>
3354 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3355 public static double2 modf(double2 x, out double2 i) { i = trunc(x); return x - i; }
3356
3357 /// <summary>
3358 /// Performs a componentwise split of a double3 vector into an integral part i and a fractional part that gets returned.
3359 /// Both parts take the sign of the corresponding input component.
3360 /// </summary>
3361 /// <param name="x">Value to split into integral and fractional part.</param>
3362 /// <param name="i">Output value containing integral part of x.</param>
3363 /// <returns>The componentwise fractional part of x.</returns>
3364 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3365 public static double3 modf(double3 x, out double3 i) { i = trunc(x); return x - i; }
3366
3367 /// <summary>
3368 /// Performs a componentwise split of a double4 vector into an integral part i and a fractional part that gets returned.
3369 /// Both parts take the sign of the corresponding input component.
3370 /// </summary>
3371 /// <param name="x">Value to split into integral and fractional part.</param>
3372 /// <param name="i">Output value containing integral part of x.</param>
3373 /// <returns>The componentwise fractional part of x.</returns>
3374 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3375 public static double4 modf(double4 x, out double4 i) { i = trunc(x); return x - i; }
3376
3377
3378 /// <summary>Returns the square root of a float value.</summary>
3379 /// <param name="x">Value to use when computing square root.</param>
3380 /// <returns>The square root.</returns>
3381 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3382 public static float sqrt(float x) { return (float)System.Math.Sqrt((float)x); }
3383
3384 /// <summary>Returns the componentwise square root of a float2 vector.</summary>
3385 /// <param name="x">Value to use when computing square root.</param>
3386 /// <returns>The componentwise square root.</returns>
3387 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3388 public static float2 sqrt(float2 x) { return new float2(sqrt(x.x), sqrt(x.y)); }
3389
3390 /// <summary>Returns the componentwise square root of a float3 vector.</summary>
3391 /// <param name="x">Value to use when computing square root.</param>
3392 /// <returns>The componentwise square root.</returns>
3393 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3394 public static float3 sqrt(float3 x) { return new float3(sqrt(x.x), sqrt(x.y), sqrt(x.z)); }
3395
3396 /// <summary>Returns the componentwise square root of a float4 vector.</summary>
3397 /// <param name="x">Value to use when computing square root.</param>
3398 /// <returns>The componentwise square root.</returns>
3399 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3400 public static float4 sqrt(float4 x) { return new float4(sqrt(x.x), sqrt(x.y), sqrt(x.z), sqrt(x.w)); }
3401
3402
3403 /// <summary>Returns the square root of a double value.</summary>
3404 /// <param name="x">Value to use when computing square root.</param>
3405 /// <returns>The square root.</returns>
3406 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3407 public static double sqrt(double x) { return System.Math.Sqrt(x); }
3408
3409 /// <summary>Returns the componentwise square root of a double2 vector.</summary>
3410 /// <param name="x">Value to use when computing square root.</param>
3411 /// <returns>The componentwise square root.</returns>
3412 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3413 public static double2 sqrt(double2 x) { return new double2(sqrt(x.x), sqrt(x.y)); }
3414
3415 /// <summary>Returns the componentwise square root of a double3 vector.</summary>
3416 /// <param name="x">Value to use when computing square root.</param>
3417 /// <returns>The componentwise square root.</returns>
3418 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3419 public static double3 sqrt(double3 x) { return new double3(sqrt(x.x), sqrt(x.y), sqrt(x.z)); }
3420
3421 /// <summary>Returns the componentwise square root of a double4 vector.</summary>
3422 /// <param name="x">Value to use when computing square root.</param>
3423 /// <returns>The componentwise square root.</returns>
3424 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3425 public static double4 sqrt(double4 x) { return new double4(sqrt(x.x), sqrt(x.y), sqrt(x.z), sqrt(x.w)); }
3426
3427
3428 /// <summary>Returns the reciprocal square root of a float value.</summary>
3429 /// <param name="x">Value to use when computing reciprocal square root.</param>
3430 /// <returns>The reciprocal square root.</returns>
3431 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3432 public static float rsqrt(float x) { return 1.0f / sqrt(x); }
3433
3434 /// <summary>Returns the componentwise reciprocal square root of a float2 vector.</summary>
3435 /// <param name="x">Value to use when computing reciprocal square root.</param>
3436 /// <returns>The componentwise reciprocal square root.</returns>
3437 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3438 public static float2 rsqrt(float2 x) { return 1.0f / sqrt(x); }
3439
3440 /// <summary>Returns the componentwise reciprocal square root of a float3 vector.</summary>
3441 /// <param name="x">Value to use when computing reciprocal square root.</param>
3442 /// <returns>The componentwise reciprocal square root.</returns>
3443 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3444 public static float3 rsqrt(float3 x) { return 1.0f / sqrt(x); }
3445
3446 /// <summary>Returns the componentwise reciprocal square root of a float4 vector</summary>
3447 /// <param name="x">Value to use when computing reciprocal square root.</param>
3448 /// <returns>The componentwise reciprocal square root.</returns>
3449 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3450 public static float4 rsqrt(float4 x) { return 1.0f / sqrt(x); }
3451
3452
3453 /// <summary>Returns the reciprocal square root of a double value.</summary>
3454 /// <param name="x">Value to use when computing reciprocal square root.</param>
3455 /// <returns>The reciprocal square root.</returns>
3456 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3457 public static double rsqrt(double x) { return 1.0 / sqrt(x); }
3458
3459 /// <summary>Returns the componentwise reciprocal square root of a double2 vector.</summary>
3460 /// <param name="x">Value to use when computing reciprocal square root.</param>
3461 /// <returns>The componentwise reciprocal square root.</returns>
3462 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3463 public static double2 rsqrt(double2 x) { return 1.0 / sqrt(x); }
3464
3465 /// <summary>Returns the componentwise reciprocal square root of a double3 vector.</summary>
3466 /// <param name="x">Value to use when computing reciprocal square root.</param>
3467 /// <returns>The componentwise reciprocal square root.</returns>
3468 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3469 public static double3 rsqrt(double3 x) { return 1.0 / sqrt(x); }
3470
3471 /// <summary>Returns the componentwise reciprocal square root of a double4 vector.</summary>
3472 /// <param name="x">Value to use when computing reciprocal square root.</param>
3473 /// <returns>The componentwise reciprocal square root.</returns>
3474 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3475 public static double4 rsqrt(double4 x) { return 1.0 / sqrt(x); }
3476
3477
3478 /// <summary>Returns a normalized version of the float2 vector x by scaling it by 1 / length(x).</summary>
3479 /// <param name="x">Vector to normalize.</param>
3480 /// <returns>The normalized vector.</returns>
3481 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3482 public static float2 normalize(float2 x) { return rsqrt(dot(x, x)) * x; }
3483
3484 /// <summary>Returns a normalized version of the float3 vector x by scaling it by 1 / length(x).</summary>
3485 /// <param name="x">Vector to normalize.</param>
3486 /// <returns>The normalized vector.</returns>
3487 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3488 public static float3 normalize(float3 x) { return rsqrt(dot(x, x)) * x; }
3489
3490 /// <summary>Returns a normalized version of the float4 vector x by scaling it by 1 / length(x).</summary>
3491 /// <param name="x">Vector to normalize.</param>
3492 /// <returns>The normalized vector.</returns>
3493 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3494 public static float4 normalize(float4 x) { return rsqrt(dot(x, x)) * x; }
3495
3496
3497 /// <summary>Returns a normalized version of the double2 vector x by scaling it by 1 / length(x).</summary>
3498 /// <param name="x">Vector to normalize.</param>
3499 /// <returns>The normalized vector.</returns>
3500 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3501 public static double2 normalize(double2 x) { return rsqrt(dot(x, x)) * x; }
3502
3503 /// <summary>Returns a normalized version of the double3 vector x by scaling it by 1 / length(x).</summary>
3504 /// <param name="x">Vector to normalize.</param>
3505 /// <returns>The normalized vector.</returns>
3506 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3507 public static double3 normalize(double3 x) { return rsqrt(dot(x, x)) * x; }
3508
3509 /// <summary>Returns a normalized version of the double4 vector x by scaling it by 1 / length(x).</summary>
3510 /// <param name="x">Vector to normalize.</param>
3511 /// <returns>The normalized vector.</returns>
3512 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3513 public static double4 normalize(double4 x) { return rsqrt(dot(x, x)) * x; }
3514
3515
3516 /// <summary>
3517 /// Returns a safe normalized version of the float2 vector x by scaling it by 1 / length(x).
3518 /// Returns the given default value when 1 / length(x) does not produce a finite number.
3519 /// </summary>
3520 /// <param name="x">Vector to normalize.</param>
3521 /// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
3522 /// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
3523 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3524 static public float2 normalizesafe(float2 x, float2 defaultvalue = new float2())
3525 {
3526 float len = math.dot(x, x);
3527 return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
3528 }
3529
3530 /// <summary>
3531 /// Returns a safe normalized version of the float3 vector x by scaling it by 1 / length(x).
3532 /// Returns the given default value when 1 / length(x) does not produce a finite number.
3533 /// </summary>
3534 /// <param name="x">Vector to normalize.</param>
3535 /// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
3536 /// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
3537 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3538 static public float3 normalizesafe(float3 x, float3 defaultvalue = new float3())
3539 {
3540 float len = math.dot(x, x);
3541 return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
3542 }
3543
3544 /// <summary>
3545 /// Returns a safe normalized version of the float4 vector x by scaling it by 1 / length(x).
3546 /// Returns the given default value when 1 / length(x) does not produce a finite number.
3547 /// </summary>
3548 /// <param name="x">Vector to normalize.</param>
3549 /// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
3550 /// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
3551 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3552 static public float4 normalizesafe(float4 x, float4 defaultvalue = new float4())
3553 {
3554 float len = math.dot(x, x);
3555 return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
3556 }
3557
3558
3559 /// <summary>
3560 /// Returns a safe normalized version of the double4 vector x by scaling it by 1 / length(x).
3561 /// Returns the given default value when 1 / length(x) does not produce a finite number.
3562 /// </summary>
3563 /// <param name="x">Vector to normalize.</param>
3564 /// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
3565 /// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
3566 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3567 static public double2 normalizesafe(double2 x, double2 defaultvalue = new double2())
3568 {
3569 double len = math.dot(x, x);
3570 return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
3571 }
3572
3573 /// <summary>
3574 /// Returns a safe normalized version of the double4 vector x by scaling it by 1 / length(x).
3575 /// Returns the given default value when 1 / length(x) does not produce a finite number.
3576 /// </summary>
3577 /// <param name="x">Vector to normalize.</param>
3578 /// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
3579 /// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
3580 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3581 static public double3 normalizesafe(double3 x, double3 defaultvalue = new double3())
3582 {
3583 double len = math.dot(x, x);
3584 return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
3585 }
3586
3587 /// <summary>
3588 /// Returns a safe normalized version of the double4 vector x by scaling it by 1 / length(x).
3589 /// Returns the given default value when 1 / length(x) does not produce a finite number.
3590 /// </summary>
3591 /// <param name="x">Vector to normalize.</param>
3592 /// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
3593 /// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
3594 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3595 static public double4 normalizesafe(double4 x, double4 defaultvalue = new double4())
3596 {
3597 double len = math.dot(x, x);
3598 return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
3599 }
3600
3601
3602 /// <summary>Returns the length of a float value. Equivalent to the absolute value.</summary>
3603 /// <param name="x">Value to use when computing length.</param>
3604 /// <returns>Length of x.</returns>
3605 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3606 public static float length(float x) { return abs(x); }
3607
3608 /// <summary>Returns the length of a float2 vector.</summary>
3609 /// <param name="x">Vector to use when computing length.</param>
3610 /// <returns>Length of vector x.</returns>
3611 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3612 public static float length(float2 x) { return sqrt(dot(x, x)); }
3613
3614 /// <summary>Returns the length of a float3 vector.</summary>
3615 /// <param name="x">Vector to use when computing length.</param>
3616 /// <returns>Length of vector x.</returns>
3617 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3618 public static float length(float3 x) { return sqrt(dot(x, x)); }
3619
3620 /// <summary>Returns the length of a float4 vector.</summary>
3621 /// <param name="x">Vector to use when computing length.</param>
3622 /// <returns>Length of vector x.</returns>
3623 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3624 public static float length(float4 x) { return sqrt(dot(x, x)); }
3625
3626
3627 /// <summary>Returns the length of a double value. Equivalent to the absolute value.</summary>
3628 /// <param name="x">Value to use when computing squared length.</param>
3629 /// <returns>Squared length of x.</returns>
3630 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3631 public static double length(double x) { return abs(x); }
3632
3633 /// <summary>Returns the length of a double2 vector.</summary>
3634 /// <param name="x">Vector to use when computing squared length.</param>
3635 /// <returns>Squared length of vector x.</returns>
3636 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3637 public static double length(double2 x) { return sqrt(dot(x, x)); }
3638
3639 /// <summary>Returns the length of a double3 vector.</summary>
3640 /// <param name="x">Vector to use when computing squared length.</param>
3641 /// <returns>Squared length of vector x.</returns>
3642 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3643 public static double length(double3 x) { return sqrt(dot(x, x)); }
3644
3645 /// <summary>Returns the length of a double4 vector.</summary>
3646 /// <param name="x">Vector to use when computing squared length.</param>
3647 /// <returns>Squared length of vector x.</returns>
3648 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3649 public static double length(double4 x) { return sqrt(dot(x, x)); }
3650
3651
3652 /// <summary>Returns the squared length of a float value. Equivalent to squaring the value.</summary>
3653 /// <param name="x">Value to use when computing squared length.</param>
3654 /// <returns>Squared length of x.</returns>
3655 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3656 public static float lengthsq(float x) { return x*x; }
3657
3658 /// <summary>Returns the squared length of a float2 vector.</summary>
3659 /// <param name="x">Vector to use when computing squared length.</param>
3660 /// <returns>Squared length of vector x.</returns>
3661 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3662 public static float lengthsq(float2 x) { return dot(x, x); }
3663
3664 /// <summary>Returns the squared length of a float3 vector.</summary>
3665 /// <param name="x">Vector to use when computing squared length.</param>
3666 /// <returns>Squared length of vector x.</returns>
3667 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3668 public static float lengthsq(float3 x) { return dot(x, x); }
3669
3670 /// <summary>Returns the squared length of a float4 vector.</summary>
3671 /// <param name="x">Vector to use when computing squared length.</param>
3672 /// <returns>Squared length of vector x.</returns>
3673 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3674 public static float lengthsq(float4 x) { return dot(x, x); }
3675
3676
3677 /// <summary>Returns the squared length of a double value. Equivalent to squaring the value.</summary>
3678 /// <param name="x">Value to use when computing squared length.</param>
3679 /// <returns>Squared length of x.</returns>
3680 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3681 public static double lengthsq(double x) { return x * x; }
3682
3683 /// <summary>Returns the squared length of a double2 vector.</summary>
3684 /// <param name="x">Vector to use when computing squared length.</param>
3685 /// <returns>Squared length of vector x.</returns>
3686 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3687 public static double lengthsq(double2 x) { return dot(x, x); }
3688
3689 /// <summary>Returns the squared length of a double3 vector.</summary>
3690 /// <param name="x">Vector to use when computing squared length.</param>
3691 /// <returns>Squared length of vector x.</returns>
3692 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3693 public static double lengthsq(double3 x) { return dot(x, x); }
3694
3695 /// <summary>Returns the squared length of a double4 vector.</summary>
3696 /// <param name="x">Vector to use when computing squared length.</param>
3697 /// <returns>Squared length of vector x.</returns>
3698 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3699 public static double lengthsq(double4 x) { return dot(x, x); }
3700
3701
3702 /// <summary>Returns the distance between two float values.</summary>
3703 /// <param name="x">First value to use in distance computation.</param>
3704 /// <param name="y">Second value to use in distance computation.</param>
3705 /// <returns>The distance between x and y.</returns>
3706 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3707 public static float distance(float x, float y) { return abs(y - x); }
3708
3709 /// <summary>Returns the distance between two float2 vectors.</summary>
3710 /// <param name="x">First vector to use in distance computation.</param>
3711 /// <param name="y">Second vector to use in distance computation.</param>
3712 /// <returns>The distance between x and y.</returns>
3713 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3714 public static float distance(float2 x, float2 y) { return length(y - x); }
3715
3716 /// <summary>Returns the distance between two float3 vectors.</summary>
3717 /// <param name="x">First vector to use in distance computation.</param>
3718 /// <param name="y">Second vector to use in distance computation.</param>
3719 /// <returns>The distance between x and y.</returns>
3720 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3721 public static float distance(float3 x, float3 y) { return length(y - x); }
3722
3723 /// <summary>Returns the distance between two float4 vectors.</summary>
3724 /// <param name="x">First vector to use in distance computation.</param>
3725 /// <param name="y">Second vector to use in distance computation.</param>
3726 /// <returns>The distance between x and y.</returns>
3727 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3728 public static float distance(float4 x, float4 y) { return length(y - x); }
3729
3730
3731 /// <summary>Returns the distance between two double values.</summary>
3732 /// <param name="x">First value to use in distance computation.</param>
3733 /// <param name="y">Second value to use in distance computation.</param>
3734 /// <returns>The distance between x and y.</returns>
3735 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3736 public static double distance(double x, double y) { return abs(y - x); }
3737
3738 /// <summary>Returns the distance between two double2 vectors.</summary>
3739 /// <param name="x">First vector to use in distance computation.</param>
3740 /// <param name="y">Second vector to use in distance computation.</param>
3741 /// <returns>The distance between x and y.</returns>
3742 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3743 public static double distance(double2 x, double2 y) { return length(y - x); }
3744
3745 /// <summary>Returns the distance between two double3 vectors.</summary>
3746 /// <param name="x">First vector to use in distance computation.</param>
3747 /// <param name="y">Second vector to use in distance computation.</param>
3748 /// <returns>The distance between x and y.</returns>
3749 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3750 public static double distance(double3 x, double3 y) { return length(y - x); }
3751
3752 /// <summary>Returns the distance between two double4 vectors.</summary>
3753 /// <param name="x">First vector to use in distance computation.</param>
3754 /// <param name="y">Second vector to use in distance computation.</param>
3755 /// <returns>The distance between x and y.</returns>
3756 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3757 public static double distance(double4 x, double4 y) { return length(y - x); }
3758
3759
3760 /// <summary>Returns the squared distance between two float values.</summary>
3761 /// <param name="x">First value to use in distance computation.</param>
3762 /// <param name="y">Second value to use in distance computation.</param>
3763 /// <returns>The squared distance between x and y.</returns>
3764 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3765 public static float distancesq(float x, float y) { return (y - x) * (y - x); }
3766
3767 /// <summary>Returns the squared distance between two float2 vectors.</summary>
3768 /// <param name="x">First vector to use in distance computation.</param>
3769 /// <param name="y">Second vector to use in distance computation.</param>
3770 /// <returns>The squared distance between x and y.</returns>
3771 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3772 public static float distancesq(float2 x, float2 y) { return lengthsq(y - x); }
3773
3774 /// <summary>Returns the squared distance between two float3 vectors.</summary>
3775 /// <param name="x">First vector to use in distance computation.</param>
3776 /// <param name="y">Second vector to use in distance computation.</param>
3777 /// <returns>The squared distance between x and y.</returns>
3778 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3779 public static float distancesq(float3 x, float3 y) { return lengthsq(y - x); }
3780
3781 /// <summary>Returns the squared distance between two float4 vectors.</summary>
3782 /// <param name="x">First vector to use in distance computation.</param>
3783 /// <param name="y">Second vector to use in distance computation.</param>
3784 /// <returns>The squared distance between x and y.</returns>
3785 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3786 public static float distancesq(float4 x, float4 y) { return lengthsq(y - x); }
3787
3788
3789 /// <summary>Returns the squared distance between two double values.</summary>
3790 /// <param name="x">First value to use in distance computation.</param>
3791 /// <param name="y">Second value to use in distance computation.</param>
3792 /// <returns>The squared distance between x and y.</returns>
3793 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3794 public static double distancesq(double x, double y) { return (y - x) * (y - x); }
3795
3796 /// <summary>Returns the squared distance between two double2 vectors.</summary>
3797 /// <param name="x">First vector to use in distance computation.</param>
3798 /// <param name="y">Second vector to use in distance computation.</param>
3799 /// <returns>The squared distance between x and y.</returns>
3800 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3801 public static double distancesq(double2 x, double2 y) { return lengthsq(y - x); }
3802
3803 /// <summary>Returns the squared distance between two double3 vectors.</summary>
3804 /// <param name="x">First vector to use in distance computation.</param>
3805 /// <param name="y">Second vector to use in distance computation.</param>
3806 /// <returns>The squared distance between x and y.</returns>
3807 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3808 public static double distancesq(double3 x, double3 y) { return lengthsq(y - x); }
3809
3810 /// <summary>Returns the squared distance between two double4 vectors.</summary>
3811 /// <param name="x">First vector to use in distance computation.</param>
3812 /// <param name="y">Second vector to use in distance computation.</param>
3813 /// <returns>The squared distance between x and y.</returns>
3814 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3815 public static double distancesq(double4 x, double4 y) { return lengthsq(y - x); }
3816
3817
3818 /// <summary>Returns the cross product of two float3 vectors.</summary>
3819 /// <param name="x">First vector to use in cross product.</param>
3820 /// <param name="y">Second vector to use in cross product.</param>
3821 /// <returns>The cross product of x and y.</returns>
3822 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3823 public static float3 cross(float3 x, float3 y) { return (x * y.yzx - x.yzx * y).yzx; }
3824
3825 /// <summary>Returns the cross product of two double3 vectors.</summary>
3826 /// <param name="x">First vector to use in cross product.</param>
3827 /// <param name="y">Second vector to use in cross product.</param>
3828 /// <returns>The cross product of x and y.</returns>
3829 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3830 public static double3 cross(double3 x, double3 y) { return (x * y.yzx - x.yzx * y).yzx; }
3831
3832
3833 /// <summary>Returns a smooth Hermite interpolation between 0.0f and 1.0f when x is in the interval (inclusive) [xMin, xMax].</summary>
3834 /// <param name="xMin">The minimum range of the x parameter.</param>
3835 /// <param name="xMax">The maximum range of the x parameter.</param>
3836 /// <param name="x">The value to be interpolated.</param>
3837 /// <returns>Returns a value camped to the range [0, 1].</returns>
3838 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3839 public static float smoothstep(float xMin, float xMax, float x)
3840 {
3841 var t = saturate((x - xMin) / (xMax - xMin));
3842 return t * t * (3.0f - (2.0f * t));
3843 }
3844
3845 /// <summary>Returns a componentwise smooth Hermite interpolation between 0.0f and 1.0f when x is in the interval (inclusive) [xMin, xMax].</summary>
3846 /// <param name="xMin">The minimum range of the x parameter.</param>
3847 /// <param name="xMax">The maximum range of the x parameter.</param>
3848 /// <param name="x">The value to be interpolated.</param>
3849 /// <returns>Returns component values camped to the range [0, 1].</returns>
3850 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3851 public static float2 smoothstep(float2 xMin, float2 xMax, float2 x)
3852 {
3853 var t = saturate((x - xMin) / (xMax - xMin));
3854 return t * t * (3.0f - (2.0f * t));
3855 }
3856
3857 /// <summary>Returns a componentwise smooth Hermite interpolation between 0.0f and 1.0f when x is in the interval (inclusive) [xMin, xMax].</summary>
3858 /// <param name="xMin">The minimum range of the x parameter.</param>
3859 /// <param name="xMax">The maximum range of the x parameter.</param>
3860 /// <param name="x">The value to be interpolated.</param>
3861 /// <returns>Returns component values camped to the range [0, 1].</returns>
3862 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3863 public static float3 smoothstep(float3 xMin, float3 xMax, float3 x)
3864 {
3865 var t = saturate((x - xMin) / (xMax - xMin));
3866 return t * t * (3.0f - (2.0f * t));
3867 }
3868
3869 /// <summary>Returns a componentwise smooth Hermite interpolation between 0.0f and 1.0f when x is in the interval (inclusive) [xMin, xMax].</summary>
3870 /// <param name="xMin">The minimum range of the x parameter.</param>
3871 /// <param name="xMax">The maximum range of the x parameter.</param>
3872 /// <param name="x">The value to be interpolated.</param>
3873 /// <returns>Returns component values camped to the range [0, 1].</returns>
3874 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3875 public static float4 smoothstep(float4 xMin, float4 xMax, float4 x)
3876 {
3877 var t = saturate((x - xMin) / (xMax - xMin));
3878 return t * t * (3.0f - (2.0f * t));
3879 }
3880
3881
3882 /// <summary>Returns a smooth Hermite interpolation between 0.0 and 1.0 when x is in the interval (inclusive) [xMin, xMax].</summary>
3883 /// <param name="xMin">The minimum range of the x parameter.</param>
3884 /// <param name="xMax">The maximum range of the x parameter.</param>
3885 /// <param name="x">The value to be interpolated.</param>
3886 /// <returns>Returns a value camped to the range [0, 1].</returns>
3887 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3888 public static double smoothstep(double xMin, double xMax, double x)
3889 {
3890 var t = saturate((x - xMin) / (xMax - xMin));
3891 return t * t * (3.0 - (2.0 * t));
3892 }
3893
3894 /// <summary>Returns a componentwise smooth Hermite interpolation between 0.0 and 1.0 when x is in the interval (inclusive) [xMin, xMax].</summary>
3895 /// <param name="xMin">The minimum range of the x parameter.</param>
3896 /// <param name="xMax">The maximum range of the x parameter.</param>
3897 /// <param name="x">The value to be interpolated.</param>
3898 /// <returns>Returns component values camped to the range [0, 1].</returns>
3899 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3900 public static double2 smoothstep(double2 xMin, double2 xMax, double2 x)
3901 {
3902 var t = saturate((x - xMin) / (xMax - xMin));
3903 return t * t * (3.0 - (2.0 * t));
3904 }
3905
3906 /// <summary>Returns a componentwise smooth Hermite interpolation between 0.0 and 1.0 when x is in the interval (inclusive) [xMin, xMax].</summary>
3907 /// <param name="xMin">The minimum range of the x parameter.</param>
3908 /// <param name="xMax">The maximum range of the x parameter.</param>
3909 /// <param name="x">The value to be interpolated.</param>
3910 /// <returns>Returns component values camped to the range [0, 1].</returns>
3911 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3912 public static double3 smoothstep(double3 xMin, double3 xMax, double3 x)
3913 {
3914 var t = saturate((x - xMin) / (xMax - xMin));
3915 return t * t * (3.0 - (2.0 * t));
3916 }
3917
3918 /// <summary>Returns a componentwise smooth Hermite interpolation between 0.0 and 1.0 when x is in the interval (inclusive) [xMin, xMax].</summary>
3919 /// <param name="xMin">The minimum range of the x parameter.</param>
3920 /// <param name="xMax">The maximum range of the x parameter.</param>
3921 /// <param name="x">The value to be interpolated.</param>
3922 /// <returns>Returns component values camped to the range [0, 1].</returns>
3923 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3924 public static double4 smoothstep(double4 xMin, double4 xMax, double4 x)
3925 {
3926 var t = saturate((x - xMin) / (xMax - xMin));
3927 return t * t * (3.0 - (2.0 * t));
3928 }
3929
3930
3931 /// <summary>Returns true if any component of the input bool2 vector is true, false otherwise.</summary>
3932 /// <param name="x">Vector of values to compare.</param>
3933 /// <returns>True if any the components of x are true, false otherwise.</returns>
3934 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3935 public static bool any(bool2 x) { return x.x || x.y; }
3936
3937 /// <summary>Returns true if any component of the input bool3 vector is true, false otherwise.</summary>
3938 /// <param name="x">Vector of values to compare.</param>
3939 /// <returns>True if any the components of x are true, false otherwise.</returns>
3940 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3941 public static bool any(bool3 x) { return x.x || x.y || x.z; }
3942
3943 /// <summary>Returns true if any components of the input bool4 vector is true, false otherwise.</summary>
3944 /// <param name="x">Vector of values to compare.</param>
3945 /// <returns>True if any the components of x are true, false otherwise.</returns>
3946 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3947 public static bool any(bool4 x) { return x.x || x.y || x.z || x.w; }
3948
3949
3950 /// <summary>Returns true if any component of the input int2 vector is non-zero, false otherwise.</summary>
3951 /// <param name="x">Vector of values to compare.</param>
3952 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
3953 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3954 public static bool any(int2 x) { return x.x != 0 || x.y != 0; }
3955
3956 /// <summary>Returns true if any component of the input int3 vector is non-zero, false otherwise.</summary>
3957 /// <param name="x">Vector of values to compare.</param>
3958 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
3959 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3960 public static bool any(int3 x) { return x.x != 0 || x.y != 0 || x.z != 0; }
3961
3962 /// <summary>Returns true if any components of the input int4 vector is non-zero, false otherwise.</summary>
3963 /// <param name="x">Vector of values to compare.</param>
3964 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
3965 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3966 public static bool any(int4 x) { return x.x != 0 || x.y != 0 || x.z != 0 || x.w != 0; }
3967
3968
3969 /// <summary>Returns true if any component of the input uint2 vector is non-zero, false otherwise.</summary>
3970 /// <param name="x">Vector of values to compare.</param>
3971 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
3972 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3973 public static bool any(uint2 x) { return x.x != 0 || x.y != 0; }
3974
3975 /// <summary>Returns true if any component of the input uint3 vector is non-zero, false otherwise.</summary>
3976 /// <param name="x">Vector of values to compare.</param>
3977 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
3978 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3979 public static bool any(uint3 x) { return x.x != 0 || x.y != 0 || x.z != 0; }
3980
3981 /// <summary>Returns true if any components of the input uint4 vector is non-zero, false otherwise.</summary>
3982 /// <param name="x">Vector of values to compare.</param>
3983 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
3984 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3985 public static bool any(uint4 x) { return x.x != 0 || x.y != 0 || x.z != 0 || x.w != 0; }
3986
3987
3988 /// <summary>Returns true if any component of the input float2 vector is non-zero, false otherwise.</summary>
3989 /// <param name="x">Vector of values to compare.</param>
3990 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
3991 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3992 public static bool any(float2 x) { return x.x != 0.0f || x.y != 0.0f; }
3993
3994 /// <summary>Returns true if any component of the input float3 vector is non-zero, false otherwise.</summary>
3995 /// <param name="x">Vector of values to compare.</param>
3996 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
3997 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3998 public static bool any(float3 x) { return x.x != 0.0f || x.y != 0.0f || x.z != 0.0f; }
3999
4000 /// <summary>Returns true if any component of the input float4 vector is non-zero, false otherwise.</summary>
4001 /// <param name="x">Vector of values to compare.</param>
4002 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
4003 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4004 public static bool any(float4 x) { return x.x != 0.0f || x.y != 0.0f || x.z != 0.0f || x.w != 0.0f; }
4005
4006
4007 /// <summary>Returns true if any component of the input double2 vector is non-zero, false otherwise.</summary>
4008 /// <param name="x">Vector of values to compare.</param>
4009 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
4010 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4011 public static bool any(double2 x) { return x.x != 0.0 || x.y != 0.0; }
4012
4013 /// <summary>Returns true if any component of the input double3 vector is non-zero, false otherwise.</summary>
4014 /// <param name="x">Vector of values to compare.</param>
4015 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
4016 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4017 public static bool any(double3 x) { return x.x != 0.0 || x.y != 0.0 || x.z != 0.0; }
4018
4019 /// <summary>Returns true if any component of the input double4 vector is non-zero, false otherwise.</summary>
4020 /// <param name="x">Vector of values to compare.</param>
4021 /// <returns>True if any the components of x are non-zero, false otherwise.</returns>
4022 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4023 public static bool any(double4 x) { return x.x != 0.0 || x.y != 0.0 || x.z != 0.0 || x.w != 0.0; }
4024
4025
4026 /// <summary>Returns true if all components of the input bool2 vector are true, false otherwise.</summary>
4027 /// <param name="x">Vector of values to compare.</param>
4028 /// <returns>True if all the components of x are true, false otherwise.</returns>
4029 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4030 public static bool all(bool2 x) { return x.x && x.y; }
4031
4032 /// <summary>Returns true if all components of the input bool3 vector are true, false otherwise.</summary>
4033 /// <param name="x">Vector of values to compare.</param>
4034 /// <returns>True if all the components of x are true, false otherwise.</returns>
4035 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4036 public static bool all(bool3 x) { return x.x && x.y && x.z; }
4037
4038 /// <summary>Returns true if all components of the input bool4 vector are true, false otherwise.</summary>
4039 /// <param name="x">Vector of values to compare.</param>
4040 /// <returns>True if all the components of x are true, false otherwise.</returns>
4041 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4042 public static bool all(bool4 x) { return x.x && x.y && x.z && x.w; }
4043
4044
4045 /// <summary>Returns true if all components of the input int2 vector are non-zero, false otherwise.</summary>
4046 /// <param name="x">Vector of values to compare.</param>
4047 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4048 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4049 public static bool all(int2 x) { return x.x != 0 && x.y != 0; }
4050
4051 /// <summary>Returns true if all components of the input int3 vector are non-zero, false otherwise.</summary>
4052 /// <param name="x">Vector of values to compare.</param>
4053 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4054 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4055 public static bool all(int3 x) { return x.x != 0 && x.y != 0 && x.z != 0; }
4056
4057 /// <summary>Returns true if all components of the input int4 vector are non-zero, false otherwise.</summary>
4058 /// <param name="x">Vector of values to compare.</param>
4059 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4060 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4061 public static bool all(int4 x) { return x.x != 0 && x.y != 0 && x.z != 0 && x.w != 0; }
4062
4063
4064 /// <summary>Returns true if all components of the input uint2 vector are non-zero, false otherwise.</summary>
4065 /// <param name="x">Vector of values to compare.</param>
4066 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4067 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4068 public static bool all(uint2 x) { return x.x != 0 && x.y != 0; }
4069
4070 /// <summary>Returns true if all components of the input uint3 vector are non-zero, false otherwise.</summary>
4071 /// <param name="x">Vector of values to compare.</param>
4072 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4073 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4074 public static bool all(uint3 x) { return x.x != 0 && x.y != 0 && x.z != 0; }
4075
4076 /// <summary>Returns true if all components of the input uint4 vector are non-zero, false otherwise.</summary>
4077 /// <param name="x">Vector of values to compare.</param>
4078 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4079 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4080 public static bool all(uint4 x) { return x.x != 0 && x.y != 0 && x.z != 0 && x.w != 0; }
4081
4082
4083 /// <summary>Returns true if all components of the input float2 vector are non-zero, false otherwise.</summary>
4084 /// <param name="x">Vector of values to compare.</param>
4085 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4086 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4087 public static bool all(float2 x) { return x.x != 0.0f && x.y != 0.0f; }
4088
4089 /// <summary>Returns true if all components of the input float3 vector are non-zero, false otherwise.</summary>
4090 /// <param name="x">Vector of values to compare.</param>
4091 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4092 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4093 public static bool all(float3 x) { return x.x != 0.0f && x.y != 0.0f && x.z != 0.0f; }
4094
4095 /// <summary>Returns true if all components of the input float4 vector are non-zero, false otherwise.</summary>
4096 /// <param name="x">Vector of values to compare.</param>
4097 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4098 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4099 public static bool all(float4 x) { return x.x != 0.0f && x.y != 0.0f && x.z != 0.0f && x.w != 0.0f; }
4100
4101
4102 /// <summary>Returns true if all components of the input double2 vector are non-zero, false otherwise.</summary>
4103 /// <param name="x">Vector of values to compare.</param>
4104 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4105 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4106 public static bool all(double2 x) { return x.x != 0.0 && x.y != 0.0; }
4107
4108 /// <summary>Returns true if all components of the input double3 vector are non-zero, false otherwise.</summary>
4109 /// <param name="x">Vector of values to compare.</param>
4110 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4111 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4112 public static bool all(double3 x) { return x.x != 0.0 && x.y != 0.0 && x.z != 0.0; }
4113
4114 /// <summary>Returns true if all components of the input double4 vector are non-zero, false otherwise.</summary>
4115 /// <param name="x">Vector of values to compare.</param>
4116 /// <returns>True if all the components of x are non-zero, false otherwise.</returns>
4117 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4118 public static bool all(double4 x) { return x.x != 0.0 && x.y != 0.0 && x.z != 0.0 && x.w != 0.0; }
4119
4120
4121 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4122 /// <param name="falseValue">Value to use if test is false.</param>
4123 /// <param name="trueValue">Value to use if test is true.</param>
4124 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4125 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4126 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4127 public static int select(int falseValue, int trueValue, bool test) { return test ? trueValue : falseValue; }
4128
4129 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4130 /// <param name="falseValue">Value to use if test is false.</param>
4131 /// <param name="trueValue">Value to use if test is true.</param>
4132 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4133 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4134 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4135 public static int2 select(int2 falseValue, int2 trueValue, bool test) { return test ? trueValue : falseValue; }
4136
4137 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4138 /// <param name="falseValue">Value to use if test is false.</param>
4139 /// <param name="trueValue">Value to use if test is true.</param>
4140 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4141 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4142 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4143 public static int3 select(int3 falseValue, int3 trueValue, bool test) { return test ? trueValue : falseValue; }
4144
4145 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4146 /// <param name="falseValue">Value to use if test is false.</param>
4147 /// <param name="trueValue">Value to use if test is true.</param>
4148 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4149 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4150 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4151 public static int4 select(int4 falseValue, int4 trueValue, bool test) { return test ? trueValue : falseValue; }
4152
4153
4154 /// <summary>
4155 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4156 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4157 /// </summary>
4158 /// <param name="falseValue">Values to use if test is false.</param>
4159 /// <param name="trueValue">Values to use if test is true.</param>
4160 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4161 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4162 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4163 public static int2 select(int2 falseValue, int2 trueValue, bool2 test) { return new int2(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y); }
4164
4165 /// <summary>
4166 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4167 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4168 /// </summary>
4169 /// <param name="falseValue">Values to use if test is false.</param>
4170 /// <param name="trueValue">Values to use if test is true.</param>
4171 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4172 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4173 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4174 public static int3 select(int3 falseValue, int3 trueValue, bool3 test) { return new int3(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y, test.z ? trueValue.z : falseValue.z); }
4175
4176 /// <summary>
4177 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4178 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4179 /// </summary>
4180 /// <param name="falseValue">Values to use if test is false.</param>
4181 /// <param name="trueValue">Values to use if test is true.</param>
4182 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4183 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4184 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4185 public static int4 select(int4 falseValue, int4 trueValue, bool4 test) { return new int4(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y, test.z ? trueValue.z : falseValue.z, test.w ? trueValue.w : falseValue.w); }
4186
4187
4188 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4189 /// <param name="falseValue">Value to use if test is false.</param>
4190 /// <param name="trueValue">Value to use if test is true.</param>
4191 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4192 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4193 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4194 public static uint select(uint falseValue, uint trueValue, bool test) { return test ? trueValue : falseValue; }
4195
4196 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4197 /// <param name="falseValue">Value to use if test is false.</param>
4198 /// <param name="trueValue">Value to use if test is true.</param>
4199 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4200 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4201 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4202 public static uint2 select(uint2 falseValue, uint2 trueValue, bool test) { return test ? trueValue : falseValue; }
4203
4204 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4205 /// <param name="falseValue">Value to use if test is false.</param>
4206 /// <param name="trueValue">Value to use if test is true.</param>
4207 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4208 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4209 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4210 public static uint3 select(uint3 falseValue, uint3 trueValue, bool test) { return test ? trueValue : falseValue; }
4211
4212 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4213 /// <param name="falseValue">Value to use if test is false.</param>
4214 /// <param name="trueValue">Value to use if test is true.</param>
4215 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4216 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4217 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4218 public static uint4 select(uint4 falseValue, uint4 trueValue, bool test) { return test ? trueValue : falseValue; }
4219
4220
4221 /// <summary>
4222 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4223 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4224 /// </summary>
4225 /// <param name="falseValue">Values to use if test is false.</param>
4226 /// <param name="trueValue">Values to use if test is true.</param>
4227 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4228 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4229 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4230 public static uint2 select(uint2 falseValue, uint2 trueValue, bool2 test) { return new uint2(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y); }
4231
4232 /// <summary>
4233 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4234 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4235 /// </summary>
4236 /// <param name="falseValue">Values to use if test is false.</param>
4237 /// <param name="trueValue">Values to use if test is true.</param>
4238 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4239 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4240 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4241 public static uint3 select(uint3 falseValue, uint3 trueValue, bool3 test) { return new uint3(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y, test.z ? trueValue.z : falseValue.z); }
4242
4243 /// <summary>
4244 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4245 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4246 /// </summary>
4247 /// <param name="falseValue">Values to use if test is false.</param>
4248 /// <param name="trueValue">Values to use if test is true.</param>
4249 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4250 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4251 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4252 public static uint4 select(uint4 falseValue, uint4 trueValue, bool4 test) { return new uint4(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y, test.z ? trueValue.z : falseValue.z, test.w ? trueValue.w : falseValue.w); }
4253
4254
4255 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4256 /// <param name="falseValue">Value to use if test is false.</param>
4257 /// <param name="trueValue">Value to use if test is true.</param>
4258 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4259 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4260 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4261 public static long select(long falseValue, long trueValue, bool test) { return test ? trueValue : falseValue; }
4262
4263 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4264 /// <param name="falseValue">Value to use if test is false.</param>
4265 /// <param name="trueValue">Value to use if test is true.</param>
4266 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4267 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4268 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4269 public static ulong select(ulong falseValue, ulong trueValue, bool test) { return test ? trueValue : falseValue; }
4270
4271
4272 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4273 /// <param name="falseValue">Value to use if test is false.</param>
4274 /// <param name="trueValue">Value to use if test is true.</param>
4275 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4276 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4277 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4278 public static float select(float falseValue, float trueValue, bool test) { return test ? trueValue : falseValue; }
4279
4280 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4281 /// <param name="falseValue">Value to use if test is false.</param>
4282 /// <param name="trueValue">Value to use if test is true.</param>
4283 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4284 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4285 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4286 public static float2 select(float2 falseValue, float2 trueValue, bool test) { return test ? trueValue : falseValue; }
4287
4288 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4289 /// <param name="falseValue">Value to use if test is false.</param>
4290 /// <param name="trueValue">Value to use if test is true.</param>
4291 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4292 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4293 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4294 public static float3 select(float3 falseValue, float3 trueValue, bool test) { return test ? trueValue : falseValue; }
4295
4296 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4297 /// <param name="falseValue">Value to use if test is false.</param>
4298 /// <param name="trueValue">Value to use if test is true.</param>
4299 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4300 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4301 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4302 public static float4 select(float4 falseValue, float4 trueValue, bool test) { return test ? trueValue : falseValue; }
4303
4304
4305 /// <summary>
4306 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4307 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4308 /// </summary>
4309 /// <param name="falseValue">Values to use if test is false.</param>
4310 /// <param name="trueValue">Values to use if test is true.</param>
4311 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4312 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4313 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4314 public static float2 select(float2 falseValue, float2 trueValue, bool2 test) { return new float2(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y); }
4315
4316 /// <summary>
4317 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4318 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4319 /// </summary>
4320 /// <param name="falseValue">Values to use if test is false.</param>
4321 /// <param name="trueValue">Values to use if test is true.</param>
4322 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4323 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4324 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4325 public static float3 select(float3 falseValue, float3 trueValue, bool3 test) { return new float3(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y, test.z ? trueValue.z : falseValue.z); }
4326
4327 /// <summary>
4328 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4329 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4330 /// </summary>
4331 /// <param name="falseValue">Values to use if test is false.</param>
4332 /// <param name="trueValue">Values to use if test is true.</param>
4333 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4334 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4335 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4336 public static float4 select(float4 falseValue, float4 trueValue, bool4 test) { return new float4(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y, test.z ? trueValue.z : falseValue.z, test.w ? trueValue.w : falseValue.w); }
4337
4338
4339 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4340 /// <param name="falseValue">Value to use if test is false.</param>
4341 /// <param name="trueValue">Value to use if test is true.</param>
4342 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4343 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4344 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4345 public static double select(double falseValue, double trueValue, bool test) { return test ? trueValue : falseValue; }
4346
4347 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4348 /// <param name="falseValue">Value to use if test is false.</param>
4349 /// <param name="trueValue">Value to use if test is true.</param>
4350 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4351 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4352 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4353 public static double2 select(double2 falseValue, double2 trueValue, bool test) { return test ? trueValue : falseValue; }
4354
4355 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4356 /// <param name="falseValue">Value to use if test is false.</param>
4357 /// <param name="trueValue">Value to use if test is true.</param>
4358 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4359 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4360 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4361 public static double3 select(double3 falseValue, double3 trueValue, bool test) { return test ? trueValue : falseValue; }
4362
4363 /// <summary>Returns trueValue if test is true, falseValue otherwise.</summary>
4364 /// <param name="falseValue">Value to use if test is false.</param>
4365 /// <param name="trueValue">Value to use if test is true.</param>
4366 /// <param name="test">Bool value to choose between falseValue and trueValue.</param>
4367 /// <returns>The selection between falseValue and trueValue according to bool test.</returns>
4368 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4369 public static double4 select(double4 falseValue, double4 trueValue, bool test) { return test ? trueValue : falseValue; }
4370
4371 /// <summary>
4372 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4373 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4374 /// </summary>
4375 /// <param name="falseValue">Values to use if test is false.</param>
4376 /// <param name="trueValue">Values to use if test is true.</param>
4377 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4378 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4379 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4380 public static double2 select(double2 falseValue, double2 trueValue, bool2 test) { return new double2(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y); }
4381
4382 /// <summary>
4383 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4384 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4385 /// </summary>
4386 /// <param name="falseValue">Values to use if test is false.</param>
4387 /// <param name="trueValue">Values to use if test is true.</param>
4388 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4389 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4390 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4391 public static double3 select(double3 falseValue, double3 trueValue, bool3 test) { return new double3(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y, test.z ? trueValue.z : falseValue.z); }
4392
4393 /// <summary>
4394 /// Returns a componentwise selection between two double4 vectors falseValue and trueValue based on a bool4 selection mask test.
4395 /// Per component, the component from trueValue is selected when test is true, otherwise the component from falseValue is selected.
4396 /// </summary>
4397 /// <param name="falseValue">Values to use if test is false.</param>
4398 /// <param name="trueValue">Values to use if test is true.</param>
4399 /// <param name="test">Selection mask to choose between falseValue and trueValue.</param>
4400 /// <returns>The componentwise selection between falseValue and trueValue according to selection mask test.</returns>
4401 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4402 public static double4 select(double4 falseValue, double4 trueValue, bool4 test) { return new double4(test.x ? trueValue.x : falseValue.x, test.y ? trueValue.y : falseValue.y, test.z ? trueValue.z : falseValue.z, test.w ? trueValue.w : falseValue.w); }
4403
4404
4405 /// <summary>Returns the result of a step function where the result is 1.0f when x >= threshold and 0.0f otherwise.</summary>
4406 /// <param name="threshold">Value to be used as a threshold for returning 1.</param>
4407 /// <param name="x">Value to compare against threshold.</param>
4408 /// <returns>1 if the comparison x >= threshold is true, otherwise 0.</returns>
4409 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4410 public static float step(float threshold, float x) { return select(0.0f, 1.0f, x >= threshold); }
4411
4412 /// <summary>Returns the result of a componentwise step function where each component is 1.0f when x >= threshold and 0.0f otherwise.</summary>
4413 /// <param name="threshold">Vector of values to be used as a threshold for returning 1.</param>
4414 /// <param name="x">Vector of values to compare against threshold.</param>
4415 /// <returns>1 if the componentwise comparison x >= threshold is true, otherwise 0.</returns>
4416 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4417 public static float2 step(float2 threshold, float2 x) { return select(float2(0.0f), float2(1.0f), x >= threshold); }
4418
4419 /// <summary>Returns the result of a componentwise step function where each component is 1.0f when x >= threshold and 0.0f otherwise.</summary>
4420 /// <param name="threshold">Vector of values to be used as a threshold for returning 1.</param>
4421 /// <param name="x">Vector of values to compare against threshold.</param>
4422 /// <returns>1 if the componentwise comparison x >= threshold is true, otherwise 0.</returns>
4423 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4424 public static float3 step(float3 threshold, float3 x) { return select(float3(0.0f), float3(1.0f), x >= threshold); }
4425
4426 /// <summary>Returns the result of a componentwise step function where each component is 1.0f when x >= threshold and 0.0f otherwise.</summary>
4427 /// <param name="threshold">Vector of values to be used as a threshold for returning 1.</param>
4428 /// <param name="x">Vector of values to compare against threshold.</param>
4429 /// <returns>1 if the componentwise comparison x >= threshold is true, otherwise 0.</returns>
4430 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4431 public static float4 step(float4 threshold, float4 x) { return select(float4(0.0f), float4(1.0f), x >= threshold); }
4432
4433
4434 /// <summary>Returns the result of a step function where the result is 1.0f when x >= threshold and 0.0f otherwise.</summary>
4435 /// <param name="threshold">Values to be used as a threshold for returning 1.</param>
4436 /// <param name="x">Value to compare against threshold.</param>
4437 /// <returns>1 if the comparison x >= threshold is true, otherwise 0.</returns>
4438 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4439 public static double step(double threshold, double x) { return select(0.0, 1.0, x >= threshold); }
4440
4441 /// <summary>Returns the result of a componentwise step function where each component is 1.0f when x >= threshold and 0.0f otherwise.</summary>
4442 /// <param name="threshold">Vector of values to be used as a threshold for returning 1.</param>
4443 /// <param name="x">Vector of values to compare against threshold.</param>
4444 /// <returns>1 if the componentwise comparison x >= threshold is true, otherwise 0.</returns>
4445 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4446 public static double2 step(double2 threshold, double2 x) { return select(double2(0.0), double2(1.0), x >= threshold); }
4447
4448 /// <summary>Returns the result of a componentwise step function where each component is 1.0f when x >= threshold and 0.0f otherwise.</summary>
4449 /// <param name="threshold">Vector of values to be used as a threshold for returning 1.</param>
4450 /// <param name="x">Vector of values to compare against threshold.</param>
4451 /// <returns>1 if the componentwise comparison x >= threshold is true, otherwise 0.</returns>
4452 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4453 public static double3 step(double3 threshold, double3 x) { return select(double3(0.0), double3(1.0), x >= threshold); }
4454
4455 /// <summary>Returns the result of a componentwise step function where each component is 1.0f when x >= threshold and 0.0f otherwise.</summary>
4456 /// <param name="threshold">Vector of values to be used as a threshold for returning 1.</param>
4457 /// <param name="x">Vector of values to compare against threshold.</param>
4458 /// <returns>1 if the componentwise comparison x >= threshold is true, otherwise 0.</returns>
4459 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4460 public static double4 step(double4 threshold, double4 x) { return select(double4(0.0), double4(1.0), x >= threshold); }
4461
4462
4463 /// <summary>Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2.0f * dot(i, n) * n.</summary>
4464 /// <param name="i">Incident vector.</param>
4465 /// <param name="n">Normal vector.</param>
4466 /// <returns>Reflection vector.</returns>
4467 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4468 public static float2 reflect(float2 i, float2 n) { return i - 2f * n * dot(i, n); }
4469
4470 /// <summary>Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2.0f * dot(i, n) * n.</summary>
4471 /// <param name="i">Incident vector.</param>
4472 /// <param name="n">Normal vector.</param>
4473 /// <returns>Reflection vector.</returns>
4474 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4475 public static float3 reflect(float3 i, float3 n) { return i - 2f * n * dot(i, n); }
4476
4477 /// <summary>Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2.0f * dot(i, n) * n.</summary>
4478 /// <param name="i">Incident vector.</param>
4479 /// <param name="n">Normal vector.</param>
4480 /// <returns>Reflection vector.</returns>
4481 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4482 public static float4 reflect(float4 i, float4 n) { return i - 2f * n * dot(i, n); }
4483
4484
4485 /// <summary>Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2.0 * dot(i, n) * n.</summary>
4486 /// <param name="i">Incident vector.</param>
4487 /// <param name="n">Normal vector.</param>
4488 /// <returns>Reflection vector.</returns>
4489 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4490 public static double2 reflect(double2 i, double2 n) { return i - 2 * n * dot(i, n); }
4491
4492 /// <summary>Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2.0 * dot(i, n) * n.</summary>
4493 /// <param name="i">Incident vector.</param>
4494 /// <param name="n">Normal vector.</param>
4495 /// <returns>Reflection vector.</returns>
4496 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4497 public static double3 reflect(double3 i, double3 n) { return i - 2 * n * dot(i, n); }
4498
4499 /// <summary>Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2.0 * dot(i, n) * n.</summary>
4500 /// <param name="i">Incident vector.</param>
4501 /// <param name="n">Normal vector.</param>
4502 /// <returns>Reflection vector.</returns>
4503 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4504 public static double4 reflect(double4 i, double4 n) { return i - 2 * n * dot(i, n); }
4505
4506
4507 /// <summary>Returns the refraction vector given the incident vector i, the normal vector n and the refraction index.</summary>
4508 /// <param name="i">Incident vector.</param>
4509 /// <param name="n">Normal vector.</param>
4510 /// <param name="indexOfRefraction">Index of refraction.</param>
4511 /// <returns>Refraction vector.</returns>
4512 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4513 public static float2 refract(float2 i, float2 n, float indexOfRefraction)
4514 {
4515 float ni = dot(n, i);
4516 float k = 1.0f - indexOfRefraction * indexOfRefraction * (1.0f - ni * ni);
4517 return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
4518 }
4519
4520 /// <summary>Returns the refraction vector given the incident vector i, the normal vector n and the refraction index.</summary>
4521 /// <param name="i">Incident vector.</param>
4522 /// <param name="n">Normal vector.</param>
4523 /// <param name="indexOfRefraction">Index of refraction.</param>
4524 /// <returns>Refraction vector.</returns>
4525 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4526 public static float3 refract(float3 i, float3 n, float indexOfRefraction)
4527 {
4528 float ni = dot(n, i);
4529 float k = 1.0f - indexOfRefraction * indexOfRefraction * (1.0f - ni * ni);
4530 return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
4531 }
4532
4533 /// <summary>Returns the refraction vector given the incident vector i, the normal vector n and the refraction index.</summary>
4534 /// <param name="i">Incident vector.</param>
4535 /// <param name="n">Normal vector.</param>
4536 /// <param name="indexOfRefraction">Index of refraction.</param>
4537 /// <returns>Refraction vector.</returns>
4538 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4539 public static float4 refract(float4 i, float4 n, float indexOfRefraction)
4540 {
4541 float ni = dot(n, i);
4542 float k = 1.0f - indexOfRefraction * indexOfRefraction * (1.0f - ni * ni);
4543 return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
4544 }
4545
4546
4547 /// <summary>Returns the refraction vector given the incident vector i, the normal vector n and the refraction index.</summary>
4548 /// <param name="i">Incident vector.</param>
4549 /// <param name="n">Normal vector.</param>
4550 /// <param name="indexOfRefraction">Index of refraction.</param>
4551 /// <returns>Refraction vector.</returns>
4552 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4553 public static double2 refract(double2 i, double2 n, double indexOfRefraction)
4554 {
4555 double ni = dot(n, i);
4556 double k = 1.0 - indexOfRefraction * indexOfRefraction * (1.0 - ni * ni);
4557 return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
4558 }
4559
4560 /// <summary>Returns the refraction vector given the incident vector i, the normal vector n and the refraction index.</summary>
4561 /// <param name="i">Incident vector.</param>
4562 /// <param name="n">Normal vector.</param>
4563 /// <param name="indexOfRefraction">Index of refraction.</param>
4564 /// <returns>Refraction vector.</returns>
4565 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4566 public static double3 refract(double3 i, double3 n, double indexOfRefraction)
4567 {
4568 double ni = dot(n, i);
4569 double k = 1.0 - indexOfRefraction * indexOfRefraction * (1.0 - ni * ni);
4570 return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
4571 }
4572
4573 /// <summary>Returns the refraction vector given the incident vector i, the normal vector n and the refraction index.</summary>
4574 /// <param name="i">Incident vector.</param>
4575 /// <param name="n">Normal vector.</param>
4576 /// <param name="indexOfRefraction">Index of refraction.</param>
4577 /// <returns>Refraction vector.</returns>
4578 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4579 public static double4 refract(double4 i, double4 n, double indexOfRefraction)
4580 {
4581 double ni = dot(n, i);
4582 double k = 1.0 - indexOfRefraction * indexOfRefraction * (1.0 - ni * ni);
4583 return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
4584 }
4585
4586 /// <summary>
4587 /// Compute vector projection of a onto b.
4588 /// </summary>
4589 /// <remarks>
4590 /// Some finite vectors a and b could generate a non-finite result. This is most likely when a's components
4591 /// are very large (close to Single.MaxValue) or when b's components are very small (close to FLT_MIN_NORMAL).
4592 /// In these cases, you can call <see cref="projectsafe(Unity.Mathematics.float2,Unity.Mathematics.float2,Unity.Mathematics.float2)"/>
4593 /// which will use a given default value if the result is not finite.
4594 /// </remarks>
4595 /// <param name="a">Vector to project.</param>
4596 /// <param name="ontoB">Non-zero vector to project onto.</param>
4597 /// <returns>Vector projection of a onto b.</returns>
4598 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4599 public static float2 project(float2 a, float2 ontoB)
4600 {
4601 return (dot(a, ontoB) / dot(ontoB, ontoB)) * ontoB;
4602 }
4603
4604 /// <summary>
4605 /// Compute vector projection of a onto b.
4606 /// </summary>
4607 /// <remarks>
4608 /// Some finite vectors a and b could generate a non-finite result. This is most likely when a's components
4609 /// are very large (close to Single.MaxValue) or when b's components are very small (close to FLT_MIN_NORMAL).
4610 /// In these cases, you can call <see cref="projectsafe(Unity.Mathematics.float3,Unity.Mathematics.float3,Unity.Mathematics.float3)"/>
4611 /// which will use a given default value if the result is not finite.
4612 /// </remarks>
4613 /// <param name="a">Vector to project.</param>
4614 /// <param name="ontoB">Non-zero vector to project onto.</param>
4615 /// <returns>Vector projection of a onto b.</returns>
4616 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4617 public static float3 project(float3 a, float3 ontoB)
4618 {
4619 return (dot(a, ontoB) / dot(ontoB, ontoB)) * ontoB;
4620 }
4621
4622 /// <summary>
4623 /// Compute vector projection of a onto b.
4624 /// </summary>
4625 /// <remarks>
4626 /// Some finite vectors a and b could generate a non-finite result. This is most likely when a's components
4627 /// are very large (close to Single.MaxValue) or when b's components are very small (close to FLT_MIN_NORMAL).
4628 /// In these cases, you can call <see cref="projectsafe(Unity.Mathematics.float4,Unity.Mathematics.float4,Unity.Mathematics.float4)"/>
4629 /// which will use a given default value if the result is not finite.
4630 /// </remarks>
4631 /// <param name="a">Vector to project.</param>
4632 /// <param name="ontoB">Non-zero vector to project onto.</param>
4633 /// <returns>Vector projection of a onto b.</returns>
4634 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4635 public static float4 project(float4 a, float4 ontoB)
4636 {
4637 return (dot(a, ontoB) / dot(ontoB, ontoB)) * ontoB;
4638 }
4639
4640 /// <summary>
4641 /// Compute vector projection of a onto b. If result is not finite, then return the default value instead.
4642 /// </summary>
4643 /// <remarks>
4644 /// This function performs extra checks to see if the result of projecting a onto b is finite. If you know that
4645 /// your inputs will generate a finite result or you don't care if the result is finite, then you can call
4646 /// <see cref="project(Unity.Mathematics.float2,Unity.Mathematics.float2)"/> instead which is faster than this
4647 /// function.
4648 /// </remarks>
4649 /// <param name="a">Vector to project.</param>
4650 /// <param name="ontoB">Non-zero vector to project onto.</param>
4651 /// <param name="defaultValue">Default value to return if projection is not finite.</param>
4652 /// <returns>Vector projection of a onto b or the default value.</returns>
4653 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4654 public static float2 projectsafe(float2 a, float2 ontoB, float2 defaultValue = new float2())
4655 {
4656 var proj = project(a, ontoB);
4657
4658 return select(defaultValue, proj, all(isfinite(proj)));
4659 }
4660
4661 /// <summary>
4662 /// Compute vector projection of a onto b. If result is not finite, then return the default value instead.
4663 /// </summary>
4664 /// <remarks>
4665 /// This function performs extra checks to see if the result of projecting a onto b is finite. If you know that
4666 /// your inputs will generate a finite result or you don't care if the result is finite, then you can call
4667 /// <see cref="project(Unity.Mathematics.float3,Unity.Mathematics.float3)"/> instead which is faster than this
4668 /// function.
4669 /// </remarks>
4670 /// <param name="a">Vector to project.</param>
4671 /// <param name="ontoB">Non-zero vector to project onto.</param>
4672 /// <param name="defaultValue">Default value to return if projection is not finite.</param>
4673 /// <returns>Vector projection of a onto b or the default value.</returns>
4674 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4675 public static float3 projectsafe(float3 a, float3 ontoB, float3 defaultValue = new float3())
4676 {
4677 var proj = project(a, ontoB);
4678
4679 return select(defaultValue, proj, all(isfinite(proj)));
4680 }
4681
4682 /// <summary>
4683 /// Compute vector projection of a onto b. If result is not finite, then return the default value instead.
4684 /// </summary>
4685 /// <remarks>
4686 /// This function performs extra checks to see if the result of projecting a onto b is finite. If you know that
4687 /// your inputs will generate a finite result or you don't care if the result is finite, then you can call
4688 /// <see cref="project(Unity.Mathematics.float4,Unity.Mathematics.float4)"/> instead which is faster than this
4689 /// function.
4690 /// </remarks>
4691 /// <param name="a">Vector to project.</param>
4692 /// <param name="ontoB">Non-zero vector to project onto.</param>
4693 /// <param name="defaultValue">Default value to return if projection is not finite.</param>
4694 /// <returns>Vector projection of a onto b or the default value.</returns>
4695 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4696 public static float4 projectsafe(float4 a, float4 ontoB, float4 defaultValue = new float4())
4697 {
4698 var proj = project(a, ontoB);
4699
4700 return select(defaultValue, proj, all(isfinite(proj)));
4701 }
4702
4703 /// <summary>
4704 /// Compute vector projection of a onto b.
4705 /// </summary>
4706 /// <remarks>
4707 /// Some finite vectors a and b could generate a non-finite result. This is most likely when a's components
4708 /// are very large (close to Double.MaxValue) or when b's components are very small (close to DBL_MIN_NORMAL).
4709 /// In these cases, you can call <see cref="projectsafe(Unity.Mathematics.double2,Unity.Mathematics.double2,Unity.Mathematics.double2)"/>
4710 /// which will use a given default value if the result is not finite.
4711 /// </remarks>
4712 /// <param name="a">Vector to project.</param>
4713 /// <param name="ontoB">Non-zero vector to project onto.</param>
4714 /// <returns>Vector projection of a onto b.</returns>
4715 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4716 public static double2 project(double2 a, double2 ontoB)
4717 {
4718 return (dot(a, ontoB) / dot(ontoB, ontoB)) * ontoB;
4719 }
4720
4721 /// <summary>
4722 /// Compute vector projection of a onto b.
4723 /// </summary>
4724 /// <remarks>
4725 /// Some finite vectors a and b could generate a non-finite result. This is most likely when a's components
4726 /// are very large (close to Double.MaxValue) or when b's components are very small (close to DBL_MIN_NORMAL).
4727 /// In these cases, you can call <see cref="projectsafe(Unity.Mathematics.double3,Unity.Mathematics.double3,Unity.Mathematics.double3)"/>
4728 /// which will use a given default value if the result is not finite.
4729 /// </remarks>
4730 /// <param name="a">Vector to project.</param>
4731 /// <param name="ontoB">Non-zero vector to project onto.</param>
4732 /// <returns>Vector projection of a onto b.</returns>
4733 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4734 public static double3 project(double3 a, double3 ontoB)
4735 {
4736 return (dot(a, ontoB) / dot(ontoB, ontoB)) * ontoB;
4737 }
4738
4739 /// <summary>
4740 /// Compute vector projection of a onto b.
4741 /// </summary>
4742 /// <remarks>
4743 /// Some finite vectors a and b could generate a non-finite result. This is most likely when a's components
4744 /// are very large (close to Double.MaxValue) or when b's components are very small (close to DBL_MIN_NORMAL).
4745 /// In these cases, you can call <see cref="projectsafe(Unity.Mathematics.double4,Unity.Mathematics.double4,Unity.Mathematics.double4)"/>
4746 /// which will use a given default value if the result is not finite.
4747 /// </remarks>
4748 /// <param name="a">Vector to project.</param>
4749 /// <param name="ontoB">Non-zero vector to project onto.</param>
4750 /// <returns>Vector projection of a onto b.</returns>
4751 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4752 public static double4 project(double4 a, double4 ontoB)
4753 {
4754 return (dot(a, ontoB) / dot(ontoB, ontoB)) * ontoB;
4755 }
4756
4757 /// <summary>
4758 /// Compute vector projection of a onto b. If result is not finite, then return the default value instead.
4759 /// </summary>
4760 /// <remarks>
4761 /// This function performs extra checks to see if the result of projecting a onto b is finite. If you know that
4762 /// your inputs will generate a finite result or you don't care if the result is finite, then you can call
4763 /// <see cref="project(Unity.Mathematics.double2,Unity.Mathematics.double2)"/> instead which is faster than this
4764 /// function.
4765 /// </remarks>
4766 /// <param name="a">Vector to project.</param>
4767 /// <param name="ontoB">Non-zero vector to project onto.</param>
4768 /// <param name="defaultValue">Default value to return if projection is not finite.</param>
4769 /// <returns>Vector projection of a onto b or the default value.</returns>
4770 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4771 public static double2 projectsafe(double2 a, double2 ontoB, double2 defaultValue = new double2())
4772 {
4773 var proj = project(a, ontoB);
4774
4775 return select(defaultValue, proj, all(isfinite(proj)));
4776 }
4777
4778 /// <summary>
4779 /// Compute vector projection of a onto b. If result is not finite, then return the default value instead.
4780 /// </summary>
4781 /// <remarks>
4782 /// This function performs extra checks to see if the result of projecting a onto b is finite. If you know that
4783 /// your inputs will generate a finite result or you don't care if the result is finite, then you can call
4784 /// <see cref="project(Unity.Mathematics.double3,Unity.Mathematics.double3)"/> instead which is faster than this
4785 /// function.
4786 /// </remarks>
4787 /// <param name="a">Vector to project.</param>
4788 /// <param name="ontoB">Non-zero vector to project onto.</param>
4789 /// <param name="defaultValue">Default value to return if projection is not finite.</param>
4790 /// <returns>Vector projection of a onto b or the default value.</returns>
4791 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4792 public static double3 projectsafe(double3 a, double3 ontoB, double3 defaultValue = new double3())
4793 {
4794 var proj = project(a, ontoB);
4795
4796 return select(defaultValue, proj, all(isfinite(proj)));
4797 }
4798
4799 /// <summary>
4800 /// Compute vector projection of a onto b. If result is not finite, then return the default value instead.
4801 /// </summary>
4802 /// <remarks>
4803 /// This function performs extra checks to see if the result of projecting a onto b is finite. If you know that
4804 /// your inputs will generate a finite result or you don't care if the result is finite, then you can call
4805 /// <see cref="project(Unity.Mathematics.double4,Unity.Mathematics.double4)"/> instead which is faster than this
4806 /// function.
4807 /// </remarks>
4808 /// <param name="a">Vector to project.</param>
4809 /// <param name="ontoB">Non-zero vector to project onto.</param>
4810 /// <param name="defaultValue">Default value to return if projection is not finite.</param>
4811 /// <returns>Vector projection of a onto b or the default value.</returns>
4812 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4813 public static double4 projectsafe(double4 a, double4 ontoB, double4 defaultValue = new double4())
4814 {
4815 var proj = project(a, ontoB);
4816
4817 return select(defaultValue, proj, all(isfinite(proj)));
4818 }
4819
4820 /// <summary>Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) < 0, -n otherwise.</summary>
4821 /// <param name="n">Vector to conditionally flip.</param>
4822 /// <param name="i">First vector in direction comparison.</param>
4823 /// <param name="ng">Second vector in direction comparison.</param>
4824 /// <returns>-n if i and ng point in the same direction; otherwise return n unchanged.</returns>
4825 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4826 public static float2 faceforward(float2 n, float2 i, float2 ng) { return select(n, -n, dot(ng, i) >= 0.0f); }
4827
4828 /// <summary>Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) < 0, -n otherwise.</summary>
4829 /// <param name="n">Vector to conditionally flip.</param>
4830 /// <param name="i">First vector in direction comparison.</param>
4831 /// <param name="ng">Second vector in direction comparison.</param>
4832 /// <returns>-n if i and ng point in the same direction; otherwise return n unchanged.</returns>
4833 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4834 public static float3 faceforward(float3 n, float3 i, float3 ng) { return select(n, -n, dot(ng, i) >= 0.0f); }
4835
4836 /// <summary>Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) < 0, -n otherwise.</summary>
4837 /// <param name="n">Vector to conditionally flip.</param>
4838 /// <param name="i">First vector in direction comparison.</param>
4839 /// <param name="ng">Second vector in direction comparison.</param>
4840 /// <returns>-n if i and ng point in the same direction; otherwise return n unchanged.</returns>
4841 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4842 public static float4 faceforward(float4 n, float4 i, float4 ng) { return select(n, -n, dot(ng, i) >= 0.0f); }
4843
4844
4845 /// <summary>Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) < 0, -n otherwise.</summary>
4846 /// <param name="n">Vector to conditionally flip.</param>
4847 /// <param name="i">First vector in direction comparison.</param>
4848 /// <param name="ng">Second vector in direction comparison.</param>
4849 /// <returns>-n if i and ng point in the same direction; otherwise return n unchanged.</returns>
4850 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4851 public static double2 faceforward(double2 n, double2 i, double2 ng) { return select(n, -n, dot(ng, i) >= 0.0f); }
4852
4853 /// <summary>Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) < 0, -n otherwise.</summary>
4854 /// <param name="n">Vector to conditionally flip.</param>
4855 /// <param name="i">First vector in direction comparison.</param>
4856 /// <param name="ng">Second vector in direction comparison.</param>
4857 /// <returns>-n if i and ng point in the same direction; otherwise return n unchanged.</returns>
4858 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4859 public static double3 faceforward(double3 n, double3 i, double3 ng) { return select(n, -n, dot(ng, i) >= 0.0f); }
4860
4861 /// <summary>Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) < 0, -n otherwise.</summary>
4862 /// <param name="n">Vector to conditionally flip.</param>
4863 /// <param name="i">First vector in direction comparison.</param>
4864 /// <param name="ng">Second vector in direction comparison.</param>
4865 /// <returns>-n if i and ng point in the same direction; otherwise return n unchanged.</returns>
4866 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4867 public static double4 faceforward(double4 n, double4 i, double4 ng) { return select(n, -n, dot(ng, i) >= 0.0f); }
4868
4869
4870 /// <summary>Returns the sine and cosine of the input float value x through the out parameters s and c.</summary>
4871 /// <remarks>When Burst compiled, his method is faster than calling sin() and cos() separately.</remarks>
4872 /// <param name="x">Input angle in radians.</param>
4873 /// <param name="s">Output sine of the input.</param>
4874 /// <param name="c">Output cosine of the input.</param>
4875 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4876 public static void sincos(float x, out float s, out float c) { s = sin(x); c = cos(x); }
4877
4878 /// <summary>Returns the componentwise sine and cosine of the input float2 vector x through the out parameters s and c.</summary>
4879 /// <remarks>When Burst compiled, his method is faster than calling sin() and cos() separately.</remarks>
4880 /// <param name="x">Input vector containing angles in radians.</param>
4881 /// <param name="s">Output vector containing the componentwise sine of the input.</param>
4882 /// <param name="c">Output vector containing the componentwise cosine of the input.</param>
4883 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4884 public static void sincos(float2 x, out float2 s, out float2 c) { s = sin(x); c = cos(x); }
4885
4886 /// <summary>Returns the componentwise sine and cosine of the input float3 vector x through the out parameters s and c.</summary>
4887 /// <remarks>When Burst compiled, his method is faster than calling sin() and cos() separately.</remarks>
4888 /// <param name="x">Input vector containing angles in radians.</param>
4889 /// <param name="s">Output vector containing the componentwise sine of the input.</param>
4890 /// <param name="c">Output vector containing the componentwise cosine of the input.</param>
4891 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4892 public static void sincos(float3 x, out float3 s, out float3 c) { s = sin(x); c = cos(x); }
4893
4894 /// <summary>Returns the componentwise sine and cosine of the input float4 vector x through the out parameters s and c.</summary>
4895 /// <remarks>When Burst compiled, his method is faster than calling sin() and cos() separately.</remarks>
4896 /// <param name="x">Input vector containing angles in radians.</param>
4897 /// <param name="s">Output vector containing the componentwise sine of the input.</param>
4898 /// <param name="c">Output vector containing the componentwise cosine of the input.</param>
4899 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4900 public static void sincos(float4 x, out float4 s, out float4 c) { s = sin(x); c = cos(x); }
4901
4902
4903 /// <summary>Returns the sine and cosine of the input double value x through the out parameters s and c.</summary>
4904 /// <remarks>When Burst compiled, his method is faster than calling sin() and cos() separately.</remarks>
4905 /// <param name="x">Input angle in radians.</param>
4906 /// <param name="s">Output sine of the input.</param>
4907 /// <param name="c">Output cosine of the input.</param>
4908 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4909 public static void sincos(double x, out double s, out double c) { s = sin(x); c = cos(x); }
4910
4911 /// <summary>Returns the componentwise sine and cosine of the input double2 vector x through the out parameters s and c.</summary>
4912 /// <remarks>When Burst compiled, his method is faster than calling sin() and cos() separately.</remarks>
4913 /// <param name="x">Input vector containing angles in radians.</param>
4914 /// <param name="s">Output vector containing the componentwise sine of the input.</param>
4915 /// <param name="c">Output vector containing the componentwise cosine of the input.</param>
4916 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4917 public static void sincos(double2 x, out double2 s, out double2 c) { s = sin(x); c = cos(x); }
4918
4919 /// <summary>Returns the componentwise sine and cosine of the input double3 vector x through the out parameters s and c.</summary>
4920 /// <remarks>When Burst compiled, his method is faster than calling sin() and cos() separately.</remarks>
4921 /// <param name="x">Input vector containing angles in radians.</param>
4922 /// <param name="s">Output vector containing the componentwise sine of the input.</param>
4923 /// <param name="c">Output vector containing the componentwise cosine of the input.</param>
4924 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4925 public static void sincos(double3 x, out double3 s, out double3 c) { s = sin(x); c = cos(x); }
4926
4927 /// <summary>Returns the componentwise sine and cosine of the input double4 vector x through the out parameters s and c.</summary>
4928 /// <remarks>When Burst compiled, his method is faster than calling sin() and cos() separately.</remarks>
4929 /// <param name="x">Input vector containing angles in radians.</param>
4930 /// <param name="s">Output vector containing the componentwise sine of the input.</param>
4931 /// <param name="c">Output vector containing the componentwise cosine of the input.</param>
4932 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4933 public static void sincos(double4 x, out double4 s, out double4 c) { s = sin(x); c = cos(x); }
4934
4935
4936 /// <summary>Returns number of 1-bits in the binary representation of an int value. Also known as the Hamming weight, popcnt on x86, and vcnt on ARM.</summary>
4937 /// <param name="x">int value in which to count bits set to 1.</param>
4938 /// <returns>Number of bits set to 1 within x.</returns>
4939 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4940 public static int countbits(int x) { return countbits((uint)x); }
4941
4942 /// <summary>Returns component-wise number of 1-bits in the binary representation of an int2 vector. Also known as the Hamming weight, popcnt on x86, and vcnt on ARM.</summary>
4943 /// <param name="x">int2 value in which to count bits for each component.</param>
4944 /// <returns>int2 containing number of bits set to 1 within each component of x.</returns>
4945 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4946 public static int2 countbits(int2 x) { return countbits((uint2)x); }
4947
4948 /// <summary>Returns component-wise number of 1-bits in the binary representation of an int3 vector. Also known as the Hamming weight, popcnt on x86, and vcnt on ARM.</summary>
4949 /// <param name="x">Number in which to count bits.</param>
4950 /// <returns>int3 containing number of bits set to 1 within each component of x.</returns>
4951 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4952 public static int3 countbits(int3 x) { return countbits((uint3)x); }
4953
4954 /// <summary>Returns component-wise number of 1-bits in the binary representation of an int4 vector. Also known as the Hamming weight, popcnt on x86, and vcnt on ARM.</summary>
4955 /// <param name="x">Number in which to count bits.</param>
4956 /// <returns>int4 containing number of bits set to 1 within each component of x.</returns>
4957 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4958 public static int4 countbits(int4 x) { return countbits((uint4)x); }
4959
4960
4961 /// <summary>Returns number of 1-bits in the binary representation of a uint value. Also known as the Hamming weight, popcnt on x86, and vcnt on ARM.</summary>
4962 /// <param name="x">Number in which to count bits.</param>
4963 /// <returns>Number of bits set to 1 within x.</returns>
4964 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4965 public static int countbits(uint x)
4966 {
4967 x = x - ((x >> 1) & 0x55555555);
4968 x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
4969 return (int)((((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24);
4970 }
4971
4972 /// <summary>Returns component-wise number of 1-bits in the binary representation of a uint2 vector. Also known as the Hamming weight, popcnt on x86, and vcnt on ARM.</summary>
4973 /// <param name="x">Number in which to count bits.</param>
4974 /// <returns>int2 containing number of bits set to 1 within each component of x.</returns>
4975 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4976 public static int2 countbits(uint2 x)
4977 {
4978 x = x - ((x >> 1) & 0x55555555);
4979 x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
4980 return int2((((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24);
4981 }
4982
4983 /// <summary>Returns component-wise number of 1-bits in the binary representation of a uint3 vector. Also known as the Hamming weight, popcnt on x86, and vcnt on ARM.</summary>
4984 /// <param name="x">Number in which to count bits.</param>
4985 /// <returns>int3 containing number of bits set to 1 within each component of x.</returns>
4986 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4987 public static int3 countbits(uint3 x)
4988 {
4989 x = x - ((x >> 1) & 0x55555555);
4990 x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
4991 return int3((((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24);
4992 }
4993
4994 /// <summary>Returns component-wise number of 1-bits in the binary representation of a uint4 vector. Also known as the Hamming weight, popcnt on x86, and vcnt on ARM.</summary>
4995 /// <param name="x">Number in which to count bits.</param>
4996 /// <returns>int4 containing number of bits set to 1 within each component of x.</returns>
4997 [MethodImpl(MethodImplOptions.AggressiveInlining)]
4998 public static int4 countbits(uint4 x)
4999 {
5000 x = x - ((x >> 1) & 0x55555555);
5001 x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
5002 return int4((((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24);
5003 }
5004
5005 /// <summary>Returns number of 1-bits in the binary representation of a ulong value. Also known as the Hamming weight, popcnt on x86, and vcnt on ARM.</summary>
5006 /// <param name="x">Number in which to count bits.</param>
5007 /// <returns>Number of bits set to 1 within x.</returns>
5008 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5009 public static int countbits(ulong x)
5010 {
5011 x = x - ((x >> 1) & 0x5555555555555555);
5012 x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333);
5013 return (int)((((x + (x >> 4)) & 0x0F0F0F0F0F0F0F0F) * 0x0101010101010101) >> 56);
5014 }
5015
5016 /// <summary>Returns number of 1-bits in the binary representation of a long value. Also known as the Hamming weight, popcnt on x86, and vcnt on ARM.</summary>
5017 /// <param name="x">Number in which to count bits.</param>
5018 /// <returns>Number of bits set to 1 within x.</returns>
5019 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5020 public static int countbits(long x) { return countbits((ulong)x); }
5021
5022
5023 /// <summary>Returns the componentwise number of leading zeros in the binary representations of an int vector.</summary>
5024 /// <param name="x">Input value.</param>
5025 /// <returns>The number of leading zeros of the input.</returns>
5026 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5027 public static int lzcnt(int x) { return lzcnt((uint)x); }
5028
5029 /// <summary>Returns the componentwise number of leading zeros in the binary representations of an int2 vector.</summary>
5030 /// <param name="x">Input value.</param>
5031 /// <returns>The componentwise number of leading zeros of the input.</returns>
5032 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5033 public static int2 lzcnt(int2 x) { return int2(lzcnt(x.x), lzcnt(x.y)); }
5034
5035 /// <summary>Returns the componentwise number of leading zeros in the binary representations of an int3 vector.</summary>
5036 /// <param name="x">Input value.</param>
5037 /// <returns>The componentwise number of leading zeros of the input.</returns>
5038 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5039 public static int3 lzcnt(int3 x) { return int3(lzcnt(x.x), lzcnt(x.y), lzcnt(x.z)); }
5040
5041 /// <summary>Returns the componentwise number of leading zeros in the binary representations of an int4 vector.</summary>
5042 /// <param name="x">Input value.</param>
5043 /// <returns>The componentwise number of leading zeros of the input.</returns>
5044 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5045 public static int4 lzcnt(int4 x) { return int4(lzcnt(x.x), lzcnt(x.y), lzcnt(x.z), lzcnt(x.w)); }
5046
5047
5048 /// <summary>Returns number of leading zeros in the binary representations of a uint value.</summary>
5049 /// <param name="x">Input value.</param>
5050 /// <returns>The number of leading zeros of the input.</returns>
5051 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5052 public static int lzcnt(uint x)
5053 {
5054 if (x == 0)
5055 return 32;
5056 LongDoubleUnion u;
5057 u.doubleValue = 0.0;
5058 u.longValue = 0x4330000000000000L + x;
5059 u.doubleValue -= 4503599627370496.0;
5060 return 0x41E - (int)(u.longValue >> 52);
5061 }
5062
5063 /// <summary>Returns the componentwise number of leading zeros in the binary representations of a uint2 vector.</summary>
5064 /// <param name="x">Input value.</param>
5065 /// <returns>The componentwise number of leading zeros of the input.</returns>
5066 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5067 public static int2 lzcnt(uint2 x) { return int2(lzcnt(x.x), lzcnt(x.y)); }
5068
5069 /// <summary>Returns the componentwise number of leading zeros in the binary representations of a uint3 vector.</summary>
5070 /// <param name="x">Input value.</param>
5071 /// <returns>The componentwise number of leading zeros of the input.</returns>
5072 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5073 public static int3 lzcnt(uint3 x) { return int3(lzcnt(x.x), lzcnt(x.y), lzcnt(x.z)); }
5074
5075 /// <summary>Returns the componentwise number of leading zeros in the binary representations of a uint4 vector.</summary>
5076 /// <param name="x">Input value.</param>
5077 /// <returns>The componentwise number of leading zeros of the input.</returns>
5078 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5079 public static int4 lzcnt(uint4 x) { return int4(lzcnt(x.x), lzcnt(x.y), lzcnt(x.z), lzcnt(x.w)); }
5080
5081
5082 /// <summary>Returns number of leading zeros in the binary representations of a long value.</summary>
5083 /// <param name="x">Input value.</param>
5084 /// <returns>The number of leading zeros of the input.</returns>
5085 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5086 public static int lzcnt(long x) { return lzcnt((ulong)x); }
5087
5088
5089 /// <summary>Returns number of leading zeros in the binary representations of a ulong value.</summary>
5090 /// <param name="x">Input value.</param>
5091 /// <returns>The number of leading zeros of the input.</returns>
5092 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5093 public static int lzcnt(ulong x)
5094 {
5095 if (x == 0)
5096 return 64;
5097
5098 uint xh = (uint)(x >> 32);
5099 uint bits = xh != 0 ? xh : (uint)x;
5100 int offset = xh != 0 ? 0x41E : 0x43E;
5101
5102 LongDoubleUnion u;
5103 u.doubleValue = 0.0;
5104 u.longValue = 0x4330000000000000L + bits;
5105 u.doubleValue -= 4503599627370496.0;
5106 return offset - (int)(u.longValue >> 52);
5107 }
5108
5109 /// <summary>
5110 /// Computes the trailing zero count in the binary representation of the input value.
5111 /// </summary>
5112 /// <remarks>
5113 /// Assuming that the least significant bit is on the right, the integer value 4 has a binary representation
5114 /// 0100 and the trailing zero count is two. The integer value 1 has a binary representation 0001 and the
5115 /// trailing zero count is zero.
5116 /// </remarks>
5117 /// <param name="x">Input to use when computing the trailing zero count.</param>
5118 /// <returns>Returns the trailing zero count of the input.</returns>
5119 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5120 public static int tzcnt(int x) { return tzcnt((uint)x); }
5121
5122 /// <summary>
5123 /// Computes the component-wise trailing zero count in the binary representation of the input value.
5124 /// </summary>
5125 /// <remarks>
5126 /// Assuming that the least significant bit is on the right, the integer value 4 has a binary representation
5127 /// 0100 and the trailing zero count is two. The integer value 1 has a binary representation 0001 and the
5128 /// trailing zero count is zero.
5129 /// </remarks>
5130 /// <param name="x">Input to use when computing the trailing zero count.</param>
5131 /// <returns>Returns the component-wise trailing zero count of the input.</returns>
5132 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5133 public static int2 tzcnt(int2 x) { return int2(tzcnt(x.x), tzcnt(x.y)); }
5134
5135 /// <summary>
5136 /// Computes the component-wise trailing zero count in the binary representation of the input value.
5137 /// </summary>
5138 /// <remarks>
5139 /// Assuming that the least significant bit is on the right, the integer value 4 has a binary representation
5140 /// 0100 and the trailing zero count is two. The integer value 1 has a binary representation 0001 and the
5141 /// trailing zero count is zero.
5142 /// </remarks>
5143 /// <param name="x">Input to use when computing the trailing zero count.</param>
5144 /// <returns>Returns the component-wise trailing zero count of the input.</returns>
5145 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5146 public static int3 tzcnt(int3 x) { return int3(tzcnt(x.x), tzcnt(x.y), tzcnt(x.z)); }
5147
5148 /// <summary>
5149 /// Computes the component-wise trailing zero count in the binary representation of the input value.
5150 /// </summary>
5151 /// <remarks>
5152 /// Assuming that the least significant bit is on the right, the integer value 4 has a binary representation
5153 /// 0100 and the trailing zero count is two. The integer value 1 has a binary representation 0001 and the
5154 /// trailing zero count is zero.
5155 /// </remarks>
5156 /// <param name="x">Input to use when computing the trailing zero count.</param>
5157 /// <returns>Returns the component-wise trailing zero count of the input.</returns>
5158 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5159 public static int4 tzcnt(int4 x) { return int4(tzcnt(x.x), tzcnt(x.y), tzcnt(x.z), tzcnt(x.w)); }
5160
5161
5162 /// <summary>
5163 /// Computes the trailing zero count in the binary representation of the input value.
5164 /// </summary>
5165 /// <remarks>
5166 /// Assuming that the least significant bit is on the right, the integer value 4 has a binary representation
5167 /// 0100 and the trailing zero count is two. The integer value 1 has a binary representation 0001 and the
5168 /// trailing zero count is zero.
5169 /// </remarks>
5170 /// <param name="x">Input to use when computing the trailing zero count.</param>
5171 /// <returns>Returns the trailing zero count of the input.</returns>
5172 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5173 public static int tzcnt(uint x)
5174 {
5175 if (x == 0)
5176 return 32;
5177
5178 x &= (uint)-x;
5179 LongDoubleUnion u;
5180 u.doubleValue = 0.0;
5181 u.longValue = 0x4330000000000000L + x;
5182 u.doubleValue -= 4503599627370496.0;
5183 return (int)(u.longValue >> 52) - 0x3FF;
5184 }
5185
5186 /// <summary>
5187 /// Computes the component-wise trailing zero count in the binary representation of the input value.
5188 /// </summary>
5189 /// <remarks>
5190 /// Assuming that the least significant bit is on the right, the integer value 4 has a binary representation
5191 /// 0100 and the trailing zero count is two. The integer value 1 has a binary representation 0001 and the
5192 /// trailing zero count is zero.
5193 /// </remarks>
5194 /// <param name="x">Input to use when computing the trailing zero count.</param>
5195 /// <returns>Returns the component-wise trailing zero count of the input.</returns>
5196 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5197 public static int2 tzcnt(uint2 x) { return int2(tzcnt(x.x), tzcnt(x.y)); }
5198
5199 /// <summary>
5200 /// Computes the component-wise trailing zero count in the binary representation of the input value.
5201 /// </summary>
5202 /// <remarks>
5203 /// Assuming that the least significant bit is on the right, the integer value 4 has a binary representation
5204 /// 0100 and the trailing zero count is two. The integer value 1 has a binary representation 0001 and the
5205 /// trailing zero count is zero.
5206 /// </remarks>
5207 /// <param name="x">Input to use when computing the trailing zero count.</param>
5208 /// <returns>Returns the component-wise trailing zero count of the input.</returns>
5209 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5210 public static int3 tzcnt(uint3 x) { return int3(tzcnt(x.x), tzcnt(x.y), tzcnt(x.z)); }
5211
5212 /// <summary>
5213 /// Computes the component-wise trailing zero count in the binary representation of the input value.
5214 /// </summary>
5215 /// <remarks>
5216 /// Assuming that the least significant bit is on the right, the integer value 4 has a binary representation
5217 /// 0100 and the trailing zero count is two. The integer value 1 has a binary representation 0001 and the
5218 /// trailing zero count is zero.
5219 /// </remarks>
5220 /// <param name="x">Input to use when computing the trailing zero count.</param>
5221 /// <returns>Returns the component-wise trailing zero count of the input.</returns>
5222 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5223 public static int4 tzcnt(uint4 x) { return int4(tzcnt(x.x), tzcnt(x.y), tzcnt(x.z), tzcnt(x.w)); }
5224
5225 /// <summary>
5226 /// Computes the trailing zero count in the binary representation of the input value.
5227 /// </summary>
5228 /// <remarks>
5229 /// Assuming that the least significant bit is on the right, the integer value 4 has a binary representation
5230 /// 0100 and the trailing zero count is two. The integer value 1 has a binary representation 0001 and the
5231 /// trailing zero count is zero.
5232 /// </remarks>
5233 /// <param name="x">Input to use when computing the trailing zero count.</param>
5234 /// <returns>Returns the trailing zero count of the input.</returns>
5235 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5236 public static int tzcnt(long x) { return tzcnt((ulong)x); }
5237
5238 /// <summary>
5239 /// Computes the trailing zero count in the binary representation of the input value.
5240 /// </summary>
5241 /// <remarks>
5242 /// Assuming that the least significant bit is on the right, the integer value 4 has a binary representation
5243 /// 0100 and the trailing zero count is two. The integer value 1 has a binary representation 0001 and the
5244 /// trailing zero count is zero.
5245 /// </remarks>
5246 /// <param name="x">Input to use when computing the trailing zero count.</param>
5247 /// <returns>Returns the trailing zero count of the input.</returns>
5248 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5249 public static int tzcnt(ulong x)
5250 {
5251 if (x == 0)
5252 return 64;
5253
5254 x = x & (ulong)-(long)x;
5255 uint xl = (uint)x;
5256
5257 uint bits = xl != 0 ? xl : (uint)(x >> 32);
5258 int offset = xl != 0 ? 0x3FF : 0x3DF;
5259
5260 LongDoubleUnion u;
5261 u.doubleValue = 0.0;
5262 u.longValue = 0x4330000000000000L + bits;
5263 u.doubleValue -= 4503599627370496.0;
5264 return (int)(u.longValue >> 52) - offset;
5265 }
5266
5267
5268
5269 /// <summary>Returns the result of performing a reversal of the bit pattern of an int value.</summary>
5270 /// <param name="x">Value to reverse.</param>
5271 /// <returns>Value with reversed bits.</returns>
5272 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5273 public static int reversebits(int x) { return (int)reversebits((uint)x); }
5274
5275 /// <summary>Returns the result of performing a componentwise reversal of the bit pattern of an int2 vector.</summary>
5276 /// <param name="x">Value to reverse.</param>
5277 /// <returns>Value with componentwise reversed bits.</returns>
5278 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5279 public static int2 reversebits(int2 x) { return (int2)reversebits((uint2)x); }
5280
5281 /// <summary>Returns the result of performing a componentwise reversal of the bit pattern of an int3 vector.</summary>
5282 /// <param name="x">Value to reverse.</param>
5283 /// <returns>Value with componentwise reversed bits.</returns>
5284 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5285 public static int3 reversebits(int3 x) { return (int3)reversebits((uint3)x); }
5286
5287 /// <summary>Returns the result of performing a componentwise reversal of the bit pattern of an int4 vector.</summary>
5288 /// <param name="x">Value to reverse.</param>
5289 /// <returns>Value with componentwise reversed bits.</returns>
5290 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5291 public static int4 reversebits(int4 x) { return (int4)reversebits((uint4)x); }
5292
5293
5294 /// <summary>Returns the result of performing a reversal of the bit pattern of a uint value.</summary>
5295 /// <param name="x">Value to reverse.</param>
5296 /// <returns>Value with reversed bits.</returns>
5297 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5298 public static uint reversebits(uint x) {
5299 x = ((x >> 1) & 0x55555555) | ((x & 0x55555555) << 1);
5300 x = ((x >> 2) & 0x33333333) | ((x & 0x33333333) << 2);
5301 x = ((x >> 4) & 0x0F0F0F0F) | ((x & 0x0F0F0F0F) << 4);
5302 x = ((x >> 8) & 0x00FF00FF) | ((x & 0x00FF00FF) << 8);
5303 return (x >> 16) | (x << 16);
5304 }
5305
5306 /// <summary>Returns the result of performing a componentwise reversal of the bit pattern of an uint2 vector.</summary>
5307 /// <param name="x">Value to reverse.</param>
5308 /// <returns>Value with componentwise reversed bits.</returns>
5309 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5310 public static uint2 reversebits(uint2 x)
5311 {
5312 x = ((x >> 1) & 0x55555555) | ((x & 0x55555555) << 1);
5313 x = ((x >> 2) & 0x33333333) | ((x & 0x33333333) << 2);
5314 x = ((x >> 4) & 0x0F0F0F0F) | ((x & 0x0F0F0F0F) << 4);
5315 x = ((x >> 8) & 0x00FF00FF) | ((x & 0x00FF00FF) << 8);
5316 return (x >> 16) | (x << 16);
5317 }
5318
5319 /// <summary>Returns the result of performing a componentwise reversal of the bit pattern of an uint3 vector.</summary>
5320 /// <param name="x">Value to reverse.</param>
5321 /// <returns>Value with componentwise reversed bits.</returns>
5322 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5323 public static uint3 reversebits(uint3 x)
5324 {
5325 x = ((x >> 1) & 0x55555555) | ((x & 0x55555555) << 1);
5326 x = ((x >> 2) & 0x33333333) | ((x & 0x33333333) << 2);
5327 x = ((x >> 4) & 0x0F0F0F0F) | ((x & 0x0F0F0F0F) << 4);
5328 x = ((x >> 8) & 0x00FF00FF) | ((x & 0x00FF00FF) << 8);
5329 return (x >> 16) | (x << 16);
5330 }
5331
5332 /// <summary>Returns the result of performing a componentwise reversal of the bit pattern of an uint4 vector.</summary>
5333 /// <param name="x">Value to reverse.</param>
5334 /// <returns>Value with componentwise reversed bits.</returns>
5335 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5336 public static uint4 reversebits(uint4 x)
5337 {
5338 x = ((x >> 1) & 0x55555555) | ((x & 0x55555555) << 1);
5339 x = ((x >> 2) & 0x33333333) | ((x & 0x33333333) << 2);
5340 x = ((x >> 4) & 0x0F0F0F0F) | ((x & 0x0F0F0F0F) << 4);
5341 x = ((x >> 8) & 0x00FF00FF) | ((x & 0x00FF00FF) << 8);
5342 return (x >> 16) | (x << 16);
5343 }
5344
5345
5346 /// <summary>Returns the result of performing a reversal of the bit pattern of a long value.</summary>
5347 /// <param name="x">Value to reverse.</param>
5348 /// <returns>Value with reversed bits.</returns>
5349 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5350 public static long reversebits(long x) { return (long)reversebits((ulong)x); }
5351
5352
5353 /// <summary>Returns the result of performing a reversal of the bit pattern of a ulong value.</summary>
5354 /// <param name="x">Value to reverse.</param>
5355 /// <returns>Value with reversed bits.</returns>
5356 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5357 public static ulong reversebits(ulong x)
5358 {
5359 x = ((x >> 1) & 0x5555555555555555ul) | ((x & 0x5555555555555555ul) << 1);
5360 x = ((x >> 2) & 0x3333333333333333ul) | ((x & 0x3333333333333333ul) << 2);
5361 x = ((x >> 4) & 0x0F0F0F0F0F0F0F0Ful) | ((x & 0x0F0F0F0F0F0F0F0Ful) << 4);
5362 x = ((x >> 8) & 0x00FF00FF00FF00FFul) | ((x & 0x00FF00FF00FF00FFul) << 8);
5363 x = ((x >> 16) & 0x0000FFFF0000FFFFul) | ((x & 0x0000FFFF0000FFFFul) << 16);
5364 return (x >> 32) | (x << 32);
5365 }
5366
5367
5368 /// <summary>Returns the result of rotating the bits of an int left by bits n.</summary>
5369 /// <param name="x">Value to rotate.</param>
5370 /// <param name="n">Number of bits to rotate.</param>
5371 /// <returns>The rotated value.</returns>
5372 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5373 public static int rol(int x, int n) { return (int)rol((uint)x, n); }
5374
5375 /// <summary>Returns the componentwise result of rotating the bits of an int2 left by bits n.</summary>
5376 /// <param name="x">Value to rotate.</param>
5377 /// <param name="n">Number of bits to rotate.</param>
5378 /// <returns>The componentwise rotated value.</returns>
5379 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5380 public static int2 rol(int2 x, int n) { return (int2)rol((uint2)x, n); }
5381
5382 /// <summary>Returns the componentwise result of rotating the bits of an int3 left by bits n.</summary>
5383 /// <param name="x">Value to rotate.</param>
5384 /// <param name="n">Number of bits to rotate.</param>
5385 /// <returns>The componentwise rotated value.</returns>
5386 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5387 public static int3 rol(int3 x, int n) { return (int3)rol((uint3)x, n); }
5388
5389 /// <summary>Returns the componentwise result of rotating the bits of an int4 left by bits n.</summary>
5390 /// <param name="x">Value to rotate.</param>
5391 /// <param name="n">Number of bits to rotate.</param>
5392 /// <returns>The componentwise rotated value.</returns>
5393 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5394 public static int4 rol(int4 x, int n) { return (int4)rol((uint4)x, n); }
5395
5396
5397 /// <summary>Returns the result of rotating the bits of a uint left by bits n.</summary>
5398 /// <param name="x">Value to rotate.</param>
5399 /// <param name="n">Number of bits to rotate.</param>
5400 /// <returns>The rotated value.</returns>
5401 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5402 public static uint rol(uint x, int n) { return (x << n) | (x >> (32 - n)); }
5403
5404 /// <summary>Returns the componentwise result of rotating the bits of a uint2 left by bits n.</summary>
5405 /// <param name="x">Value to rotate.</param>
5406 /// <param name="n">Number of bits to rotate.</param>
5407 /// <returns>The componentwise rotated value.</returns>
5408 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5409 public static uint2 rol(uint2 x, int n) { return (x << n) | (x >> (32 - n)); }
5410
5411 /// <summary>Returns the componentwise result of rotating the bits of a uint3 left by bits n.</summary>
5412 /// <param name="x">Value to rotate.</param>
5413 /// <param name="n">Number of bits to rotate.</param>
5414 /// <returns>The componentwise rotated value.</returns>
5415 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5416 public static uint3 rol(uint3 x, int n) { return (x << n) | (x >> (32 - n)); }
5417
5418 /// <summary>Returns the componentwise result of rotating the bits of a uint4 left by bits n.</summary>
5419 /// <param name="x">Value to rotate.</param>
5420 /// <param name="n">Number of bits to rotate.</param>
5421 /// <returns>The componentwise rotated value.</returns>
5422 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5423 public static uint4 rol(uint4 x, int n) { return (x << n) | (x >> (32 - n)); }
5424
5425
5426 /// <summary>Returns the result of rotating the bits of a long left by bits n.</summary>
5427 /// <param name="x">Value to rotate.</param>
5428 /// <param name="n">Number of bits to rotate.</param>
5429 /// <returns>The rotated value.</returns>
5430 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5431 public static long rol(long x, int n) { return (long)rol((ulong)x, n); }
5432
5433
5434 /// <summary>Returns the result of rotating the bits of a ulong left by bits n.</summary>
5435 /// <param name="x">Value to rotate.</param>
5436 /// <param name="n">Number of bits to rotate.</param>
5437 /// <returns>The rotated value.</returns>
5438 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5439 public static ulong rol(ulong x, int n) { return (x << n) | (x >> (64 - n)); }
5440
5441
5442 /// <summary>Returns the result of rotating the bits of an int right by bits n.</summary>
5443 /// <param name="x">Value to rotate.</param>
5444 /// <param name="n">Number of bits to rotate.</param>
5445 /// <returns>The rotated value.</returns>
5446 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5447 public static int ror(int x, int n) { return (int)ror((uint)x, n); }
5448
5449 /// <summary>Returns the componentwise result of rotating the bits of an int2 right by bits n.</summary>
5450 /// <param name="x">Value to rotate.</param>
5451 /// <param name="n">Number of bits to rotate.</param>
5452 /// <returns>The componentwise rotated value.</returns>
5453 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5454 public static int2 ror(int2 x, int n) { return (int2)ror((uint2)x, n); }
5455
5456 /// <summary>Returns the componentwise result of rotating the bits of an int3 right by bits n.</summary>
5457 /// <param name="x">Value to rotate.</param>
5458 /// <param name="n">Number of bits to rotate.</param>
5459 /// <returns>The componentwise rotated value.</returns>
5460 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5461 public static int3 ror(int3 x, int n) { return (int3)ror((uint3)x, n); }
5462
5463 /// <summary>Returns the componentwise result of rotating the bits of an int4 right by bits n.</summary>
5464 /// <param name="x">Value to rotate.</param>
5465 /// <param name="n">Number of bits to rotate.</param>
5466 /// <returns>The componentwise rotated value.</returns>
5467 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5468 public static int4 ror(int4 x, int n) { return (int4)ror((uint4)x, n); }
5469
5470
5471 /// <summary>Returns the result of rotating the bits of a uint right by bits n.</summary>
5472 /// <param name="x">Value to rotate.</param>
5473 /// <param name="n">Number of bits to rotate.</param>
5474 /// <returns>The rotated value.</returns>
5475 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5476 public static uint ror(uint x, int n) { return (x >> n) | (x << (32 - n)); }
5477
5478 /// <summary>Returns the componentwise result of rotating the bits of a uint2 right by bits n.</summary>
5479 /// <param name="x">Value to rotate.</param>
5480 /// <param name="n">Number of bits to rotate.</param>
5481 /// <returns>The componentwise rotated value.</returns>
5482 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5483 public static uint2 ror(uint2 x, int n) { return (x >> n) | (x << (32 - n)); }
5484
5485 /// <summary>Returns the componentwise result of rotating the bits of a uint3 right by bits n.</summary>
5486 /// <param name="x">Value to rotate.</param>
5487 /// <param name="n">Number of bits to rotate.</param>
5488 /// <returns>The componentwise rotated value.</returns>
5489 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5490 public static uint3 ror(uint3 x, int n) { return (x >> n) | (x << (32 - n)); }
5491
5492 /// <summary>Returns the componentwise result of rotating the bits of a uint4 right by bits n.</summary>
5493 /// <param name="x">Value to rotate.</param>
5494 /// <param name="n">Number of bits to rotate.</param>
5495 /// <returns>The componentwise rotated value.</returns>
5496 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5497 public static uint4 ror(uint4 x, int n) { return (x >> n) | (x << (32 - n)); }
5498
5499
5500 /// <summary>Returns the result of rotating the bits of a long right by bits n.</summary>
5501 /// <param name="x">Value to rotate.</param>
5502 /// <param name="n">Number of bits to rotate.</param>
5503 /// <returns>The rotated value.</returns>
5504 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5505 public static long ror(long x, int n) { return (long)ror((ulong)x, n); }
5506
5507
5508 /// <summary>Returns the result of rotating the bits of a ulong right by bits n.</summary>
5509 /// <param name="x">Value to rotate.</param>
5510 /// <param name="n">Number of bits to rotate.</param>
5511 /// <returns>The rotated value.</returns>
5512 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5513 public static ulong ror(ulong x, int n) { return (x >> n) | (x << (64 - n)); }
5514
5515
5516 /// <summary>Returns the smallest power of two greater than or equal to the input.</summary>
5517 /// <remarks>Also known as nextpow2.</remarks>
5518 /// <param name="x">Input value.</param>
5519 /// <returns>The smallest power of two greater than or equal to the input.</returns>
5520 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5521 public static int ceilpow2(int x)
5522 {
5523 x -= 1;
5524 x |= x >> 1;
5525 x |= x >> 2;
5526 x |= x >> 4;
5527 x |= x >> 8;
5528 x |= x >> 16;
5529 return x + 1;
5530 }
5531
5532 /// <summary>Returns the result of a componentwise calculation of the smallest power of two greater than or equal to the input.</summary>
5533 /// <remarks>Also known as nextpow2.</remarks>
5534 /// <param name="x">Input value.</param>
5535 /// <returns>The componentwise smallest power of two greater than or equal to the input.</returns>
5536 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5537 public static int2 ceilpow2(int2 x)
5538 {
5539 x -= 1;
5540 x |= x >> 1;
5541 x |= x >> 2;
5542 x |= x >> 4;
5543 x |= x >> 8;
5544 x |= x >> 16;
5545 return x + 1;
5546 }
5547
5548 /// <summary>Returns the result of a componentwise calculation of the smallest power of two greater than or equal to the input.</summary>
5549 /// <remarks>Also known as nextpow2.</remarks>
5550 /// <param name="x">Input value.</param>
5551 /// <returns>The componentwise smallest power of two greater than or equal to the input.</returns>
5552 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5553 public static int3 ceilpow2(int3 x)
5554 {
5555 x -= 1;
5556 x |= x >> 1;
5557 x |= x >> 2;
5558 x |= x >> 4;
5559 x |= x >> 8;
5560 x |= x >> 16;
5561 return x + 1;
5562 }
5563
5564 /// <summary>Returns the result of a componentwise calculation of the smallest power of two greater than or equal to the input.</summary>
5565 /// <remarks>Also known as nextpow2.</remarks>
5566 /// <param name="x">Input value.</param>
5567 /// <returns>The componentwise smallest power of two greater than or equal to the input.</returns>
5568 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5569 public static int4 ceilpow2(int4 x)
5570 {
5571 x -= 1;
5572 x |= x >> 1;
5573 x |= x >> 2;
5574 x |= x >> 4;
5575 x |= x >> 8;
5576 x |= x >> 16;
5577 return x + 1;
5578 }
5579
5580
5581 /// <summary>Returns the smallest power of two greater than or equal to the input.</summary>
5582 /// <remarks>Also known as nextpow2.</remarks>
5583 /// <param name="x">Input value.</param>
5584 /// <returns>The smallest power of two greater than or equal to the input.</returns>
5585 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5586 public static uint ceilpow2(uint x)
5587 {
5588 x -= 1;
5589 x |= x >> 1;
5590 x |= x >> 2;
5591 x |= x >> 4;
5592 x |= x >> 8;
5593 x |= x >> 16;
5594 return x + 1;
5595 }
5596
5597 /// <summary>Returns the result of a componentwise calculation of the smallest power of two greater than or equal to the input.</summary>
5598 /// <remarks>Also known as nextpow2.</remarks>
5599 /// <param name="x">Input value.</param>
5600 /// <returns>The componentwise smallest power of two greater than or equal to the input.</returns>
5601 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5602 public static uint2 ceilpow2(uint2 x)
5603 {
5604 x -= 1;
5605 x |= x >> 1;
5606 x |= x >> 2;
5607 x |= x >> 4;
5608 x |= x >> 8;
5609 x |= x >> 16;
5610 return x + 1;
5611 }
5612
5613 /// <summary>Returns the result of a componentwise calculation of the smallest power of two greater than or equal to the input.</summary>
5614 /// <remarks>Also known as nextpow2.</remarks>
5615 /// <param name="x">Input value.</param>
5616 /// <returns>The componentwise smallest power of two greater than or equal to the input.</returns>
5617 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5618 public static uint3 ceilpow2(uint3 x)
5619 {
5620 x -= 1;
5621 x |= x >> 1;
5622 x |= x >> 2;
5623 x |= x >> 4;
5624 x |= x >> 8;
5625 x |= x >> 16;
5626 return x + 1;
5627 }
5628
5629 /// <summary>Returns the result of a componentwise calculation of the smallest power of two greater than or equal to the input.</summary>
5630 /// <remarks>Also known as nextpow2.</remarks>
5631 /// <param name="x">Input value.</param>
5632 /// <returns>The componentwise smallest power of two greater than or equal to the input.</returns>
5633 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5634 public static uint4 ceilpow2(uint4 x)
5635 {
5636 x -= 1;
5637 x |= x >> 1;
5638 x |= x >> 2;
5639 x |= x >> 4;
5640 x |= x >> 8;
5641 x |= x >> 16;
5642 return x + 1;
5643 }
5644
5645
5646 /// <summary>Returns the smallest power of two greater than or equal to the input.</summary>
5647 /// <remarks>Also known as nextpow2.</remarks>
5648 /// <param name="x">Input value.</param>
5649 /// <returns>The smallest power of two greater than or equal to the input.</returns>
5650 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5651 public static long ceilpow2(long x)
5652 {
5653 x -= 1;
5654 x |= x >> 1;
5655 x |= x >> 2;
5656 x |= x >> 4;
5657 x |= x >> 8;
5658 x |= x >> 16;
5659 x |= x >> 32;
5660 return x + 1;
5661 }
5662
5663
5664 /// <summary>Returns the smallest power of two greater than or equal to the input.</summary>
5665 /// <remarks>Also known as nextpow2.</remarks>
5666 /// <param name="x">Input value.</param>
5667 /// <returns>The smallest power of two greater than or equal to the input.</returns>
5668 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5669 public static ulong ceilpow2(ulong x)
5670 {
5671 x -= 1;
5672 x |= x >> 1;
5673 x |= x >> 2;
5674 x |= x >> 4;
5675 x |= x >> 8;
5676 x |= x >> 16;
5677 x |= x >> 32;
5678 return x + 1;
5679 }
5680
5681 /// <summary>
5682 /// Computes the ceiling of the base-2 logarithm of x.
5683 /// </summary>
5684 /// <remarks>
5685 /// x must be greater than 0, otherwise the result is undefined.
5686 /// </remarks>
5687 /// <param name="x">Integer to be used as input.</param>
5688 /// <returns>Ceiling of the base-2 logarithm of x, as an integer.</returns>
5689 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5690 public static int ceillog2(int x)
5691 {
5692 return 32 - lzcnt((uint)x - 1);
5693 }
5694
5695 /// <summary>
5696 /// Computes the componentwise ceiling of the base-2 logarithm of x.
5697 /// </summary>
5698 /// <remarks>
5699 /// Components of x must be greater than 0, otherwise the result for that component is undefined.
5700 /// </remarks>
5701 /// <param name="x">int2 to be used as input.</param>
5702 /// <returns>Componentwise ceiling of the base-2 logarithm of x.</returns>
5703 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5704 public static int2 ceillog2(int2 x)
5705 {
5706 return new int2(ceillog2(x.x), ceillog2(x.y));
5707 }
5708
5709 /// <summary>
5710 /// Computes the componentwise ceiling of the base-2 logarithm of x.
5711 /// </summary>
5712 /// <remarks>
5713 /// Components of x must be greater than 0, otherwise the result for that component is undefined.
5714 /// </remarks>
5715 /// <param name="x">int3 to be used as input.</param>
5716 /// <returns>Componentwise ceiling of the base-2 logarithm of x.</returns>
5717 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5718 public static int3 ceillog2(int3 x)
5719 {
5720 return new int3(ceillog2(x.x), ceillog2(x.y), ceillog2(x.z));
5721 }
5722
5723 /// <summary>
5724 /// Computes the componentwise ceiling of the base-2 logarithm of x.
5725 /// </summary>
5726 /// <remarks>
5727 /// Components of x must be greater than 0, otherwise the result for that component is undefined.
5728 /// </remarks>
5729 /// <param name="x">int4 to be used as input.</param>
5730 /// <returns>Componentwise ceiling of the base-2 logarithm of x.</returns>
5731 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5732 public static int4 ceillog2(int4 x)
5733 {
5734 return new int4(ceillog2(x.x), ceillog2(x.y), ceillog2(x.z), ceillog2(x.w));
5735 }
5736
5737 /// <summary>
5738 /// Computes the ceiling of the base-2 logarithm of x.
5739 /// </summary>
5740 /// <remarks>
5741 /// x must be greater than 0, otherwise the result is undefined.
5742 /// </remarks>
5743 /// <param name="x">Unsigned integer to be used as input.</param>
5744 /// <returns>Ceiling of the base-2 logarithm of x, as an integer.</returns>
5745 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5746 public static int ceillog2(uint x)
5747 {
5748 return 32 - lzcnt(x - 1);
5749 }
5750
5751 /// <summary>
5752 /// Computes the componentwise ceiling of the base-2 logarithm of x.
5753 /// </summary>
5754 /// <remarks>
5755 /// Components of x must be greater than 0, otherwise the result for that component is undefined.
5756 /// </remarks>
5757 /// <param name="x">uint2 to be used as input.</param>
5758 /// <returns>Componentwise ceiling of the base-2 logarithm of x.</returns>
5759 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5760 public static int2 ceillog2(uint2 x)
5761 {
5762 return new int2(ceillog2(x.x), ceillog2(x.y));
5763 }
5764
5765 /// <summary>
5766 /// Computes the componentwise ceiling of the base-2 logarithm of x.
5767 /// </summary>
5768 /// <remarks>
5769 /// Components of x must be greater than 0, otherwise the result for that component is undefined.
5770 /// </remarks>
5771 /// <param name="x">uint3 to be used as input.</param>
5772 /// <returns>Componentwise ceiling of the base-2 logarithm of x.</returns>
5773 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5774 public static int3 ceillog2(uint3 x)
5775 {
5776 return new int3(ceillog2(x.x), ceillog2(x.y), ceillog2(x.z));
5777 }
5778
5779 /// <summary>
5780 /// Computes the componentwise ceiling of the base-2 logarithm of x.
5781 /// </summary>
5782 /// <remarks>
5783 /// Components of x must be greater than 0, otherwise the result for that component is undefined.
5784 /// </remarks>
5785 /// <param name="x">uint4 to be used as input.</param>
5786 /// <returns>Componentwise ceiling of the base-2 logarithm of x.</returns>
5787 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5788 public static int4 ceillog2(uint4 x)
5789 {
5790 return new int4(ceillog2(x.x), ceillog2(x.y), ceillog2(x.z), ceillog2(x.w));
5791 }
5792
5793 /// <summary>
5794 /// Computes the floor of the base-2 logarithm of x.
5795 /// </summary>
5796 /// <remarks>x must be greater than zero, otherwise the result is undefined.</remarks>
5797 /// <param name="x">Integer to be used as input.</param>
5798 /// <returns>Floor of base-2 logarithm of x.</returns>
5799 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5800 public static int floorlog2(int x)
5801 {
5802 return 31 - lzcnt((uint)x);
5803 }
5804
5805 /// <summary>
5806 /// Computes the componentwise floor of the base-2 logarithm of x.
5807 /// </summary>
5808 /// <remarks>Components of x must be greater than zero, otherwise the result of the component is undefined.</remarks>
5809 /// <param name="x">int2 to be used as input.</param>
5810 /// <returns>Componentwise floor of base-2 logarithm of x.</returns>
5811 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5812 public static int2 floorlog2(int2 x)
5813 {
5814 return new int2(floorlog2(x.x), floorlog2(x.y));
5815 }
5816
5817 /// <summary>
5818 /// Computes the componentwise floor of the base-2 logarithm of x.
5819 /// </summary>
5820 /// <remarks>Components of x must be greater than zero, otherwise the result of the component is undefined.</remarks>
5821 /// <param name="x">int3 to be used as input.</param>
5822 /// <returns>Componentwise floor of base-2 logarithm of x.</returns>
5823 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5824 public static int3 floorlog2(int3 x)
5825 {
5826 return new int3(floorlog2(x.x), floorlog2(x.y), floorlog2(x.z));
5827 }
5828
5829 /// <summary>
5830 /// Computes the componentwise floor of the base-2 logarithm of x.
5831 /// </summary>
5832 /// <remarks>Components of x must be greater than zero, otherwise the result of the component is undefined.</remarks>
5833 /// <param name="x">int4 to be used as input.</param>
5834 /// <returns>Componentwise floor of base-2 logarithm of x.</returns>
5835 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5836 public static int4 floorlog2(int4 x)
5837 {
5838 return new int4(floorlog2(x.x), floorlog2(x.y), floorlog2(x.z), floorlog2(x.w));
5839 }
5840
5841 /// <summary>
5842 /// Computes the floor of the base-2 logarithm of x.
5843 /// </summary>
5844 /// <remarks>x must be greater than zero, otherwise the result is undefined.</remarks>
5845 /// <param name="x">Unsigned integer to be used as input.</param>
5846 /// <returns>Floor of base-2 logarithm of x.</returns>
5847 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5848 public static int floorlog2(uint x)
5849 {
5850 return 31 - lzcnt(x);
5851 }
5852
5853 /// <summary>
5854 /// Computes the componentwise floor of the base-2 logarithm of x.
5855 /// </summary>
5856 /// <remarks>Components of x must be greater than zero, otherwise the result of the component is undefined.</remarks>
5857 /// <param name="x">uint2 to be used as input.</param>
5858 /// <returns>Componentwise floor of base-2 logarithm of x.</returns>
5859 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5860 public static int2 floorlog2(uint2 x)
5861 {
5862 return new int2(floorlog2(x.x), floorlog2(x.y));
5863 }
5864
5865 /// <summary>
5866 /// Computes the componentwise floor of the base-2 logarithm of x.
5867 /// </summary>
5868 /// <remarks>Components of x must be greater than zero, otherwise the result of the component is undefined.</remarks>
5869 /// <param name="x">uint3 to be used as input.</param>
5870 /// <returns>Componentwise floor of base-2 logarithm of x.</returns>
5871 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5872 public static int3 floorlog2(uint3 x)
5873 {
5874 return new int3(floorlog2(x.x), floorlog2(x.y), floorlog2(x.z));
5875 }
5876
5877 /// <summary>
5878 /// Computes the componentwise floor of the base-2 logarithm of x.
5879 /// </summary>
5880 /// <remarks>Components of x must be greater than zero, otherwise the result of the component is undefined.</remarks>
5881 /// <param name="x">uint4 to be used as input.</param>
5882 /// <returns>Componentwise floor of base-2 logarithm of x.</returns>
5883 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5884 public static int4 floorlog2(uint4 x)
5885 {
5886 return new int4(floorlog2(x.x), floorlog2(x.y), floorlog2(x.z), floorlog2(x.w));
5887 }
5888
5889 /// <summary>Returns the result of converting a float value from degrees to radians.</summary>
5890 /// <param name="x">Angle in degrees.</param>
5891 /// <returns>Angle converted to radians.</returns>
5892 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5893 public static float radians(float x) { return x * TORADIANS; }
5894
5895 /// <summary>Returns the result of a componentwise conversion of a float2 vector from degrees to radians.</summary>
5896 /// <param name="x">Vector containing angles in degrees.</param>
5897 /// <returns>Vector containing angles converted to radians.</returns>
5898 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5899 public static float2 radians(float2 x) { return x * TORADIANS; }
5900
5901 /// <summary>Returns the result of a componentwise conversion of a float3 vector from degrees to radians.</summary>
5902 /// <param name="x">Vector containing angles in degrees.</param>
5903 /// <returns>Vector containing angles converted to radians.</returns>
5904 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5905 public static float3 radians(float3 x) { return x * TORADIANS; }
5906
5907 /// <summary>Returns the result of a componentwise conversion of a float4 vector from degrees to radians.</summary>
5908 /// <param name="x">Vector containing angles in degrees.</param>
5909 /// <returns>Vector containing angles converted to radians.</returns>
5910 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5911 public static float4 radians(float4 x) { return x * TORADIANS; }
5912
5913
5914 /// <summary>Returns the result of converting a float value from degrees to radians.</summary>
5915 /// <param name="x">Angle in degrees.</param>
5916 /// <returns>Angle converted to radians.</returns>
5917 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5918 public static double radians(double x) { return x * TORADIANS_DBL; }
5919
5920 /// <summary>Returns the result of a componentwise conversion of a float2 vector from degrees to radians.</summary>
5921 /// <param name="x">Vector containing angles in degrees.</param>
5922 /// <returns>Vector containing angles converted to radians.</returns>
5923 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5924 public static double2 radians(double2 x) { return x * TORADIANS_DBL; }
5925
5926 /// <summary>Returns the result of a componentwise conversion of a float3 vector from degrees to radians.</summary>
5927 /// <param name="x">Vector containing angles in degrees.</param>
5928 /// <returns>Vector containing angles converted to radians.</returns>
5929 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5930 public static double3 radians(double3 x) { return x * TORADIANS_DBL; }
5931
5932 /// <summary>Returns the result of a componentwise conversion of a float4 vector from degrees to radians.</summary>
5933 /// <param name="x">Vector containing angles in degrees.</param>
5934 /// <returns>Vector containing angles converted to radians.</returns>
5935 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5936 public static double4 radians(double4 x) { return x * TORADIANS_DBL; }
5937
5938
5939 /// <summary>Returns the result of converting a double value from radians to degrees.</summary>
5940 /// <param name="x">Angle in radians.</param>
5941 /// <returns>Angle converted to degrees.</returns>
5942 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5943 public static float degrees(float x) { return x * TODEGREES; }
5944
5945 /// <summary>Returns the result of a componentwise conversion of a double2 vector from radians to degrees.</summary>
5946 /// <param name="x">Vector containing angles in radians.</param>
5947 /// <returns>Vector containing angles converted to degrees.</returns>
5948 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5949 public static float2 degrees(float2 x) { return x * TODEGREES; }
5950
5951 /// <summary>Returns the result of a componentwise conversion of a double3 vector from radians to degrees.</summary>
5952 /// <param name="x">Vector containing angles in radians.</param>
5953 /// <returns>Vector containing angles converted to degrees.</returns>
5954 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5955 public static float3 degrees(float3 x) { return x * TODEGREES; }
5956
5957 /// <summary>Returns the result of a componentwise conversion of a double4 vector from radians to degrees.</summary>
5958 /// <param name="x">Vector containing angles in radians.</param>
5959 /// <returns>Vector containing angles converted to degrees.</returns>
5960 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5961 public static float4 degrees(float4 x) { return x * TODEGREES; }
5962
5963
5964 /// <summary>Returns the result of converting a double value from radians to degrees.</summary>
5965 /// <param name="x">Angle in radians.</param>
5966 /// <returns>Angle converted to degrees.</returns>
5967 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5968 public static double degrees(double x) { return x * TODEGREES_DBL; }
5969
5970 /// <summary>Returns the result of a componentwise conversion of a double2 vector from radians to degrees.</summary>
5971 /// <param name="x">Vector containing angles in radians.</param>
5972 /// <returns>Vector containing angles converted to degrees.</returns>
5973 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5974 public static double2 degrees(double2 x) { return x * TODEGREES_DBL; }
5975
5976 /// <summary>Returns the result of a componentwise conversion of a double3 vector from radians to degrees.</summary>
5977 /// <param name="x">Vector containing angles in radians.</param>
5978 /// <returns>Vector containing values converted to degrees.</returns>
5979 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5980 public static double3 degrees(double3 x) { return x * TODEGREES_DBL; }
5981
5982 /// <summary>Returns the result of a componentwise conversion of a double4 vector from radians to degrees.</summary>
5983 /// <param name="x">Vector containing angles in radians.</param>
5984 /// <returns>Vector containing angles converted to degrees.</returns>
5985 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5986 public static double4 degrees(double4 x) { return x * TODEGREES_DBL; }
5987
5988
5989 /// <summary>Returns the minimum component of an int2 vector.</summary>
5990 /// <param name="x">The vector to use when computing the minimum component.</param>
5991 /// <returns>The value of the minimum component of the vector.</returns>
5992 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5993 public static int cmin(int2 x) { return min(x.x, x.y); }
5994
5995 /// <summary>Returns the minimum component of an int3 vector.</summary>
5996 /// <param name="x">The vector to use when computing the minimum component.</param>
5997 /// <returns>The value of the minimum component of the vector.</returns>
5998 [MethodImpl(MethodImplOptions.AggressiveInlining)]
5999 public static int cmin(int3 x) { return min(min(x.x, x.y), x.z); }
6000
6001 /// <summary>Returns the minimum component of an int4 vector.</summary>
6002 /// <param name="x">The vector to use when computing the minimum component.</param>
6003 /// <returns>The value of the minimum component of the vector.</returns>
6004 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6005 public static int cmin(int4 x) { return min(min(x.x, x.y), min(x.z, x.w)); }
6006
6007
6008 /// <summary>Returns the minimum component of a uint2 vector.</summary>
6009 /// <param name="x">The vector to use when computing the minimum component.</param>
6010 /// <returns>The value of the minimum component of the vector.</returns>
6011 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6012 public static uint cmin(uint2 x) { return min(x.x, x.y); }
6013
6014 /// <summary>Returns the minimum component of a uint3 vector.</summary>
6015 /// <param name="x">The vector to use when computing the minimum component.</param>
6016 /// <returns>The value of the minimum component of the vector.</returns>
6017 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6018 public static uint cmin(uint3 x) { return min(min(x.x, x.y), x.z); }
6019
6020 /// <summary>Returns the minimum component of a uint4 vector.</summary>
6021 /// <param name="x">The vector to use when computing the minimum component.</param>
6022 /// <returns>The value of the minimum component of the vector.</returns>
6023 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6024 public static uint cmin(uint4 x) { return min(min(x.x, x.y), min(x.z, x.w)); }
6025
6026
6027 /// <summary>Returns the minimum component of a float2 vector.</summary>
6028 /// <param name="x">The vector to use when computing the minimum component.</param>
6029 /// <returns>The value of the minimum component of the vector.</returns>
6030 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6031 public static float cmin(float2 x) { return min(x.x, x.y); }
6032
6033 /// <summary>Returns the minimum component of a float3 vector.</summary>
6034 /// <param name="x">The vector to use when computing the minimum component.</param>
6035 /// <returns>The value of the minimum component of the vector.</returns>
6036 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6037 public static float cmin(float3 x) { return min(min(x.x, x.y), x.z); }
6038
6039 /// <summary>Returns the minimum component of a float4 vector.</summary>
6040 /// <param name="x">The vector to use when computing the minimum component.</param>
6041 /// <returns>The value of the minimum component of the vector.</returns>
6042 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6043 public static float cmin(float4 x) { return min(min(x.x, x.y), min(x.z, x.w)); }
6044
6045
6046 /// <summary>Returns the minimum component of a double2 vector.</summary>
6047 /// <param name="x">The vector to use when computing the minimum component.</param>
6048 /// <returns>The value of the minimum component of the vector.</returns>
6049 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6050 public static double cmin(double2 x) { return min(x.x, x.y); }
6051
6052 /// <summary>Returns the minimum component of a double3 vector.</summary>
6053 /// <param name="x">The vector to use when computing the minimum component.</param>
6054 /// <returns>The value of the minimum component of the vector.</returns>
6055 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6056 public static double cmin(double3 x) { return min(min(x.x, x.y), x.z); }
6057
6058 /// <summary>Returns the minimum component of a double4 vector.</summary>
6059 /// <param name="x">The vector to use when computing the minimum component.</param>
6060 /// <returns>The value of the minimum component of the vector.</returns>
6061 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6062 public static double cmin(double4 x) { return min(min(x.x, x.y), min(x.z, x.w)); }
6063
6064
6065 /// <summary>Returns the maximum component of an int2 vector.</summary>
6066 /// <param name="x">The vector to use when computing the maximum component.</param>
6067 /// <returns>The value of the maximum component of the vector.</returns>
6068 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6069 public static int cmax(int2 x) { return max(x.x, x.y); }
6070
6071 /// <summary>Returns the maximum component of an int3 vector.</summary>
6072 /// <param name="x">The vector to use when computing the maximum component.</param>
6073 /// <returns>The value of the maximum component of the vector.</returns>
6074 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6075 public static int cmax(int3 x) { return max(max(x.x, x.y), x.z); }
6076
6077 /// <summary>Returns the maximum component of an int4 vector.</summary>
6078 /// <param name="x">The vector to use when computing the maximum component.</param>
6079 /// <returns>The value of the maximum component of the vector.</returns>
6080 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6081 public static int cmax(int4 x) { return max(max(x.x, x.y), max(x.z, x.w)); }
6082
6083
6084 /// <summary>Returns the maximum component of a uint2 vector.</summary>
6085 /// <param name="x">The vector to use when computing the maximum component.</param>
6086 /// <returns>The value of the maximum component of the vector.</returns>
6087 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6088 public static uint cmax(uint2 x) { return max(x.x, x.y); }
6089
6090 /// <summary>Returns the maximum component of a uint3 vector.</summary>
6091 /// <param name="x">The vector to use when computing the maximum component.</param>
6092 /// <returns>The value of the maximum component of the vector.</returns>
6093 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6094 public static uint cmax(uint3 x) { return max(max(x.x, x.y), x.z); }
6095
6096 /// <summary>Returns the maximum component of a uint4 vector.</summary>
6097 /// <param name="x">The vector to use when computing the maximum component.</param>
6098 /// <returns>The value of the maximum component of the vector.</returns>
6099 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6100 public static uint cmax(uint4 x) { return max(max(x.x, x.y), max(x.z, x.w)); }
6101
6102
6103 /// <summary>Returns the maximum component of a float2 vector.</summary>
6104 /// <param name="x">The vector to use when computing the maximum component.</param>
6105 /// <returns>The value of the maximum component of the vector.</returns>
6106 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6107 public static float cmax(float2 x) { return max(x.x, x.y); }
6108
6109 /// <summary>Returns the maximum component of a float3 vector.</summary>
6110 /// <param name="x">The vector to use when computing the maximum component.</param>
6111 /// <returns>The value of the maximum component of the vector.</returns>
6112 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6113 public static float cmax(float3 x) { return max(max(x.x, x.y), x.z); }
6114
6115 /// <summary>Returns the maximum component of a float4 vector.</summary>
6116 /// <param name="x">The vector to use when computing the maximum component.</param>
6117 /// <returns>The value of the maximum component of the vector.</returns>
6118 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6119 public static float cmax(float4 x) { return max(max(x.x, x.y), max(x.z, x.w)); }
6120
6121
6122 /// <summary>Returns the maximum component of a double2 vector.</summary>
6123 /// <param name="x">The vector to use when computing the maximum component.</param>
6124 /// <returns>The value of the maximum component of the vector.</returns>
6125 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6126 public static double cmax(double2 x) { return max(x.x, x.y); }
6127
6128 /// <summary>Returns the maximum component of a double3 vector.</summary>
6129 /// <param name="x">The vector to use when computing the maximum component.</param>
6130 /// <returns>The value of the maximum component of the vector.</returns>
6131 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6132 public static double cmax(double3 x) { return max(max(x.x, x.y), x.z); }
6133
6134 /// <summary>Returns the maximum component of a double4 vector.</summary>
6135 /// <param name="x">The vector to use when computing the maximum component.</param>
6136 /// <returns>The value of the maximum component of the vector.</returns>
6137 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6138 public static double cmax(double4 x) { return max(max(x.x, x.y), max(x.z, x.w)); }
6139
6140
6141 /// <summary>Returns the horizontal sum of components of an int2 vector.</summary>
6142 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6143 /// <returns>The horizontal sum of of components of the vector.</returns>
6144 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6145 public static int csum(int2 x) { return x.x + x.y; }
6146
6147 /// <summary>Returns the horizontal sum of components of an int3 vector.</summary>
6148 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6149 /// <returns>The horizontal sum of of components of the vector.</returns>
6150 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6151 public static int csum(int3 x) { return x.x + x.y + x.z; }
6152
6153 /// <summary>Returns the horizontal sum of components of an int4 vector.</summary>
6154 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6155 /// <returns>The horizontal sum of of components of the vector.</returns>
6156 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6157 public static int csum(int4 x) { return x.x + x.y + x.z + x.w; }
6158
6159
6160 /// <summary>Returns the horizontal sum of components of a uint2 vector.</summary>
6161 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6162 /// <returns>The horizontal sum of of components of the vector.</returns>
6163 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6164 public static uint csum(uint2 x) { return x.x + x.y; }
6165
6166 /// <summary>Returns the horizontal sum of components of a uint3 vector.</summary>
6167 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6168 /// <returns>The horizontal sum of of components of the vector.</returns>
6169 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6170 public static uint csum(uint3 x) { return x.x + x.y + x.z; }
6171
6172 /// <summary>Returns the horizontal sum of components of a uint4 vector.</summary>
6173 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6174 /// <returns>The horizontal sum of of components of the vector.</returns>
6175 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6176 public static uint csum(uint4 x) { return x.x + x.y + x.z + x.w; }
6177
6178
6179 /// <summary>Returns the horizontal sum of components of a float2 vector.</summary>
6180 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6181 /// <returns>The horizontal sum of of components of the vector.</returns>
6182 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6183 public static float csum(float2 x) { return x.x + x.y; }
6184
6185 /// <summary>Returns the horizontal sum of components of a float3 vector.</summary>
6186 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6187 /// <returns>The horizontal sum of of components of the vector.</returns>
6188 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6189 public static float csum(float3 x) { return x.x + x.y + x.z; }
6190
6191 /// <summary>Returns the horizontal sum of components of a float4 vector.</summary>
6192 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6193 /// <returns>The horizontal sum of of components of the vector.</returns>
6194 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6195 public static float csum(float4 x) { return (x.x + x.y) + (x.z + x.w); }
6196
6197
6198 /// <summary>Returns the horizontal sum of components of a double2 vector.</summary>
6199 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6200 /// <returns>The horizontal sum of of components of the vector.</returns>
6201 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6202 public static double csum(double2 x) { return x.x + x.y; }
6203
6204 /// <summary>Returns the horizontal sum of components of a double3 vector.</summary>
6205 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6206 /// <returns>The horizontal sum of of components of the vector.</returns>
6207 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6208 public static double csum(double3 x) { return x.x + x.y + x.z; }
6209
6210 /// <summary>Returns the horizontal sum of components of a double4 vector.</summary>
6211 /// <param name="x">The vector to use when computing the horizontal sum.</param>
6212 /// <returns>The horizontal sum of of components of the vector.</returns>
6213 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6214 public static double csum(double4 x) { return (x.x + x.y) + (x.z + x.w); }
6215
6216 /// <summary>
6217 /// Computes the square (x * x) of the input argument x.
6218 /// </summary>
6219 /// <param name="x">Value to square.</param>
6220 /// <returns>Returns the square of the input.</returns>
6221 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6222 public static float square(float x)
6223 {
6224 return x * x;
6225 }
6226
6227 /// <summary>
6228 /// Computes the component-wise square (x * x) of the input argument x.
6229 /// </summary>
6230 /// <param name="x">Value to square.</param>
6231 /// <returns>Returns the square of the input.</returns>
6232 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6233 public static float2 square(float2 x)
6234 {
6235 return x * x;
6236 }
6237
6238 /// <summary>
6239 /// Computes the component-wise square (x * x) of the input argument x.
6240 /// </summary>
6241 /// <param name="x">Value to square.</param>
6242 /// <returns>Returns the square of the input.</returns>
6243 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6244 public static float3 square(float3 x)
6245 {
6246 return x * x;
6247 }
6248
6249 /// <summary>
6250 /// Computes the component-wise square (x * x) of the input argument x.
6251 /// </summary>
6252 /// <param name="x">Value to square.</param>
6253 /// <returns>Returns the square of the input.</returns>
6254 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6255 public static float4 square(float4 x)
6256 {
6257 return x * x;
6258 }
6259
6260 /// <summary>
6261 /// Computes the square (x * x) of the input argument x.
6262 /// </summary>
6263 /// <param name="x">Value to square.</param>
6264 /// <returns>Returns the square of the input.</returns>
6265 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6266 public static double square(double x)
6267 {
6268 return x * x;
6269 }
6270
6271 /// <summary>
6272 /// Computes the component-wise square (x * x) of the input argument x.
6273 /// </summary>
6274 /// <param name="x">Value to square.</param>
6275 /// <returns>Returns the square of the input.</returns>
6276 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6277 public static double2 square(double2 x)
6278 {
6279 return x * x;
6280 }
6281
6282 /// <summary>
6283 /// Computes the component-wise square (x * x) of the input argument x.
6284 /// </summary>
6285 /// <param name="x">Value to square.</param>
6286 /// <returns>Returns the square of the input.</returns>
6287 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6288 public static double3 square(double3 x)
6289 {
6290 return x * x;
6291 }
6292
6293 /// <summary>
6294 /// Computes the component-wise square (x * x) of the input argument x.
6295 /// </summary>
6296 /// <param name="x">Value to square.</param>
6297 /// <returns>Returns the square of the input.</returns>
6298 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6299 public static double4 square(double4 x)
6300 {
6301 return x * x;
6302 }
6303
6304 /// <summary>
6305 /// Computes the square (x * x) of the input argument x.
6306 /// </summary>
6307 /// <remarks>
6308 /// Due to integer overflow, it's not always guaranteed that <c>square(x)</c> is positive. For example, <c>square(46341)</c>
6309 /// will return <c>-2147479015</c>.
6310 /// </remarks>
6311 /// <param name="x">Value to square.</param>
6312 /// <returns>Returns the square of the input.</returns>
6313 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6314 public static int square(int x)
6315 {
6316 return x * x;
6317 }
6318
6319 /// <summary>
6320 /// Computes the component-wise square (x * x) of the input argument x.
6321 /// </summary>
6322 /// <remarks>
6323 /// Due to integer overflow, it's not always guaranteed that <c>square(x)</c> is positive. For example, <c>square(new int2(46341))</c>
6324 /// will return <c>new int2(-2147479015)</c>.
6325 /// </remarks>
6326 /// <param name="x">Value to square.</param>
6327 /// <returns>Returns the square of the input.</returns>
6328 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6329 public static int2 square(int2 x)
6330 {
6331 return x * x;
6332 }
6333
6334 /// <summary>
6335 /// Computes the component-wise square (x * x) of the input argument x.
6336 /// </summary>
6337 /// <remarks>
6338 /// Due to integer overflow, it's not always guaranteed that <c>square(x)</c> is positive. For example, <c>square(new int3(46341))</c>
6339 /// will return <c>new int3(-2147479015)</c>.
6340 /// </remarks>
6341 /// <param name="x">Value to square.</param>
6342 /// <returns>Returns the square of the input.</returns>
6343 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6344 public static int3 square(int3 x)
6345 {
6346 return x * x;
6347 }
6348
6349 /// <summary>
6350 /// Computes the component-wise square (x * x) of the input argument x.
6351 /// </summary>
6352 /// <remarks>
6353 /// Due to integer overflow, it's not always guaranteed that <c>square(x)</c> is positive. For example, <c>square(new int4(46341))</c>
6354 /// will return <c>new int4(-2147479015)</c>.
6355 /// </remarks>
6356 /// <param name="x">Value to square.</param>
6357 /// <returns>Returns the square of the input.</returns>
6358 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6359 public static int4 square(int4 x)
6360 {
6361 return x * x;
6362 }
6363
6364 /// <summary>
6365 /// Computes the square (x * x) of the input argument x.
6366 /// </summary>
6367 /// <remarks>
6368 /// Due to integer overflow, it's not always guaranteed that <c>square(x) >= x</c>. For example, <c>square(4294967295u)</c>
6369 /// will return <c>1u</c>.
6370 /// </remarks>
6371 /// <param name="x">Value to square.</param>
6372 /// <returns>Returns the square of the input.</returns>
6373 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6374 public static uint square(uint x)
6375 {
6376 return x * x;
6377 }
6378
6379 /// <summary>
6380 /// Computes the component-wise square (x * x) of the input argument x.
6381 /// </summary>
6382 /// <remarks>
6383 /// Due to integer overflow, it's not always guaranteed that <c>square(x) >= x</c>. For example, <c>square(new uint2(4294967295u))</c>
6384 /// will return <c>new uint2(1u)</c>.
6385 /// </remarks>
6386 /// <param name="x">Value to square.</param>
6387 /// <returns>Returns the square of the input.</returns>
6388 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6389 public static uint2 square(uint2 x)
6390 {
6391 return x * x;
6392 }
6393
6394 /// <summary>
6395 /// Computes the component-wise square (x * x) of the input argument x.
6396 /// </summary>
6397 /// <remarks>
6398 /// Due to integer overflow, it's not always guaranteed that <c>square(x) >= x</c>. For example, <c>square(new uint3(4294967295u))</c>
6399 /// will return <c>new uint3(1u)</c>.
6400 /// </remarks>
6401 /// <param name="x">Value to square.</param>
6402 /// <returns>Returns the square of the input.</returns>
6403 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6404 public static uint3 square(uint3 x)
6405 {
6406 return x * x;
6407 }
6408
6409 /// <summary>
6410 /// Computes the component-wise square (x * x) of the input argument x.
6411 /// </summary>
6412 /// <remarks>
6413 /// Due to integer overflow, it's not always guaranteed that <c>square(x) >= x</c>. For example, <c>square(new uint4(4294967295u))</c>
6414 /// will return <c>new uint4(1u)</c>.
6415 /// </remarks>
6416 /// <param name="x">Value to square.</param>
6417 /// <returns>Returns the square of the input.</returns>
6418 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6419 public static uint4 square(uint4 x)
6420 {
6421 return x * x;
6422 }
6423
6424 /// <summary>
6425 /// Packs components with an enabled mask to the left.
6426 /// </summary>
6427 /// <remarks>
6428 /// This function is also known as left packing. The effect of this function is to filter out components that
6429 /// are not enabled and leave an output buffer tightly packed with only the enabled components. A common use
6430 /// case is if you perform intersection tests on arrays of data in structure of arrays (SoA) form and need to
6431 /// produce an output array of the things that intersected.
6432 /// </remarks>
6433 /// <param name="output">Pointer to packed output array where enabled components should be stored to.</param>
6434 /// <param name="index">Index into output array where first enabled component should be stored to.</param>
6435 /// <param name="val">The value to to compress.</param>
6436 /// <param name="mask">Mask indicating which components are enabled.</param>
6437 /// <returns>Index to element after the last one stored.</returns>
6438 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6439 public static unsafe int compress(int* output, int index, int4 val, bool4 mask)
6440 {
6441 if (mask.x)
6442 output[index++] = val.x;
6443 if (mask.y)
6444 output[index++] = val.y;
6445 if (mask.z)
6446 output[index++] = val.z;
6447 if (mask.w)
6448 output[index++] = val.w;
6449
6450 return index;
6451 }
6452
6453 /// <summary>
6454 /// Packs components with an enabled mask to the left.
6455 /// </summary>
6456 /// <remarks>
6457 /// This function is also known as left packing. The effect of this function is to filter out components that
6458 /// are not enabled and leave an output buffer tightly packed with only the enabled components. A common use
6459 /// case is if you perform intersection tests on arrays of data in structure of arrays (SoA) form and need to
6460 /// produce an output array of the things that intersected.
6461 /// </remarks>
6462 /// <param name="output">Pointer to packed output array where enabled components should be stored to.</param>
6463 /// <param name="index">Index into output array where first enabled component should be stored to.</param>
6464 /// <param name="val">The value to to compress.</param>
6465 /// <param name="mask">Mask indicating which components are enabled.</param>
6466 /// <returns>Index to element after the last one stored.</returns>
6467 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6468 public static unsafe int compress(uint* output, int index, uint4 val, bool4 mask)
6469 {
6470 return compress((int*)output, index, *(int4*)&val, mask);
6471 }
6472
6473 /// <summary>
6474 /// Packs components with an enabled mask to the left.
6475 /// </summary>
6476 /// <remarks>
6477 /// This function is also known as left packing. The effect of this function is to filter out components that
6478 /// are not enabled and leave an output buffer tightly packed with only the enabled components. A common use
6479 /// case is if you perform intersection tests on arrays of data in structure of arrays (SoA) form and need to
6480 /// produce an output array of the things that intersected.
6481 /// </remarks>
6482 /// <param name="output">Pointer to packed output array where enabled components should be stored to.</param>
6483 /// <param name="index">Index into output array where first enabled component should be stored to.</param>
6484 /// <param name="val">The value to to compress.</param>
6485 /// <param name="mask">Mask indicating which components are enabled.</param>
6486 /// <returns>Index to element after the last one stored.</returns>
6487 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6488 public static unsafe int compress(float* output, int index, float4 val, bool4 mask)
6489 {
6490 return compress((int*)output, index, *(int4*)&val, mask);
6491 }
6492
6493 /// <summary>Returns the floating point representation of a half-precision floating point value.</summary>
6494 /// <param name="x">The half precision float.</param>
6495 /// <returns>The single precision float representation of the half precision float.</returns>
6496 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6497 public static float f16tof32(uint x)
6498 {
6499 const uint shifted_exp = (0x7c00 << 13);
6500 uint uf = (x & 0x7fff) << 13;
6501 uint e = uf & shifted_exp;
6502 uf += (127 - 15) << 23;
6503 uf += select(0, (128u - 16u) << 23, e == shifted_exp);
6504 uf = select(uf, asuint(asfloat(uf + (1 << 23)) - 6.10351563e-05f), e == 0);
6505 uf |= (x & 0x8000) << 16;
6506 return asfloat(uf);
6507 }
6508
6509 /// <summary>Returns the floating point representation of a half-precision floating point vector.</summary>
6510 /// <param name="x">The half precision float vector.</param>
6511 /// <returns>The single precision float vector representation of the half precision float vector.</returns>
6512 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6513 public static float2 f16tof32(uint2 x)
6514 {
6515 const uint shifted_exp = (0x7c00 << 13);
6516 uint2 uf = (x & 0x7fff) << 13;
6517 uint2 e = uf & shifted_exp;
6518 uf += (127 - 15) << 23;
6519 uf += select(0, (128u - 16u) << 23, e == shifted_exp);
6520 uf = select(uf, asuint(asfloat(uf + (1 << 23)) - 6.10351563e-05f), e == 0);
6521 uf |= (x & 0x8000) << 16;
6522 return asfloat(uf);
6523 }
6524
6525 /// <summary>Returns the floating point representation of a half-precision floating point vector.</summary>
6526 /// <param name="x">The half precision float vector.</param>
6527 /// <returns>The single precision float vector representation of the half precision float vector.</returns>
6528 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6529 public static float3 f16tof32(uint3 x)
6530 {
6531 const uint shifted_exp = (0x7c00 << 13);
6532 uint3 uf = (x & 0x7fff) << 13;
6533 uint3 e = uf & shifted_exp;
6534 uf += (127 - 15) << 23;
6535 uf += select(0, (128u - 16u) << 23, e == shifted_exp);
6536 uf = select(uf, asuint(asfloat(uf + (1 << 23)) - 6.10351563e-05f), e == 0);
6537 uf |= (x & 0x8000) << 16;
6538 return asfloat(uf);
6539 }
6540
6541 /// <summary>Returns the floating point representation of a half-precision floating point vector.</summary>
6542 /// <param name="x">The half precision float vector.</param>
6543 /// <returns>The single precision float vector representation of the half precision float vector.</returns>
6544 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6545 public static float4 f16tof32(uint4 x)
6546 {
6547 const uint shifted_exp = (0x7c00 << 13);
6548 uint4 uf = (x & 0x7fff) << 13;
6549 uint4 e = uf & shifted_exp;
6550 uf += (127 - 15) << 23;
6551 uf += select(0, (128u - 16u) << 23, e == shifted_exp);
6552 uf = select(uf, asuint(asfloat(uf + (1 << 23)) - 6.10351563e-05f), e == 0);
6553 uf |= (x & 0x8000) << 16;
6554 return asfloat(uf);
6555 }
6556
6557 /// <summary>Returns the result converting a float value to its nearest half-precision floating point representation.</summary>
6558 /// <param name="x">The single precision float.</param>
6559 /// <returns>The half precision float representation of the single precision float.</returns>
6560 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6561 public static uint f32tof16(float x)
6562 {
6563 const int infinity_32 = 255 << 23;
6564 const uint msk = 0x7FFFF000u;
6565
6566 uint ux = asuint(x);
6567 uint uux = ux & msk;
6568 uint h = (uint)(asuint(min(asfloat(uux) * 1.92592994e-34f, 260042752.0f)) + 0x1000) >> 13; // Clamp to signed infinity if overflowed
6569 h = select(h, select(0x7c00u, 0x7e00u, (int)uux > infinity_32), (int)uux >= infinity_32); // NaN->qNaN and Inf->Inf
6570 return h | (ux & ~msk) >> 16;
6571 }
6572
6573 /// <summary>Returns the result of a componentwise conversion of a float2 vector to its nearest half-precision floating point representation.</summary>
6574 /// <param name="x">The single precision float vector.</param>
6575 /// <returns>The half precision float vector representation of the single precision float vector.</returns>
6576 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6577 public static uint2 f32tof16(float2 x)
6578 {
6579 const int infinity_32 = 255 << 23;
6580 const uint msk = 0x7FFFF000u;
6581
6582 uint2 ux = asuint(x);
6583 uint2 uux = ux & msk;
6584 uint2 h = (uint2)(asint(min(asfloat(uux) * 1.92592994e-34f, 260042752.0f)) + 0x1000) >> 13; // Clamp to signed infinity if overflowed
6585 h = select(h, select(0x7c00u, 0x7e00u, (int2)uux > infinity_32), (int2)uux >= infinity_32); // NaN->qNaN and Inf->Inf
6586 return h | (ux & ~msk) >> 16;
6587 }
6588
6589 /// <summary>Returns the result of a componentwise conversion of a float3 vector to its nearest half-precision floating point representation.</summary>
6590 /// <param name="x">The single precision float vector.</param>
6591 /// <returns>The half precision float vector representation of the single precision float vector.</returns>
6592 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6593 public static uint3 f32tof16(float3 x)
6594 {
6595 const int infinity_32 = 255 << 23;
6596 const uint msk = 0x7FFFF000u;
6597
6598 uint3 ux = asuint(x);
6599 uint3 uux = ux & msk;
6600 uint3 h = (uint3)(asint(min(asfloat(uux) * 1.92592994e-34f, 260042752.0f)) + 0x1000) >> 13; // Clamp to signed infinity if overflowed
6601 h = select(h, select(0x7c00u, 0x7e00u, (int3)uux > infinity_32), (int3)uux >= infinity_32); // NaN->qNaN and Inf->Inf
6602 return h | (ux & ~msk) >> 16;
6603 }
6604
6605 /// <summary>Returns the result of a componentwise conversion of a float4 vector to its nearest half-precision floating point representation.</summary>
6606 /// <param name="x">The single precision float vector.</param>
6607 /// <returns>The half precision float vector representation of the single precision float vector.</returns>
6608 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6609 public static uint4 f32tof16(float4 x)
6610 {
6611 const int infinity_32 = 255 << 23;
6612 const uint msk = 0x7FFFF000u;
6613
6614 uint4 ux = asuint(x);
6615 uint4 uux = ux & msk;
6616 uint4 h = (uint4)(asint(min(asfloat(uux) * 1.92592994e-34f, 260042752.0f)) + 0x1000) >> 13; // Clamp to signed infinity if overflowed
6617 h = select(h, select(0x7c00u, 0x7e00u, (int4)uux > infinity_32), (int4)uux >= infinity_32); // NaN->qNaN and Inf->Inf
6618 return h | (ux & ~msk) >> 16;
6619 }
6620
6621 /// <summary>
6622 /// Generate an orthonormal basis given a single unit length normal vector.
6623 /// </summary>
6624 /// <remarks>
6625 /// This implementation is from "Building an Orthonormal Basis, Revisited"
6626 /// https://graphics.pixar.com/library/OrthonormalB/paper.pdf
6627 /// </remarks>
6628 /// <param name="normal">Unit length normal vector.</param>
6629 /// <param name="basis1">Output unit length vector, orthogonal to normal vector.</param>
6630 /// <param name="basis2">Output unit length vector, orthogonal to normal vector and basis1.</param>
6631 public static void orthonormal_basis(float3 normal, out float3 basis1, out float3 basis2)
6632 {
6633 var sign = normal.z >= 0.0f ? 1.0f : -1.0f;
6634 var a = -1.0f / (sign + normal.z);
6635 var b = normal.x * normal.y * a;
6636 basis1.x = 1.0f + sign * normal.x * normal.x * a;
6637 basis1.y = sign * b;
6638 basis1.z = -sign * normal.x;
6639 basis2.x = b;
6640 basis2.y = sign + normal.y * normal.y * a;
6641 basis2.z = -normal.y;
6642 }
6643
6644 /// <summary>
6645 /// Generate an orthonormal basis given a single unit length normal vector.
6646 /// </summary>
6647 /// <remarks>
6648 /// This implementation is from "Building an Orthonormal Basis, Revisited"
6649 /// https://graphics.pixar.com/library/OrthonormalB/paper.pdf
6650 /// </remarks>
6651 /// <param name="normal">Unit length normal vector.</param>
6652 /// <param name="basis1">Output unit length vector, orthogonal to normal vector.</param>
6653 /// <param name="basis2">Output unit length vector, orthogonal to normal vector and basis1.</param>
6654 public static void orthonormal_basis(double3 normal, out double3 basis1, out double3 basis2)
6655 {
6656 var sign = normal.z >= 0.0 ? 1.0 : -1.0;
6657 var a = -1.0 / (sign + normal.z);
6658 var b = normal.x * normal.y * a;
6659 basis1.x = 1.0 + sign * normal.x * normal.x * a;
6660 basis1.y = sign * b;
6661 basis1.z = -sign * normal.x;
6662 basis2.x = b;
6663 basis2.y = sign + normal.y * normal.y * a;
6664 basis2.z = -normal.y;
6665 }
6666
6667 /// <summary>Change the sign of x based on the most significant bit of y [msb(y) ? -x : x].</summary>
6668 /// <param name="x">The single precision float to change the sign.</param>
6669 /// <param name="y">The single precision float used to test the most significant bit.</param>
6670 /// <returns>Returns x with changed sign based on y.</returns>
6671 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6672 public static float chgsign(float x, float y)
6673 {
6674 return asfloat(asuint(x) ^ (asuint(y) & 0x80000000));
6675 }
6676
6677 /// <summary>Change the sign of components of x based on the most significant bit of components of y [msb(y) ? -x : x].</summary>
6678 /// <param name="x">The single precision float vector to change the sign.</param>
6679 /// <param name="y">The single precision float vector used to test the most significant bit.</param>
6680 /// <returns>Returns vector x with changed sign based on vector y.</returns>
6681 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6682 public static float2 chgsign(float2 x, float2 y)
6683 {
6684 return asfloat(asuint(x) ^ (asuint(y) & 0x80000000));
6685 }
6686
6687 /// <summary>Change the sign of components of x based on the most significant bit of components of y [msb(y) ? -x : x].</summary>
6688 /// <param name="x">The single precision float vector to change the sign.</param>
6689 /// <param name="y">The single precision float vector used to test the most significant bit.</param>
6690 /// <returns>Returns vector x with changed sign based on vector y.</returns>
6691 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6692 public static float3 chgsign(float3 x, float3 y)
6693 {
6694 return asfloat(asuint(x) ^ (asuint(y) & 0x80000000));
6695 }
6696
6697 /// <summary>Change the sign of components of x based on the most significant bit of components of y [msb(y) ? -x : x].</summary>
6698 /// <param name="x">The single precision float vector to change the sign.</param>
6699 /// <param name="y">The single precision float vector used to test the most significant bit.</param>
6700 /// <returns>Returns vector x with changed sign based on vector y.</returns>
6701 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6702 public static float4 chgsign(float4 x, float4 y)
6703 {
6704 return asfloat(asuint(x) ^ (asuint(y) & 0x80000000));
6705 }
6706
6707 /// <summary>
6708 /// Read 32 bits of data in little endian format.
6709 /// </summary>
6710 /// <param name="pBuffer">Memory address to read from.</param>
6711 /// <returns>32 bits in little endian format.</returns>
6712 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6713 private static unsafe uint read32_little_endian(void* pBuffer)
6714 {
6715 byte* ptr = (byte*)pBuffer;
6716 return (uint)ptr[0] | ((uint)ptr[1] << 8) | ((uint)ptr[2] << 16) | ((uint)ptr[3] << 24);
6717 }
6718
6719 private static unsafe uint hash_with_unaligned_loads(void* pBuffer, int numBytes, uint seed)
6720 {
6721 unchecked
6722 {
6723 const uint Prime1 = 2654435761;
6724 const uint Prime2 = 2246822519;
6725 const uint Prime3 = 3266489917;
6726 const uint Prime4 = 668265263;
6727 const uint Prime5 = 374761393;
6728
6729 uint4* p = (uint4*)pBuffer;
6730 uint hash = seed + Prime5;
6731 if (numBytes >= 16)
6732 {
6733 uint4 state = new uint4(Prime1 + Prime2, Prime2, 0, (uint)-Prime1) + seed;
6734
6735 int count = numBytes >> 4;
6736 for (int i = 0; i < count; ++i)
6737 {
6738 state += *p++ * Prime2;
6739 state = (state << 13) | (state >> 19);
6740 state *= Prime1;
6741 }
6742
6743 hash = rol(state.x, 1) + rol(state.y, 7) + rol(state.z, 12) + rol(state.w, 18);
6744 }
6745
6746 hash += (uint)numBytes;
6747
6748 uint* puint = (uint*)p;
6749 for (int i = 0; i < ((numBytes >> 2) & 3); ++i)
6750 {
6751 hash += *puint++ * Prime3;
6752 hash = rol(hash, 17) * Prime4;
6753 }
6754
6755 byte* pbyte = (byte*)puint;
6756 for (int i = 0; i < ((numBytes) & 3); ++i)
6757 {
6758 hash += (*pbyte++) * Prime5;
6759 hash = rol(hash, 11) * Prime1;
6760 }
6761
6762 hash ^= hash >> 15;
6763 hash *= Prime2;
6764 hash ^= hash >> 13;
6765 hash *= Prime3;
6766 hash ^= hash >> 16;
6767
6768 return hash;
6769 }
6770 }
6771
6772 private static unsafe uint hash_without_unaligned_loads(void* pBuffer, int numBytes, uint seed)
6773 {
6774 unchecked
6775 {
6776 const uint Prime1 = 2654435761;
6777 const uint Prime2 = 2246822519;
6778 const uint Prime3 = 3266489917;
6779 const uint Prime4 = 668265263;
6780 const uint Prime5 = 374761393;
6781
6782 byte* p = (byte*)pBuffer;
6783 uint hash = seed + Prime5;
6784 if (numBytes >= 16)
6785 {
6786 uint4 state = new uint4(Prime1 + Prime2, Prime2, 0, (uint)-Prime1) + seed;
6787
6788 int count = numBytes >> 4;
6789 for (int i = 0; i < count; ++i)
6790 {
6791 var data = new uint4(read32_little_endian(p), read32_little_endian(p + 4), read32_little_endian(p + 8), read32_little_endian(p + 12));
6792 state += data * Prime2;
6793 state = rol(state, 13);
6794 state *= Prime1;
6795 p += 16;
6796 }
6797
6798 hash = rol(state.x, 1) + rol(state.y, 7) + rol(state.z, 12) + rol(state.w, 18);
6799 }
6800
6801 hash += (uint)numBytes;
6802
6803 for (int i = 0; i < ((numBytes >> 2) & 3); ++i)
6804 {
6805 hash += read32_little_endian(p) * Prime3;
6806 hash = rol(hash, 17) * Prime4;
6807 p += 4;
6808 }
6809
6810 for (int i = 0; i < ((numBytes) & 3); ++i)
6811 {
6812 hash += (*p++) * Prime5;
6813 hash = rol(hash, 11) * Prime1;
6814 }
6815
6816 hash ^= hash >> 15;
6817 hash *= Prime2;
6818 hash ^= hash >> 13;
6819 hash *= Prime3;
6820 hash ^= hash >> 16;
6821
6822 return hash;
6823 }
6824 }
6825
6826 /// <summary>Returns a uint hash from a block of memory using the xxhash32 algorithm. Can only be used in an unsafe context.</summary>
6827 /// <param name="pBuffer">A pointer to the beginning of the data.</param>
6828 /// <param name="numBytes">Number of bytes to hash.</param>
6829 /// <param name="seed">Starting seed value.</param>
6830 /// <returns>The 32 bit hash of the input data buffer.</returns>
6831 public static unsafe uint hash(void* pBuffer, int numBytes, uint seed = 0)
6832 {
6833#if !UNITY_64 && UNITY_ANDROID
6834 return hash_without_unaligned_loads(pBuffer, numBytes, seed);
6835#else
6836 return hash_with_unaligned_loads(pBuffer, numBytes, seed);
6837#endif
6838 }
6839
6840 /// <summary>
6841 /// Unity's up axis (0, 1, 0).
6842 /// </summary>
6843 /// <remarks>Matches [https://docs.unity3d.com/ScriptReference/Vector3-up.html](https://docs.unity3d.com/ScriptReference/Vector3-up.html)</remarks>
6844 /// <returns>The up axis.</returns>
6845 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6846 public static float3 up() { return new float3(0.0f, 1.0f, 0.0f); } // for compatibility
6847
6848 /// <summary>
6849 /// Unity's down axis (0, -1, 0).
6850 /// </summary>
6851 /// <remarks>Matches [https://docs.unity3d.com/ScriptReference/Vector3-down.html](https://docs.unity3d.com/ScriptReference/Vector3-down.html)</remarks>
6852 /// <returns>The down axis.</returns>
6853 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6854 public static float3 down() { return new float3(0.0f, -1.0f, 0.0f); }
6855
6856 /// <summary>
6857 /// Unity's forward axis (0, 0, 1).
6858 /// </summary>
6859 /// <remarks>Matches [https://docs.unity3d.com/ScriptReference/Vector3-forward.html](https://docs.unity3d.com/ScriptReference/Vector3-forward.html)</remarks>
6860 /// <returns>The forward axis.</returns>
6861 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6862 public static float3 forward() { return new float3(0.0f, 0.0f, 1.0f); }
6863
6864 /// <summary>
6865 /// Unity's back axis (0, 0, -1).
6866 /// </summary>
6867 /// <remarks>Matches [https://docs.unity3d.com/ScriptReference/Vector3-back.html](https://docs.unity3d.com/ScriptReference/Vector3-back.html)</remarks>
6868 /// <returns>The back axis.</returns>
6869 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6870 public static float3 back() { return new float3(0.0f, 0.0f, -1.0f); }
6871
6872 /// <summary>
6873 /// Unity's left axis (-1, 0, 0).
6874 /// </summary>
6875 /// <remarks>Matches [https://docs.unity3d.com/ScriptReference/Vector3-left.html](https://docs.unity3d.com/ScriptReference/Vector3-left.html)</remarks>
6876 /// <returns>The left axis.</returns>
6877 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6878 public static float3 left() { return new float3(-1.0f, 0.0f, 0.0f); }
6879
6880 /// <summary>
6881 /// Unity's right axis (1, 0, 0).
6882 /// </summary>
6883 /// <remarks>Matches [https://docs.unity3d.com/ScriptReference/Vector3-right.html](https://docs.unity3d.com/ScriptReference/Vector3-right.html)</remarks>
6884 /// <returns>The right axis.</returns>
6885 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6886 public static float3 right() { return new float3(1.0f, 0.0f, 0.0f); }
6887
6888 /// <summary>
6889 /// Returns the Euler angle representation of the quaternion following the XYZ rotation order.
6890 /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
6891 /// </summary>
6892 /// <param name="q">The quaternion to convert to Euler angles.</param>
6893 /// <returns>The Euler angle representation of the quaternion in XYZ order.</returns>
6894 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6895 public static float3 EulerXYZ(quaternion q)
6896 {
6897 const float epsilon = 1e-6f;
6898 const float cutoff = (1f - 2f * epsilon) * (1f - 2f * epsilon);
6899
6900 // prepare the data
6901 var qv = q.value;
6902 var d1 = qv * qv.wwww * float4(2f); //xw, yw, zw, ww
6903 var d2 = qv * qv.yzxw * float4(2f); //xy, yz, zx, ww
6904 var d3 = qv * qv;
6905 var euler = Unity.Mathematics.float3.zero;
6906
6907 var y1 = d2.z - d1.y;
6908 if (y1 * y1 < cutoff)
6909 {
6910 var x1 = d2.y + d1.x;
6911 var x2 = d3.z + d3.w - d3.y - d3.x;
6912 var z1 = d2.x + d1.z;
6913 var z2 = d3.x + d3.w - d3.y - d3.z;
6914 euler = float3(atan2(x1, x2), -asin(y1), atan2(z1, z2));
6915 }
6916 else //xzx
6917 {
6918 y1 = clamp(y1, -1f, 1f);
6919 var abcd = float4(d2.z, d1.y, d2.x, d1.z);
6920 var x1 = 2f * (abcd.x * abcd.w + abcd.y * abcd.z); //2(ad+bc)
6921 var x2 = csum(abcd * abcd * float4(-1f, 1f, -1f, 1f));
6922 euler = float3(atan2(x1, x2), -asin(y1), 0f);
6923 }
6924
6925 return euler;
6926 }
6927
6928 /// <summary>
6929 /// Returns the Euler angle representation of the quaternion following the XZY rotation order.
6930 /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
6931 /// </summary>
6932 /// <param name="q">The quaternion to convert to Euler angles.</param>
6933 /// <returns>The Euler angle representation of the quaternion in XZY order.</returns>
6934 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6935 public static float3 EulerXZY(quaternion q)
6936 {
6937 const float epsilon = 1e-6f;
6938 const float cutoff = (1f - 2f * epsilon) * (1f - 2f * epsilon);
6939
6940 // prepare the data
6941 var qv = q.value;
6942 var d1 = qv * qv.wwww * float4(2f); //xw, yw, zw, ww
6943 var d2 = qv * qv.yzxw * float4(2f); //xy, yz, zx, ww
6944 var d3 = qv * qv;
6945 var euler = Unity.Mathematics.float3.zero;
6946
6947 var y1 = d2.x + d1.z;
6948 if (y1 * y1 < cutoff)
6949 {
6950 var x1 = -d2.y + d1.x;
6951 var x2 = d3.y + d3.w - d3.z - d3.x;
6952 var z1 = -d2.z + d1.y;
6953 var z2 = d3.x + d3.w - d3.y - d3.z;
6954 euler = float3(atan2(x1, x2), asin(y1), atan2(z1, z2));
6955 }
6956 else //xyx
6957 {
6958 y1 = clamp(y1, -1f, 1f);
6959 var abcd = float4(d2.x, d1.z, d2.z, d1.y);
6960 var x1 = 2f * (abcd.x * abcd.w + abcd.y * abcd.z); //2(ad+bc)
6961 var x2 = csum(abcd * abcd * float4(-1f, 1f, -1f, 1f));
6962 euler = float3(atan2(x1, x2), asin(y1), 0f);
6963 }
6964
6965 return euler.xzy;
6966 }
6967
6968 /// <summary>
6969 /// Returns the Euler angle representation of the quaternion following the YXZ rotation order.
6970 /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
6971 /// </summary>
6972 /// <param name="q">The quaternion to convert to Euler angles.</param>
6973 /// <returns>The Euler angle representation of the quaternion in YXZ order.</returns>
6974 [MethodImpl(MethodImplOptions.AggressiveInlining)]
6975 public static float3 EulerYXZ(quaternion q)
6976 {
6977 const float epsilon = 1e-6f;
6978 const float cutoff = (1f - 2f * epsilon) * (1f - 2f * epsilon);
6979
6980 // prepare the data
6981 var qv = q.value;
6982 var d1 = qv * qv.wwww * float4(2f); //xw, yw, zw, ww
6983 var d2 = qv * qv.yzxw * float4(2f); //xy, yz, zx, ww
6984 var d3 = qv * qv;
6985 var euler = Unity.Mathematics.float3.zero;
6986
6987 var y1 = d2.y + d1.x;
6988 if (y1 * y1 < cutoff)
6989 {
6990 var x1 = -d2.z + d1.y;
6991 var x2 = d3.z + d3.w - d3.x - d3.y;
6992 var z1 = -d2.x + d1.z;
6993 var z2 = d3.y + d3.w - d3.z - d3.x;
6994 euler = float3(atan2(x1, x2), asin(y1), atan2(z1, z2));
6995 }
6996 else //yzy
6997 {
6998 y1 = clamp(y1, -1f, 1f);
6999 var abcd = float4(d2.x, d1.z, d2.y, d1.x);
7000 var x1 = 2f * (abcd.x * abcd.w + abcd.y * abcd.z); //2(ad+bc)
7001 var x2 = csum(abcd * abcd * float4(-1f, 1f, -1f, 1f));
7002 euler = float3(atan2(x1, x2), asin(y1), 0f);
7003 }
7004
7005 return euler.yxz;
7006 }
7007
7008 /// <summary>
7009 /// Returns the Euler angle representation of the quaternion following the YZX rotation order.
7010 /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
7011 /// </summary>
7012 /// <param name="q">The quaternion to convert to Euler angles.</param>
7013 /// <returns>The Euler angle representation of the quaternion in YZX order.</returns>
7014 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7015 public static float3 EulerYZX(quaternion q)
7016 {
7017 const float epsilon = 1e-6f;
7018 const float cutoff = (1f - 2f * epsilon) * (1f - 2f * epsilon);
7019
7020 // prepare the data
7021 var qv = q.value;
7022 var d1 = qv * qv.wwww * float4(2f); //xw, yw, zw, ww
7023 var d2 = qv * qv.yzxw * float4(2f); //xy, yz, zx, ww
7024 var d3 = qv * qv;
7025 var euler = Unity.Mathematics.float3.zero;
7026
7027 var y1 = d2.x - d1.z;
7028 if (y1 * y1 < cutoff)
7029 {
7030 var x1 = d2.z + d1.y;
7031 var x2 = d3.x + d3.w - d3.z - d3.y;
7032 var z1 = d2.y + d1.x;
7033 var z2 = d3.y + d3.w - d3.x - d3.z;
7034 euler = float3(atan2(x1, x2), -asin(y1), atan2(z1, z2));
7035 }
7036 else //yxy
7037 {
7038 y1 = clamp(y1, -1f, 1f);
7039 var abcd = float4(d2.x, d1.z, d2.y, d1.x);
7040 var x1 = 2f * (abcd.x * abcd.w + abcd.y * abcd.z); //2(ad+bc)
7041 var x2 = csum(abcd * abcd * float4(-1f, 1f, -1f, 1f));
7042 euler = float3(atan2(x1, x2), -asin(y1), 0f);
7043 }
7044
7045 return euler.zxy;
7046 }
7047
7048 /// <summary>
7049 /// Returns the Euler angle representation of the quaternion following the ZXY rotation order.
7050 /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
7051 /// </summary>
7052 /// <param name="q">The quaternion to convert to Euler angles.</param>
7053 /// <returns>The Euler angle representation of the quaternion in ZXY order.</returns>
7054 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7055 public static float3 EulerZXY(quaternion q)
7056 {
7057 const float epsilon = 1e-6f;
7058 const float cutoff = (1f - 2f * epsilon) * (1f - 2f * epsilon);
7059
7060 // prepare the data
7061 var qv = q.value;
7062 var d1 = qv * qv.wwww * float4(2f); //xw, yw, zw, ww
7063 var d2 = qv * qv.yzxw * float4(2f); //xy, yz, zx, ww
7064 var d3 = qv * qv;
7065 var euler = Unity.Mathematics.float3.zero;
7066
7067 var y1 = d2.y - d1.x;
7068 if (y1 * y1 < cutoff)
7069 {
7070 var x1 = d2.x + d1.z;
7071 var x2 = d3.y + d3.w - d3.x - d3.z;
7072 var z1 = d2.z + d1.y;
7073 var z2 = d3.z + d3.w - d3.x - d3.y;
7074 euler = float3(atan2(x1, x2), -asin(y1), atan2(z1, z2));
7075 }
7076 else //zxz
7077 {
7078 y1 = clamp(y1, -1f, 1f);
7079 var abcd = float4(d2.z, d1.y, d2.y, d1.x);
7080 var x1 = 2f * (abcd.x * abcd.w + abcd.y * abcd.z); //2(ad+bc)
7081 var x2 = csum(abcd * abcd * float4(-1f, 1f, -1f, 1f));
7082 euler = float3(atan2(x1, x2), -asin(y1), 0f);
7083 }
7084
7085 return euler.yzx;
7086 }
7087
7088 /// <summary>
7089 /// Returns the Euler angle representation of the quaternion following the ZYX rotation order.
7090 /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
7091 /// </summary>
7092 /// <param name="q">The quaternion to convert to Euler angles.</param>
7093 /// <returns>The Euler angle representation of the quaternion in ZYX order.</returns>
7094 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7095 public static float3 EulerZYX(quaternion q)
7096 {
7097 const float epsilon = 1e-6f;
7098 const float cutoff = (1f - 2f * epsilon) * (1f - 2f * epsilon);
7099
7100 var qv = q.value;
7101 var d1 = qv * qv.wwww * float4(2f); //xw, yw, zw, ww
7102 var d2 = qv * qv.yzxw * float4(2f); //xy, yz, zx, ww
7103 var d3 = qv * qv;
7104 var euler = Unity.Mathematics.float3.zero;
7105
7106 var y1 = d2.z + d1.y;
7107 if (y1 * y1 < cutoff)
7108 {
7109 var x1 = -d2.x + d1.z;
7110 var x2 = d3.x + d3.w - d3.y - d3.z;
7111 var z1 = -d2.y + d1.x;
7112 var z2 = d3.z + d3.w - d3.y - d3.x;
7113 euler = float3(atan2(x1, x2), asin(y1), atan2(z1, z2));
7114 }
7115 else //zxz
7116 {
7117 y1 = clamp(y1, -1f, 1f);
7118 var abcd = float4(d2.z, d1.y, d2.y, d1.x);
7119 var x1 = 2f * (abcd.x * abcd.w + abcd.y * abcd.z); //2(ad+bc)
7120 var x2 = csum(abcd * abcd * float4(-1f, 1f, -1f, 1f));
7121 euler = float3(atan2(x1, x2), asin(y1), 0f);
7122 }
7123
7124 return euler.zyx;
7125 }
7126
7127 /// <summary>
7128 /// Returns the Euler angle representation of the quaternion. The returned angles depend on the specified order to apply the
7129 /// three rotations around the principal axes. All rotation angles are in radians and clockwise when looking along the
7130 /// rotation axis towards the origin.
7131 /// When the rotation order is known at compile time, to get the best performance you should use the specific
7132 /// Euler rotation constructors such as EulerZXY(...).
7133 /// </summary>
7134 /// <param name="q">The quaternion to convert to Euler angles.</param>
7135 /// <param name="order">The order in which the rotations are applied.</param>
7136 /// <returns>The Euler angle representation of the quaternion in the specified order.</returns>
7137 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7138 public static float3 Euler(quaternion q, math.RotationOrder order = math.RotationOrder.Default)
7139 {
7140 switch (order)
7141 {
7142 case math.RotationOrder.XYZ:
7143 return EulerXYZ(q);
7144 case math.RotationOrder.XZY:
7145 return EulerXZY(q);
7146 case math.RotationOrder.YXZ:
7147 return EulerYXZ(q);
7148 case math.RotationOrder.YZX:
7149 return EulerYZX(q);
7150 case math.RotationOrder.ZXY:
7151 return EulerZXY(q);
7152 case math.RotationOrder.ZYX:
7153 return EulerZYX(q);
7154 default:
7155 return Unity.Mathematics.float3.zero;
7156 }
7157 }
7158
7159 /// <summary>
7160 /// Matrix columns multiplied by scale components
7161 /// m.c0.x * s.x | m.c1.x * s.y | m.c2.x * s.z
7162 /// m.c0.y * s.x | m.c1.y * s.y | m.c2.y * s.z
7163 /// m.c0.z * s.x | m.c1.z * s.y | m.c2.z * s.z
7164 /// </summary>
7165 /// <param name="m">Matrix to scale.</param>
7166 /// <param name="s">Scaling coefficients for each column.</param>
7167 /// <returns>The scaled matrix.</returns>
7168 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7169 public static float3x3 mulScale(float3x3 m, float3 s) => new float3x3(m.c0 * s.x, m.c1 * s.y, m.c2 * s.z);
7170
7171 /// <summary>
7172 /// Matrix rows multiplied by scale components
7173 /// m.c0.x * s.x | m.c1.x * s.x | m.c2.x * s.x
7174 /// m.c0.y * s.y | m.c1.y * s.y | m.c2.y * s.y
7175 /// m.c0.z * s.z | m.c1.z * s.z | m.c2.z * s.z
7176 /// </summary>
7177 /// <param name="s">Scaling coefficients for each row.</param>
7178 /// <param name="m">Matrix to scale.</param>
7179 /// <returns>The scaled matrix.</returns>
7180 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7181 public static float3x3 scaleMul(float3 s, float3x3 m) => new float3x3(m.c0 * s, m.c1 * s, m.c2 * s);
7182
7183 // Internal
7184
7185 // SSE shuffles
7186 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7187 internal static float4 unpacklo(float4 a, float4 b)
7188 {
7189 return shuffle(a, b, ShuffleComponent.LeftX, ShuffleComponent.RightX, ShuffleComponent.LeftY, ShuffleComponent.RightY);
7190 }
7191
7192 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7193 internal static double4 unpacklo(double4 a, double4 b)
7194 {
7195 return shuffle(a, b, ShuffleComponent.LeftX, ShuffleComponent.RightX, ShuffleComponent.LeftY, ShuffleComponent.RightY);
7196 }
7197
7198 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7199 internal static float4 unpackhi(float4 a, float4 b)
7200 {
7201 return shuffle(a, b, ShuffleComponent.LeftZ, ShuffleComponent.RightZ, ShuffleComponent.LeftW, ShuffleComponent.RightW);
7202 }
7203
7204 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7205 internal static double4 unpackhi(double4 a, double4 b)
7206 {
7207 return shuffle(a, b, ShuffleComponent.LeftZ, ShuffleComponent.RightZ, ShuffleComponent.LeftW, ShuffleComponent.RightW);
7208 }
7209
7210
7211 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7212 internal static float4 movelh(float4 a, float4 b)
7213 {
7214 return shuffle(a, b, ShuffleComponent.LeftX, ShuffleComponent.LeftY, ShuffleComponent.RightX, ShuffleComponent.RightY);
7215 }
7216
7217 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7218 internal static double4 movelh(double4 a, double4 b)
7219 {
7220 return shuffle(a, b, ShuffleComponent.LeftX, ShuffleComponent.LeftY, ShuffleComponent.RightX, ShuffleComponent.RightY);
7221 }
7222
7223
7224 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7225 internal static float4 movehl(float4 a, float4 b)
7226 {
7227 return shuffle(b, a, ShuffleComponent.LeftZ, ShuffleComponent.LeftW, ShuffleComponent.RightZ, ShuffleComponent.RightW);
7228 }
7229
7230 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7231 internal static double4 movehl(double4 a, double4 b)
7232 {
7233 return shuffle(b, a, ShuffleComponent.LeftZ, ShuffleComponent.LeftW, ShuffleComponent.RightZ, ShuffleComponent.RightW);
7234 }
7235
7236 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7237 internal static uint fold_to_uint(double x) // utility for double hashing
7238 {
7239 LongDoubleUnion u;
7240 u.longValue = 0;
7241 u.doubleValue = x;
7242 return (uint)(u.longValue >> 32) ^ (uint)u.longValue;
7243 }
7244
7245 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7246 internal static uint2 fold_to_uint(double2 x) { return uint2(fold_to_uint(x.x), fold_to_uint(x.y)); }
7247 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7248 internal static uint3 fold_to_uint(double3 x) { return uint3(fold_to_uint(x.x), fold_to_uint(x.y), fold_to_uint(x.z)); }
7249 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7250 internal static uint4 fold_to_uint(double4 x) { return uint4(fold_to_uint(x.x), fold_to_uint(x.y), fold_to_uint(x.z), fold_to_uint(x.w)); }
7251
7252 [StructLayout(LayoutKind.Explicit)]
7253 internal struct LongDoubleUnion
7254 {
7255 [FieldOffset(0)]
7256 public long longValue;
7257 [FieldOffset(0)]
7258 public double doubleValue;
7259 }
7260 }
7261}