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