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 byte2 : IBinaryNumber<byte2>
|
|
{
|
|
/// <summary>Determines if every component of a value is a power of two.</summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
static bool IBinaryNumber<byte2>.IsPow2(byte2 value)
|
|
{
|
|
return byte.IsPow2(value.X) && byte.IsPow2(value.Y);
|
|
}
|
|
|
|
/// <inheritdoc cref="IBinaryNumber{TSelf}.Log2" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static byte2 Log2(byte2 value)
|
|
{
|
|
return new byte2(byte.Log2(value.X), byte.Log2(value.Y));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static byte2 operator &(byte2 a, byte2 b)
|
|
{
|
|
return new((byte)(a.X & b.X), (byte)(a.Y & b.Y));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static byte2 operator |(byte2 a, byte2 b)
|
|
{
|
|
return new((byte)(a.X | b.X), (byte)(a.Y | b.Y));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static byte2 operator ^(byte2 a, byte2 b)
|
|
{
|
|
return new((byte)(a.X ^ b.X), (byte)(a.Y ^ b.Y));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static byte2 operator ~(byte2 value)
|
|
{
|
|
return new((byte)(~value.X), (byte)(~value.Y));
|
|
}
|
|
}
|
|
|
|
// the componentwise predicate mask (no interface to mirror) - the per-lane truth IsPow2 collapses
|
|
public partial struct byte2
|
|
{
|
|
/// <summary>Determines which components of a value are powers of two.</summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool2 IsPow2(byte2 value)
|
|
{
|
|
return new bool2(byte.IsPow2(value.X), byte.IsPow2(value.Y));
|
|
}
|
|
}
|
|
|
|
// the good bits from IBinaryInteger - declared on IIntegerVector
|
|
public partial struct byte2
|
|
{
|
|
/// <inheritdoc cref="IBinaryInteger{TSelf}.PopCount" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static byte2 PopCount(byte2 value)
|
|
{
|
|
return new byte2(byte.PopCount(value.X), byte.PopCount(value.Y));
|
|
}
|
|
|
|
/// <inheritdoc cref="IBinaryInteger{TSelf}.LeadingZeroCount" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static byte2 LeadingZeroCount(byte2 value)
|
|
{
|
|
return new byte2(byte.LeadingZeroCount(value.X), byte.LeadingZeroCount(value.Y));
|
|
}
|
|
|
|
/// <inheritdoc cref="IBinaryInteger{TSelf}.TrailingZeroCount" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static byte2 TrailingZeroCount(byte2 value)
|
|
{
|
|
return new byte2(byte.TrailingZeroCount(value.X), byte.TrailingZeroCount(value.Y));
|
|
}
|
|
|
|
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateLeft" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static byte2 RotateLeft(byte2 value, int rotateAmount)
|
|
{
|
|
return new byte2(byte.RotateLeft(value.X, rotateAmount), byte.RotateLeft(value.Y, rotateAmount));
|
|
}
|
|
|
|
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateRight" />
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static byte2 RotateRight(byte2 value, int rotateAmount)
|
|
{
|
|
return new byte2(byte.RotateRight(value.X, rotateAmount), byte.RotateRight(value.Y, rotateAmount));
|
|
}
|
|
}
|