This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit b578433e37
8 changed files with 784842 additions and 0 deletions

View file

@ -0,0 +1,28 @@
// <auto-generated /> - edit Vector.copy.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct ulong4
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void CopyTo(Span<ulong> destination)
{
if (destination.Length < ComponentCount)
throw new ArgumentException("Length must be at least 4.", nameof(destination));
Unsafe.WriteUnaligned(ref Unsafe.As<ulong, byte>(ref MemoryMarshal.GetReference(destination)), this);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool TryCopyTo(Span<ulong> destination)
{
if (destination.Length < ComponentCount)
return false;
Unsafe.WriteUnaligned(ref Unsafe.As<ulong, byte>(ref MemoryMarshal.GetReference(destination)), this);
return true;
}
}

View file

@ -0,0 +1,41 @@
// <auto-generated /> - edit Vector.equality.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct ulong4
{
/// <inheritdoc />
public readonly override int GetHashCode()
{
return HashCode.Combine(X, Y, Z, W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(ulong4 other)
{
return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z) && W.Equals(other.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is ulong4 other && Equals(other);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(ulong4 a, ulong4 b)
{
return a.X == b.X && a.Y == b.Y && a.Z == b.Z && a.W == b.W;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(ulong4 a, ulong4 b)
{
return !(a == b);
}
}

View file

@ -0,0 +1,92 @@
// <auto-generated /> - edit Vector.format.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct ulong4 : ISpanFormattable, IUtf8SpanFormattable, ISpanParsable<ulong4>
{
/// <inheritdoc />
public readonly override string ToString()
{
return ToString("G", CultureInfo.CurrentCulture);
}
/// <inheritdoc cref="Vector4.ToString(string?)" />
public readonly string ToString(string? format)
{
return ToString(format, CultureInfo.CurrentCulture);
}
/// <inheritdoc />
public readonly string ToString(string? format, IFormatProvider? formatProvider)
{
var separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
return $"<{X.ToString(format, formatProvider)}{separator} {Y.ToString(format, formatProvider)}{separator} {Z.ToString(format, formatProvider)}{separator} {W.ToString(format, formatProvider)}>";
}
/// <inheritdoc />
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<ulong4, ulong>(this, destination, out charsWritten, format, provider);
}
/// <inheritdoc />
public readonly bool TryFormat(Span<byte> destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<ulong4, ulong>(this, destination, out bytesWritten, format, provider);
}
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
public static ulong4 Parse(string s, IFormatProvider? provider)
{
ArgumentNullException.ThrowIfNull(s);
return Parse(s.AsSpan(), NumberStyles.Integer, provider);
}
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
public static ulong4 Parse(ReadOnlySpan<char> s, IFormatProvider? provider = null)
{
return Parse(s, NumberStyles.Integer, provider);
}
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
public static ulong4 Parse(string s, NumberStyles style, IFormatProvider? provider)
{
ArgumentNullException.ThrowIfNull(s);
return Parse(s.AsSpan(), style, provider);
}
/// <summary>Parses from the <see cref="ToString()" /> format, <c>&lt;1, 2, 3&gt;</c>.</summary>
/// <exception cref="FormatException">The input is not in a valid format, or a component fails to parse.</exception>
public static ulong4 Parse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider)
{
if (!TryParse(s, style, provider, out var result))
throw new FormatException($"'{s}' is not in a valid ulong4 format.");
return result;
}
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out ulong4)" />
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out ulong4 result)
{
return TryParse(s.AsSpan(), NumberStyles.Integer, provider, out result);
}
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out ulong4)" />
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out ulong4 result)
{
return TryParse(s, NumberStyles.Integer, provider, out result);
}
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out ulong4)" />
public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out ulong4 result)
{
return TryParse(s.AsSpan(), style, provider, out result);
}
/// <summary>Parses from the <see cref="ToString()" /> format, <c>&lt;1, 2, 3&gt;</c>.</summary>
/// <returns>true if the input parsed as a ulong4.</returns>
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out ulong4 result)
{
return StringHelpers.TryParse<ulong4, ulong>(s, style, provider, out result);
}
}

View file

@ -0,0 +1,147 @@
// <auto-generated /> - edit Vector.tt to modify
#nullable enable
namespace Brutal.Numerics;
/// <summary>
/// Implements a 4D vector with ulong components.
/// </summary>
[DebuggerTypeProxy(typeof(VectorDebugView4<ulong4, ulong, double>))]
public partial struct ulong4 : IVector4<ulong4, ulong>
, IIntegerVector<ulong4, ulong, ulong, double>
{
/// <inheritdoc />
public static int ComponentSize => sizeof(ulong);
/// <summary>Gets the number of components.</summary>
public static int ComponentCount => 4;
/// <inheritdoc cref="Vector4.X" />
[XmlAttribute]
public ulong X;
/// <inheritdoc cref="Vector4.Y" />
[XmlAttribute]
public ulong Y;
/// <inheritdoc cref="Vector4.Z" />
[XmlAttribute]
public ulong Z;
/// <inheritdoc cref="Vector4.W" />
[XmlAttribute]
public ulong W;
ulong IVector4<ulong4, ulong>.X { readonly get => X; set => X = value; }
ulong IVector4<ulong4, ulong>.Y { readonly get => Y; set => Y = value; }
ulong IVector4<ulong4, ulong>.Z { readonly get => Z; set => Z = value; }
ulong IVector4<ulong4, ulong>.W { readonly get => W; set => W = value; }
/// <inheritdoc cref="Vector4(float, float, float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ulong4(ulong x, ulong y, ulong z, ulong w)
{
X = x;
Y = y;
Z = z;
W = w;
}
/// <inheritdoc cref="Vector4(float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ulong4(ulong xyzw)
: this(xyzw, xyzw, xyzw, xyzw) { }
/// <inheritdoc cref="Vector4(Vector3, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ulong4(ulong3 xyz, ulong w)
: this(xyz.X, xyz.Y, xyz.Z, w) { }
/// <summary>
/// Creates a new instance of <see cref="ulong4" /> from two <see cref="ulong2" /> instances.
/// </summary>
/// <param name="xy">The first two components.</param>
/// <param name="zw">The last two components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ulong4(ulong2 xy, ulong2 zw)
: this(xy.X, xy.Y, zw.X, zw.Y) { }
/// <inheritdoc cref="Vector4(Vector2, float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ulong4(ulong2 xy, ulong z, ulong w)
: this(xy.X, xy.Y, z, w) { }
/// <summary>Creates a vector from the leading 4 elements of a span.</summary>
/// <param name="span">The elements to read; must contain at least 4, and any beyond that are ignored.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="span" /> holds fewer than 4 elements.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ulong4(ReadOnlySpan<ulong> span)
{
if (span.Length < 4)
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 4.");
this = Unsafe.ReadUnaligned<ulong4>(ref Unsafe.As<ulong, byte>(ref MemoryMarshal.GetReference(span)));
}
/// <inheritdoc cref="ulong4(ReadOnlySpan{ulong})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static ulong4 IComponentTuple<ulong4, ulong>.Create(ReadOnlySpan<ulong> span) => new(span);
/// <inheritdoc />
public static ulong4 UnitX => new(1, 0, 0, 0);
/// <inheritdoc />
public static ulong4 UnitY => new(0, 1, 0, 0);
/// <inheritdoc />
public static ulong4 UnitZ => new(0, 0, 1, 0);
/// <inheritdoc />
public static ulong4 UnitW => new(0, 0, 0, 1);
/// <inheritdoc />
public ulong this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
return Unsafe.Add(ref Unsafe.AsRef(in X), index);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
Unsafe.Add(ref X, index) = value;
}
}
public readonly void Deconstruct(out ulong x, out ulong y, out ulong z, out ulong w)
{
x = X;
y = Y;
z = Z;
w = W;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<ulong> AsSpan()
{
return MemoryMarshal.CreateSpan(ref Unsafe.As<ulong4, ulong>(ref this), 4);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ReadOnlySpan<ulong> AsReadOnlySpan()
{
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<ulong4, ulong>(ref Unsafe.AsRef(in this)), 4);
}
}

View file

@ -0,0 +1,42 @@
// <auto-generated /> - edit Vector.math-metric.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct ulong4
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly double Length()
{
return (double)double.Sqrt((double)X * X + (double)Y * Y + (double)Z * Z + (double)W * W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ulong LengthSquared()
{
return Dot(this, this);
}
/// <inheritdoc cref="Vector4.Distance" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double Distance(ulong4 a, ulong4 b)
{
return (double)double.Sqrt(((double)a.X - b.X) * ((double)a.X - b.X) + ((double)a.Y - b.Y) * ((double)a.Y - b.Y) + ((double)a.Z - b.Z) * ((double)a.Z - b.Z) + ((double)a.W - b.W) * ((double)a.W - b.W));
}
/// <inheritdoc cref="Vector4.DistanceSquared" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong DistanceSquared(ulong4 a, ulong4 b)
{
return (a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y) + (a.Z - b.Z) * (a.Z - b.Z) + (a.W - b.W) * (a.W - b.W);
}
/// <inheritdoc cref="Vector4.Dot" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong Dot(ulong4 a, ulong4 b)
{
return a.X * b.X + a.Y * b.Y + a.Z * b.Z + a.W * b.W;
}
}

View file

@ -0,0 +1,100 @@
// <auto-generated /> - edit Vector.numerics-binary.tt to modify
#nullable enable
namespace Brutal.Numerics;
// IBinaryNumber
public partial struct ulong4 : IBinaryNumber<ulong4>
{
/// <summary>Determines if every component of a value is a power of two.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool IBinaryNumber<ulong4>.IsPow2(ulong4 value)
{
return ulong.IsPow2(value.X) && ulong.IsPow2(value.Y) && ulong.IsPow2(value.Z) && ulong.IsPow2(value.W);
}
/// <inheritdoc cref="IBinaryNumber{TSelf}.Log2" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Log2(ulong4 value)
{
return new ulong4(ulong.Log2(value.X), ulong.Log2(value.Y), ulong.Log2(value.Z), ulong.Log2(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator &(ulong4 a, ulong4 b)
{
return new(a.X & b.X, a.Y & b.Y, a.Z & b.Z, a.W & b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator |(ulong4 a, ulong4 b)
{
return new(a.X | b.X, a.Y | b.Y, a.Z | b.Z, a.W | b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator ^(ulong4 a, ulong4 b)
{
return new(a.X ^ b.X, a.Y ^ b.Y, a.Z ^ b.Z, a.W ^ b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator ~(ulong4 value)
{
return new(~value.X, ~value.Y, ~value.Z, ~value.W);
}
}
// the componentwise predicate mask (no interface to mirror) - the per-lane truth IsPow2 collapses
public partial struct ulong4
{
/// <summary>Determines which components of a value are powers of two.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsPow2(ulong4 value)
{
return new bool4(ulong.IsPow2(value.X), ulong.IsPow2(value.Y), ulong.IsPow2(value.Z), ulong.IsPow2(value.W));
}
}
// the good bits from IBinaryInteger - declared on IIntegerVector
public partial struct ulong4
{
/// <inheritdoc cref="IBinaryInteger{TSelf}.PopCount" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 PopCount(ulong4 value)
{
return new ulong4(ulong.PopCount(value.X), ulong.PopCount(value.Y), ulong.PopCount(value.Z), ulong.PopCount(value.W));
}
/// <inheritdoc cref="IBinaryInteger{TSelf}.LeadingZeroCount" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 LeadingZeroCount(ulong4 value)
{
return new ulong4(ulong.LeadingZeroCount(value.X), ulong.LeadingZeroCount(value.Y), ulong.LeadingZeroCount(value.Z), ulong.LeadingZeroCount(value.W));
}
/// <inheritdoc cref="IBinaryInteger{TSelf}.TrailingZeroCount" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 TrailingZeroCount(ulong4 value)
{
return new ulong4(ulong.TrailingZeroCount(value.X), ulong.TrailingZeroCount(value.Y), ulong.TrailingZeroCount(value.Z), ulong.TrailingZeroCount(value.W));
}
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateLeft" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 RotateLeft(ulong4 value, int rotateAmount)
{
return new ulong4(ulong.RotateLeft(value.X, rotateAmount), ulong.RotateLeft(value.Y, rotateAmount), ulong.RotateLeft(value.Z, rotateAmount), ulong.RotateLeft(value.W, rotateAmount));
}
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateRight" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 RotateRight(ulong4 value, int rotateAmount)
{
return new ulong4(ulong.RotateRight(value.X, rotateAmount), ulong.RotateRight(value.Y, rotateAmount), ulong.RotateRight(value.Z, rotateAmount), ulong.RotateRight(value.W, rotateAmount));
}
}

View file

@ -0,0 +1,389 @@
// <auto-generated /> - edit Vector.numerics.tt to modify
#nullable enable
namespace Brutal.Numerics;
// INumberBase
public partial struct ulong4 : INumberBase<ulong4>
{
/// <inheritdoc />
public static ulong4 Zero => new(0);
/// <inheritdoc />
public static ulong4 One => new(1);
static ulong4 IAdditiveIdentity<ulong4, ulong4>.AdditiveIdentity => Zero;
static ulong4 IMultiplicativeIdentity<ulong4, ulong4>.MultiplicativeIdentity => One;
static int INumberBase<ulong4>.Radix => 2; // every component type is binary
static ulong4 INumberBase<ulong4>.Abs(ulong4 value) => value;
static bool INumberBase<ulong4>.IsCanonical(ulong4 value) => true;
static bool INumberBase<ulong4>.IsComplexNumber(ulong4 value) => false;
static bool INumberBase<ulong4>.IsImaginaryNumber(ulong4 value) => false;
/// <summary>Determines if every component of a value is zero.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<ulong4>.IsZero(ulong4 value)
{
return value == Zero;
}
/// <summary>Determines if every component of a value is an even integral value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<ulong4>.IsEvenInteger(ulong4 value)
{
return (value.X & 1) == 0 && (value.Y & 1) == 0 && (value.Z & 1) == 0 && (value.W & 1) == 0;
}
/// <summary>Determines if every component of a value is an odd integral value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<ulong4>.IsOddInteger(ulong4 value)
{
return (value.X & 1) == 1 && (value.Y & 1) == 1 && (value.Z & 1) == 1 && (value.W & 1) == 1;
}
static bool INumberBase<ulong4>.IsNegative(ulong4 value) => false;
static bool INumberBase<ulong4>.IsPositive(ulong4 value) => true;
static bool INumberBase<ulong4>.IsFinite(ulong4 value) => true;
static bool INumberBase<ulong4>.IsInfinity(ulong4 value) => false;
static bool INumberBase<ulong4>.IsNegativeInfinity(ulong4 value) => false;
static bool INumberBase<ulong4>.IsPositiveInfinity(ulong4 value) => false;
static bool INumberBase<ulong4>.IsInteger(ulong4 value) => true;
static bool INumberBase<ulong4>.IsRealNumber(ulong4 value) => true;
static bool INumberBase<ulong4>.IsNaN(ulong4 value) => false;
static bool INumberBase<ulong4>.IsNormal(ulong4 value) => value.X != 0 && value.Y != 0 && value.Z != 0 && value.W != 0;
static bool INumberBase<ulong4>.IsSubnormal(ulong4 value) => false;
/// <summary>Computes, componentwise, the value whose magnitude is greater.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 MaxMagnitude(ulong4 a, ulong4 b)
{
return Max(a, b);
}
/// <summary>Computes, componentwise, the value whose magnitude is greater.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 MaxMagnitudeNumber(ulong4 a, ulong4 b)
{
return Max(a, b);
}
/// <summary>Computes, componentwise, the value whose magnitude is smaller.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 MinMagnitude(ulong4 a, ulong4 b)
{
return Min(a, b);
}
/// <summary>Computes, componentwise, the value whose magnitude is smaller.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 MinMagnitudeNumber(ulong4 a, ulong4 b)
{
return Min(a, b);
}
/// <inheritdoc cref="Vector4.Add" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Add(ulong4 a, ulong4 b)
{
return a + b;
}
/// <inheritdoc cref="Vector4.Divide(Vector4, Vector4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Divide(ulong4 a, ulong4 b)
{
return a / b;
}
/// <inheritdoc cref="Vector4.Multiply(Vector4, Vector4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Multiply(ulong4 a, ulong4 b)
{
return a * b;
}
/// <inheritdoc cref="Vector4.Negate" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Negate(ulong4 value)
{
return -value;
}
/// <inheritdoc cref="Vector4.Subtract" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Subtract(ulong4 a, ulong4 b)
{
return a - b;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator +(ulong4 a, ulong4 b)
{
return new(a.X + b.X, a.Y + b.Y, a.Z + b.Z, a.W + b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator -(ulong4 a, ulong4 b)
{
return new(a.X - b.X, a.Y - b.Y, a.Z - b.Z, a.W - b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator *(ulong4 a, ulong4 b)
{
return new(a.X * b.X, a.Y * b.Y, a.Z * b.Z, a.W * b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator /(ulong4 a, ulong4 b)
{
return new(a.X / b.X, a.Y / b.Y, a.Z / b.Z, a.W / b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator -(ulong4 a)
{
return new(0 - a.X, 0 - a.Y, 0 - a.Z, 0 - a.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator +(ulong4 a)
{
return a;
}
// ++/-- are well-defined (+/- One) but a footgun on a concrete vector: generic-plane only.
static ulong4 IIncrementOperators<ulong4>.operator ++(ulong4 value) => value + One;
static ulong4 IDecrementOperators<ulong4>.operator --(ulong4 value) => value - One;
static bool INumberBase<ulong4>.TryConvertFromChecked<TOther>(TOther value, out ulong4 result)
{
return NumberConversion.TryConvertFrom<ulong4, ulong, TOther, NumberConversion.Checked>(value, out result);
}
static bool INumberBase<ulong4>.TryConvertToChecked<TOther>(ulong4 value, [MaybeNullWhen(false)] out TOther result)
{
result = default;
return false;
}
static bool INumberBase<ulong4>.TryConvertFromSaturating<TOther>(TOther value, out ulong4 result)
{
return NumberConversion.TryConvertFrom<ulong4, ulong, TOther, NumberConversion.Saturating>(value, out result);
}
static bool INumberBase<ulong4>.TryConvertToSaturating<TOther>(ulong4 value, [MaybeNullWhen(false)] out TOther result)
{
result = default;
return false;
}
static bool INumberBase<ulong4>.TryConvertFromTruncating<TOther>(TOther value, out ulong4 result)
{
return NumberConversion.TryConvertFrom<ulong4, ulong, TOther, NumberConversion.Truncating>(value, out result);
}
static bool INumberBase<ulong4>.TryConvertToTruncating<TOther>(ulong4 value, [MaybeNullWhen(false)] out TOther result)
{
result = default;
return false;
}
}
// IMultiplyOperators<TSelf, TComponent, TSelf>, IDivisionOperators<TSelf, TComponent, TSelf>
public partial struct ulong4
: IMultiplyOperators<ulong4, ulong, ulong4>
, IDivisionOperators<ulong4, ulong, ulong4>
{
/// <inheritdoc cref="Vector4.Divide(Vector4, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Divide(ulong4 a, ulong b)
{
return a / b;
}
/// <inheritdoc cref="Vector4.Multiply(Vector4, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Multiply(ulong4 a, ulong b)
{
return a * b;
}
/// <inheritdoc cref="Vector4.Multiply(float, Vector4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Multiply(ulong a, ulong4 b)
{
return a * b;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator *(ulong4 a, ulong b)
{
return new(a.X * b, a.Y * b, a.Z * b, a.W * b);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator /(ulong4 a, ulong b)
{
return new(a.X / b, a.Y / b, a.Z / b, a.W / b);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator *(ulong a, ulong4 b)
{
return new(a * b.X, a * b.Y, a * b.Z, a * b.W);
}
}
// INumber
public partial struct ulong4 : INumber<ulong4>
{
/// <inheritdoc cref="Vector4.Clamp" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Clamp(ulong4 value, ulong4 min, ulong4 max)
{
// HLSL contract when min > max: max wins (clamp is Max-then-Min); pinned in
// Clamp_InvertedBounds_MatchesBcl. NOT scalar T.Clamp, which throws on inversion.
return Min(Max(value, min), max);
}
/// <inheritdoc cref="Vector4.Max" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Max(ulong4 a, ulong4 b)
{
return new(ulong.Max(a.X, b.X), ulong.Max(a.Y, b.Y), ulong.Max(a.Z, b.Z), ulong.Max(a.W, b.W));
}
/// <inheritdoc cref="Vector4.Min" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 Min(ulong4 a, ulong4 b)
{
return new(ulong.Min(a.X, b.X), ulong.Min(a.Y, b.Y), ulong.Min(a.Z, b.Z), ulong.Min(a.W, b.W));
}
static ulong4 INumber<ulong4>.MaxNumber(ulong4 a, ulong4 b) => Max(a, b);
static ulong4 INumber<ulong4>.MinNumber(ulong4 a, ulong4 b) => Min(a, b);
static ulong4 INumber<ulong4>.CopySign(ulong4 value, ulong4 sign) => value;
// the Native variants permit either NaN/signed-zero behavior - forwarding is always legal
static ulong4 INumber<ulong4>.ClampNative(ulong4 value, ulong4 min, ulong4 max) => Clamp(value, min, max);
static ulong4 INumber<ulong4>.MaxNative(ulong4 a, ulong4 b) => Max(a, b);
static ulong4 INumber<ulong4>.MinNative(ulong4 a, ulong4 b) => Min(a, b);
// Sign's int return cannot hold a per-lane answer, and a collapsed one would lie for mixed signs
static int INumber<ulong4>.Sign(ulong4 value) =>
throw new NotSupportedException($"{nameof(ulong4)} has no scalar sign.");
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong4 operator %(ulong4 a, ulong4 b)
{
return new ulong4(a.X % b.X, a.Y % b.Y, a.Z % b.Z, a.W % b.W);
}
int IComparable.CompareTo(object? obj) =>
throw new NotSupportedException($"{nameof(ulong4)} has no total order.");
int IComparable<ulong4>.CompareTo(ulong4 other) =>
throw new NotSupportedException($"{nameof(ulong4)} has no total order.");
static bool IComparisonOperators<ulong4, ulong4, bool>.operator <(ulong4 a, ulong4 b) =>
throw new NotSupportedException($"{nameof(ulong4)} has no total order.");
static bool IComparisonOperators<ulong4, ulong4, bool>.operator <=(ulong4 a, ulong4 b) =>
throw new NotSupportedException($"{nameof(ulong4)} has no total order.");
static bool IComparisonOperators<ulong4, ulong4, bool>.operator >(ulong4 a, ulong4 b) =>
throw new NotSupportedException($"{nameof(ulong4)} has no total order.");
static bool IComparisonOperators<ulong4, ulong4, bool>.operator >=(ulong4 a, ulong4 b) =>
throw new NotSupportedException($"{nameof(ulong4)} has no total order.");
}
// IComponentwiseComparison + the componentwise predicate masks (no interface to mirror)
public partial struct ulong4 : IComponentwiseComparison<ulong4, bool4>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 operator <(ulong4 a, ulong4 b)
{
return new bool4(a.X < b.X, a.Y < b.Y, a.Z < b.Z, a.W < b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 operator <=(ulong4 a, ulong4 b)
{
return new bool4(a.X <= b.X, a.Y <= b.Y, a.Z <= b.Z, a.W <= b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 operator >(ulong4 a, ulong4 b)
{
return new bool4(a.X > b.X, a.Y > b.Y, a.Z > b.Z, a.W > b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 operator >=(ulong4 a, ulong4 b)
{
return new bool4(a.X >= b.X, a.Y >= b.Y, a.Z >= b.Z, a.W >= b.W);
}
/// <summary>Determines which components of a value are zero.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsZero(ulong4 value)
{
return new bool4(value.X == 0, value.Y == 0, value.Z == 0, value.W == 0);
}
/// <summary>Determines which components of a value are an even integral value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsEvenInteger(ulong4 value)
{
return new bool4(ulong.IsEvenInteger(value.X), ulong.IsEvenInteger(value.Y), ulong.IsEvenInteger(value.Z), ulong.IsEvenInteger(value.W));
}
/// <summary>Determines which components of a value are an odd integral value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsOddInteger(ulong4 value)
{
return new bool4(ulong.IsOddInteger(value.X), ulong.IsOddInteger(value.Y), ulong.IsOddInteger(value.Z), ulong.IsOddInteger(value.W));
}
}
// IUnsignedNumber - a marker, so there is nothing to implement
public partial struct ulong4 : IUnsignedNumber<ulong4>;

File diff suppressed because it is too large Load diff