// - edit Vector.numerics-binary.tt to modify
#nullable enable
namespace Brutal.Numerics;
// IBinaryNumber
public partial struct byte4 : IBinaryNumber
{
/// Determines if every component of a value is a power of two.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool IBinaryNumber.IsPow2(byte4 value)
{
return byte.IsPow2(value.X) && byte.IsPow2(value.Y) && byte.IsPow2(value.Z) && byte.IsPow2(value.W);
}
///
[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));
}
///
[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));
}
///
[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));
}
///
[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));
}
///
[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
{
/// Determines which components of a value are powers of two.
[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
{
///
[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));
}
///
[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));
}
///
[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));
}
///
[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));
}
///
[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));
}
}