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

545 lines
22 KiB
C#

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