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