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