mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 12:38:24 +01:00
100 lines
3.3 KiB
C#
100 lines
3.3 KiB
C#
// <auto-generated /> - edit Vector.numerics-binary.tt to modify
|
|
#nullable enable
|
|
|
|
namespace Brutal.Numerics;
|
|
|
|
// IBinaryNumber
|
|
public partial struct uint2 : IBinaryNumber<uint2>
|
|
{
|
|
/// <summary>Determines if every component of a value is a power of two.</summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
static bool IBinaryNumber<uint2>.IsPow2(uint2 value)
|
|
{
|
|
return uint.IsPow2(value.X) && uint.IsPow2(value.Y);
|
|
}
|
|
|
|
/// <inheritdoc cref="IBinaryNumber{TSelf}.Log2" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static uint2 Log2(uint2 value)
|
|
{
|
|
return new uint2(uint.Log2(value.X), uint.Log2(value.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 value)
|
|
{
|
|
return new(~value.X, ~value.Y);
|
|
}
|
|
}
|
|
|
|
// the componentwise predicate mask (no interface to mirror) - the per-lane truth IsPow2 collapses
|
|
public partial struct uint2
|
|
{
|
|
/// <summary>Determines which components of a value are powers of two.</summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool2 IsPow2(uint2 value)
|
|
{
|
|
return new bool2(uint.IsPow2(value.X), uint.IsPow2(value.Y));
|
|
}
|
|
}
|
|
|
|
// the good bits from IBinaryInteger - declared on IIntegerVector
|
|
public partial struct uint2
|
|
{
|
|
/// <inheritdoc cref="IBinaryInteger{TSelf}.PopCount" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static uint2 PopCount(uint2 value)
|
|
{
|
|
return new uint2(uint.PopCount(value.X), uint.PopCount(value.Y));
|
|
}
|
|
|
|
/// <inheritdoc cref="IBinaryInteger{TSelf}.LeadingZeroCount" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static uint2 LeadingZeroCount(uint2 value)
|
|
{
|
|
return new uint2(uint.LeadingZeroCount(value.X), uint.LeadingZeroCount(value.Y));
|
|
}
|
|
|
|
/// <inheritdoc cref="IBinaryInteger{TSelf}.TrailingZeroCount" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static uint2 TrailingZeroCount(uint2 value)
|
|
{
|
|
return new uint2(uint.TrailingZeroCount(value.X), uint.TrailingZeroCount(value.Y));
|
|
}
|
|
|
|
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateLeft" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static uint2 RotateLeft(uint2 value, int rotateAmount)
|
|
{
|
|
return new uint2(uint.RotateLeft(value.X, rotateAmount), uint.RotateLeft(value.Y, rotateAmount));
|
|
}
|
|
|
|
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateRight" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static uint2 RotateRight(uint2 value, int rotateAmount)
|
|
{
|
|
return new uint2(uint.RotateRight(value.X, rotateAmount), uint.RotateRight(value.Y, rotateAmount));
|
|
}
|
|
}
|