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