brutal/Brutal.Numerics/Vector/uint2/uint2.numerics.gen.cs
Rian Drake b578433e37 first
2026-10-15 17:10:50 +13:00

389 lines
13 KiB
C#

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