This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit b578433e37
313 changed files with 784842 additions and 0 deletions

View file

@ -0,0 +1,610 @@
// ReSharper disable InconsistentNaming
namespace Brutal.Numerics;
/// <summary>Shape shared by every numerics value: a fixed-width run of identically-typed components.</summary>
/* Non-generic, so shape can be asked about without naming a component type. Says nothing about
* vectors or numbers - a matrix, a plane and a rect are component tuples too. */
public interface IComponentTuple
{
/// <summary>Gets the stride of one component in bytes.</summary>
static abstract int ComponentSize { get; }
/// <summary>Gets the number of components.</summary>
static abstract int ComponentCount { get; }
}
/// <inheritdoc cref="IComponentTuple" />
/// <typeparam name="T">The component type.</typeparam>
public interface IComponentTuple<T> : IComponentTuple
{
/// <summary>Gets or sets the element at the specified index.</summary>
/// <param name="index">The index of the element to get or set.</param>
/// <returns>The element at <paramref name="index" />.</returns>
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="index" /> was less than zero or greater than the number
/// of elements.
/// </exception>
T this[int index] { get; set; }
/// <summary>A mutable view over the components.</summary>
/// <remarks>
/// Deliberately NOT a readonly member, because it hands out a writable view. The consequence is that
/// calling it on a readonly field or an <see langword="in" /> parameter gets you a span over a
/// defensive COPY, so writes there are silently lost - reach for <see cref="AsReadOnlySpan" /> instead.
/// </remarks>
Span<T> AsSpan();
/// <summary>A read-only view over the components, safe in the readonly contexts where <see cref="AsSpan" /> would view a copy.</summary>
ReadOnlySpan<T> AsReadOnlySpan();
/// <summary>
/// Copies the vector to the given <see cref="Span{T}" />.The length of the destination span must be at least
/// as long as there are elements in the source vector.
/// </summary>
/// <param name="destination">The destination span which the values are copied into.</param>
/// <exception cref="ArgumentException">
/// If number of elements in source vector is greater than those available in
/// destination span.
/// </exception>
void CopyTo(Span<T> destination);
/// <summary>
/// Attempts to copy the vector to the given <see cref="Span{Single}" />. The length of the destination span must
/// be at least as long as there are elements in the source vector.
/// </summary>
/// <param name="destination">The destination span which the values are copied into.</param>
/// <returns>
/// <see langword="true" /> if the source vector was successfully copied to <paramref name="destination" />.
/// <see langword="false" /> if <paramref name="destination" /> is not large enough to hold the source vector.
/// </returns>
bool TryCopyTo(Span<T> destination);
}
/// <inheritdoc cref="IComponentTuple{T}" />
/// <typeparam name="TSelf">The type that implements the interface.</typeparam>
/// <typeparam name="T">The component type.</typeparam>
/* The rung where a component tuple knows its own type, so it can be constructed and compared.
* Everything above this point is layout and says nothing about being a vector. */
public interface IComponentTuple<TSelf, T> : IComponentTuple<T>, IEquatable<TSelf>, IFormattable
where TSelf : IComponentTuple<TSelf, T>
{
/// <summary>Constructs a value from the leading components of a span.</summary>
/// <param name="span">A span of at least <see cref="IComponentTuple.ComponentCount" /> components.</param>
static abstract TSelf Create(ReadOnlySpan<T> span);
}
/* ---------------------------------------------------------------------------
* FUNCTION. Reductions collapse lanes, so they are not layout - which is why they moved off
* IComponentTuple. Split where PRESENCE differs rather than per verb: a quaternion has Dot,
* LengthSquared and Length, and deliberately has no Distance, because Euclidean distance is not the
* metric on rotations. Each carries its own result type, since a squared reduction and a square root
* cannot agree on one.
* --------------------------------------------------------------------------- */
/// <summary>The dot product.</summary>
/// <typeparam name="TSelf">The type that implements the interface.</typeparam>
/// <typeparam name="TResult">What the reduction returns; wider than the component where the
/// component cannot carry the result.</typeparam>
/* No family in the name: quaternions have a dot product too, and are not vectors. LengthSquared
* lives here rather than beside Length because it is the SELF-dot - the same reduction, so it cannot
* have a different result type. */
public interface IDotProduct<TSelf, TResult>
where TSelf : IDotProduct<TSelf, TResult>
{
/// <summary>The dot product.</summary>
static abstract TResult Dot(TSelf a, TSelf b);
/// <summary>The squared magnitude, avoiding the square root.</summary>
TResult LengthSquared();
}
/// <summary>The magnitude: a square root, so its result type is its own.</summary>
public interface IMagnitude<TSelf, TRoot>
where TSelf : IMagnitude<TSelf, TRoot>
{
/// <summary>The magnitude.</summary>
TRoot Length();
}
/// <summary>Distance between two values, where a Euclidean metric is the right one.</summary>
public interface IDistance<TSelf, TSquared, TRoot>
where TSelf : IDistance<TSelf, TSquared, TRoot>
{
/// <summary>The distance between two values.</summary>
static abstract TRoot Distance(TSelf a, TSelf b);
/// <summary>The squared distance, avoiding the square root.</summary>
static abstract TSquared DistanceSquared(TSelf a, TSelf b);
}
/* INumber forces scalar <, <=, > and >= into existence; R^n has no total order, so ours throw.
* The componentwise forms here are the answers that exist - one bool per lane, reduced by the
* caller with Any/All, as every shader language spells it. Only one of the two occupies the
* public slot: the throwing pair is an EXPLICIT implementation of IComparisonOperators, reachable
* only from code that asked for a total order by naming it.
* INHERITING IComparisonOperators is load-bearing: without it, constraining on BOTH this
* interface and INumber makes every comparison CS9342-ambiguous (measured); with it, the
* redeclarations HIDE the scalar pair and the mask form wins. Pinned in ComparisonDispatchTests. */
/// <summary>Defines componentwise relational operators, each returning a per-component mask.</summary>
/// <typeparam name="TSelf">The type that implements the interface.</typeparam>
/// <typeparam name="TMask">The boolean vector of matching arity.</typeparam>
public interface IComponentwiseComparison<TSelf, TMask> : IComparisonOperators<TSelf, TSelf, bool>
where TSelf : IComponentwiseComparison<TSelf, TMask>
{
/// <summary>Compares each pair of components for less-than.</summary>
static abstract TMask operator <(TSelf a, TSelf b);
/// <summary>Compares each pair of components for less-than-or-equal.</summary>
static abstract TMask operator <=(TSelf a, TSelf b);
/// <summary>Compares each pair of components for greater-than.</summary>
static abstract TMask operator >(TSelf a, TSelf b);
/// <summary>Compares each pair of components for greater-than-or-equal.</summary>
static abstract TMask operator >=(TSelf a, TSelf b);
}
/// <summary>Defines a generic vector type.</summary>
/// <typeparam name="TSelf">The type that implements the interface.</typeparam>
/// <typeparam name="T">The component type.</typeparam>
/* Inherits IEqualityOperators so the ==/!= below are REDECLARATIONS that hide it - the same
* CS9342 cure as IComponentwiseComparison, needed the moment any second route brings
* IEqualityOperators into a constraint closure alongside this interface (the bundles do, through
* IComparisonOperators; INumberBase does for any caller naming both). */
public interface IVector<TSelf, T> : IComponentTuple<TSelf, T>, IEqualityOperators<TSelf, TSelf, bool>
where TSelf : IVector<TSelf, T>
{
/// <summary>Gets the zero vector.</summary>
static abstract TSelf Zero { get; }
/// <summary>Gets the one vector.</summary>
static abstract TSelf One { get; }
/// <summary>Returns a value that indicates whether each pair of elements in two specified vectors is equal.</summary>
/// <param name="left">The first vector to compare.</param>
/// <param name="right">The second vector to compare.</param>
/// <returns>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are equal; otherwise,
/// <see langword="false" />.
/// </returns>
public static abstract bool operator ==(TSelf left, TSelf right);
/// <summary>Returns a value that indicates whether two specified vectors are not equal.</summary>
/// <param name="left">The first vector to compare.</param>
/// <param name="right">The second vector to compare.</param>
/// <returns>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are not equal; otherwise,
/// <see langword="false" />.
/// </returns>
public static abstract bool operator !=(TSelf left, TSelf right);
}
/// <summary>Defines a integer vector type.</summary>
public interface INumericVector<TSelf, in T>
where TSelf : INumericVector<TSelf, T>
{
/// <summary>Adds two vectors together.</summary>
/// <param name="left">The first vector to add.</param>
/// <param name="right">The second vector to add.</param>
/// <returns>The summed vector.</returns>
public static abstract TSelf operator +(TSelf left, TSelf right);
/// <summary>Subtracts the second vector from the first.</summary>
/// <param name="left">The first vector.</param>
/// <param name="right">The second vector.</param>
public static abstract TSelf operator -(TSelf left, TSelf right);
/// <summary>Returns a new vector whose values are the product of each pair of elements in two specified vectors.</summary>
/// <param name="left">The first vector.</param>
/// <param name="right">The second vector.</param>
/// <returns>The element-wise product vector.</returns>
public static abstract TSelf operator *(TSelf left, TSelf right);
/// <summary>Divides the first vector by the second.</summary>
/// <param name="left">The first vector.</param>
/// <param name="right">The second vector.</param>
public static abstract TSelf operator /(TSelf left, TSelf right);
/// <summary>Multiplies the specified vector by the specified scalar value.</summary>
/// <param name="left">The vector.</param>
/// <param name="right">The scalar value.</param>
/// <returns>The scaled vector.</returns>
public static abstract TSelf operator *(TSelf left, T right);
/// <summary>Divides the specified vector by a specified scalar value.</summary>
/// <param name="value1">The vector.</param>
/// <param name="value2">The scalar value.</param>
/// <returns>The result of the division.</returns>
public static abstract TSelf operator /(TSelf value1, T value2);
/// <summary>Multiplies the scalar value by the specified vector.</summary>
/// <param name="left">The vector.</param>
/// <param name="right">The scalar value.</param>
/// <returns>The scaled vector.</returns>
public static abstract TSelf operator *(T left, TSelf right);
/// <summary>Negates the specified vector.</summary>
/// <param name="value">The vector to negate.</param>
/// <returns>The negated vector.</returns>
public static abstract TSelf operator -(TSelf value);
}
/// <summary>Defines a integer vector type.</summary>
public interface IBooleanVector<TSelf, T> : IVector<TSelf, T>
where TSelf : IBooleanVector<TSelf, T>
{
/// <summary>OR operation</summary>
public static abstract TSelf operator |(TSelf a, TSelf b);
/// <summary>AND operation</summary>
public static abstract TSelf operator &(TSelf a, TSelf b);
/// <summary>Whether any component is true.</summary>
bool Any { get; }
/// <summary>Whether every component is true.</summary>
bool All { get; }
}
/* TResult is what C# promotion gives the component: int for sbyte, byte, short and ushort, and the
* component itself for int, uint, long and ulong. The square roots are TRoot, since a sqrt has no
* integer answer: float for the 4-byte-and-under components, double for the 8-byte ones, whose
* magnitude float cannot hold.
* T is no longer contravariant, because the magnitude returns TRoot and the reductions return
* TResult; variance never applied to the struct implementers anyway. */
/// <summary>Defines a integer vector type.</summary>
/// <typeparam name="TSelf">The type that implements the interface.</typeparam>
/// <typeparam name="T">The component type.</typeparam>
/// <typeparam name="TResult">What a reduction returns: the C# promotion of <typeparamref name="T" />.</typeparam>
/// <typeparam name="TRoot">What a square root returns: float, or double for the 8-byte components.</typeparam>
public interface IIntegerVector<TSelf, T, TResult, TRoot>
: INumericVector<TSelf, T>,
IDotProduct<TSelf, TResult>,
IMagnitude<TSelf, TRoot>,
IDistance<TSelf, TResult, TRoot>
where TSelf : IIntegerVector<TSelf, T, TResult, TRoot>
{
/* The half of IBinaryInteger that means something for a vector. The other ten members are the
* scalar wire-encoding suite and are undefined here - nothing says whether a big-endian int3
* byte-swaps each component, reverses component order, or both - so taking the whole interface
* would mean inventing a contract to satisfy something nothing constrains on. Every integer
* family has all five, so it is a family trait and belongs here rather than in a name of its
* own. */
/// <inheritdoc cref="IBinaryInteger{TSelf}.PopCount" />
static abstract TSelf PopCount(TSelf value);
/// <inheritdoc cref="IBinaryInteger{TSelf}.LeadingZeroCount" />
static abstract TSelf LeadingZeroCount(TSelf value);
/// <inheritdoc cref="IBinaryInteger{TSelf}.TrailingZeroCount" />
static abstract TSelf TrailingZeroCount(TSelf value);
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateLeft" />
static abstract TSelf RotateLeft(TSelf value, int rotateAmount);
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateRight" />
static abstract TSelf RotateRight(TSelf value, int rotateAmount);
}
/// <inheritdoc cref="IIntegerVector{TSelf,T,TResult,TRoot}" />
/* Inherits rather than paralleling it: a signed integer vector IS an integer vector, and the two
* were siblings only because neither declared anything to share. Now that the bit-counting members
* live on the base, the difference is exactly Abs. */
public interface ISignedIntegerVector<TSelf, T, TResult, TRoot> : IIntegerVector<TSelf, T, TResult, TRoot>
where TSelf : ISignedIntegerVector<TSelf, T, TResult, TRoot>
{
/// <summary>Returns a vector whose elements are the absolute values of each of the specified vector's elements.</summary>
/// <param name="value">A vector.</param>
/// <returns>The absolute value vector.</returns>
public static abstract TSelf Abs(TSelf value);
}
/// <summary>Defines a floating vector type.</summary>
/* Named for the FAMILY, not for a BCL rung: it carries the family's math, and the rung the concrete
* types reach (IFloatingPointIeee754) is declared on them, not here. "Floating" rather than
* "FloatingPoint" so the four family names share one shape - IIntegerVector, ISignedIntegerVector,
* IBooleanVector, IFloatingVector - and so the only one colliding with a real BCL interface name
* stops doing so. */
public interface IFloatingVector<TSelf, T>
: INumericVector<TSelf, T>,
IDotProduct<TSelf, T>,
IMagnitude<TSelf, T>,
IDistance<TSelf, T, T>
where TSelf : IFloatingVector<TSelf, T>
{
/// <summary>Reflects a vector about a surface normal.</summary>
/* Every floating vector has one at every arity, so it is a family trait. It was its own name
* only while arity 4 lacked it - Vector4 has no Reflect, which looked like a rule and was an
* omission. */
static abstract TSelf Reflect(TSelf vector, TSelf normal);
/// <inheritdoc cref="Vector3.Normalize" />
/// <exception cref="DivideByZeroException">Thrown when the input vector is a zero vector.</exception>
static abstract TSelf Normalize(TSelf value);
/// <inheritdoc cref="Vector3.Normalize" />
/// <remarks>Will return a zero vector if the input vector is a zero vector.</remarks>
static abstract TSelf NormalizeOrZero(TSelf value);
/* The static algebra surface: exposes the statics that already exist on every floating-point
* vector type, so generic code can call them through the interface (satisfied implicitly).
* Dot, Distance and DistanceSquared are no longer here - they are inherited from the reduction
* interfaces above, which quaternions share and which carry their own result types. */
/// <inheritdoc cref="Vector3.Add" />
static abstract TSelf Add(TSelf left, TSelf right);
/// <inheritdoc cref="Vector3.Subtract" />
static abstract TSelf Subtract(TSelf left, TSelf right);
/// <inheritdoc cref="Vector3.Multiply(Vector3, Vector3)" />
static abstract TSelf Multiply(TSelf left, TSelf right);
/// <inheritdoc cref="Vector3.Multiply(Vector3, float)" />
static abstract TSelf Multiply(TSelf left, T right);
/// <inheritdoc cref="Vector3.Multiply(float, Vector3)" />
static abstract TSelf Multiply(T left, TSelf right);
/// <inheritdoc cref="Vector3.Divide(Vector3, Vector3)" />
static abstract TSelf Divide(TSelf left, TSelf right);
/// <inheritdoc cref="Vector3.Divide(Vector3, float)" />
static abstract TSelf Divide(TSelf left, T divisor);
/// <inheritdoc cref="Vector3.Negate" />
static abstract TSelf Negate(TSelf value);
/// <inheritdoc cref="Vector3.Abs" />
static abstract TSelf Abs(TSelf value);
/// <inheritdoc cref="Vector3.SquareRoot" />
static abstract TSelf SquareRoot(TSelf value);
/// <inheritdoc cref="Vector3.Min" />
static abstract TSelf Min(TSelf a, TSelf b);
/// <inheritdoc cref="Vector3.Max" />
static abstract TSelf Max(TSelf a, TSelf b);
/// <inheritdoc cref="Vector3.Clamp" />
static abstract TSelf Clamp(TSelf value, TSelf min, TSelf max);
/// <inheritdoc cref="Vector3.Lerp(Vector3,Vector3,float)" />
static abstract TSelf Lerp(TSelf a, TSelf b, T t);
}
/* The arities are SIBLINGS, not a chain. They used to inherit - IVector4 : IVector3 : IVector2 -
* which meant a float4 satisfied `where TSelf : IVector2<TSelf, T>`, so arity stopped being a proof
* of anything and a two-component constraint silently accepted four. Each one now states its own
* full axis set instead of collecting them on the way down. */
/// <summary>Defines a vector2 type.</summary>
public interface IVector2<TSelf, T> : IVector<TSelf, T>
where TSelf : IVector2<TSelf, T>
{
/* The components by name. They are FIELDS on the concrete types, and a field cannot
* implement a property, so each type carries an explicit forwarder - generated, one line
* each. Worth it because X/Y/Z is how the domain spells a component; the indexer stays for
* code that walks them. */
/// <summary>Gets or sets the x component.</summary>
T X { get; set; }
/// <summary>Gets or sets the y component.</summary>
T Y { get; set; }
/// <summary>Gets the unit x vector.</summary>
static abstract TSelf UnitX { get; }
/// <summary>Gets the unit y vector.</summary>
static abstract TSelf UnitY { get; }
}
/// <summary>Defines a vector3 type.</summary>
public interface IVector3<TSelf, T> : IVector<TSelf, T>
where TSelf : IVector3<TSelf, T>
{
/// <summary>Gets or sets the x component.</summary>
T X { get; set; }
/// <summary>Gets or sets the y component.</summary>
T Y { get; set; }
/// <summary>Gets or sets the z component.</summary>
T Z { get; set; }
/// <inheritdoc cref="IVector2{TSelf,T}.UnitX" />
static abstract TSelf UnitX { get; }
/// <inheritdoc cref="IVector2{TSelf,T}.UnitY" />
static abstract TSelf UnitY { get; }
/// <summary>Gets the unit z vector.</summary>
static abstract TSelf UnitZ { get; }
}
/// <summary>Defines a vector4 type.</summary>
public interface IVector4<TSelf, T> : IVector<TSelf, T>
where TSelf : IVector4<TSelf, T>
{
/// <summary>Gets or sets the x component.</summary>
T X { get; set; }
/// <summary>Gets or sets the y component.</summary>
T Y { get; set; }
/// <summary>Gets or sets the z component.</summary>
T Z { get; set; }
/// <summary>Gets or sets the w component.</summary>
T W { get; set; }
/// <inheritdoc cref="IVector2{TSelf,T}.UnitX" />
static abstract TSelf UnitX { get; }
/// <inheritdoc cref="IVector2{TSelf,T}.UnitY" />
static abstract TSelf UnitY { get; }
/// <inheritdoc cref="IVector3{TSelf,T}.UnitZ" />
static abstract TSelf UnitZ { get; }
/// <summary>Gets the unit w vector.</summary>
static abstract TSelf UnitW { get; }
}
internal class VectorDebugView2<TSelf, T, TRoot>(TSelf v)
where TSelf : IVector2<TSelf, T>, IMagnitude<TSelf, TRoot>
{
public T X => v[0];
public T Y => v[1];
public TRoot Length => v.Length();
public override string? ToString()
{
return v.ToString();
}
}
internal class VectorDebugView3<TSelf, T, TRoot>(TSelf v)
where TSelf : IVector3<TSelf, T>, IMagnitude<TSelf, TRoot>
{
public T X => v[0];
public T Y => v[1];
public T Z => v[2];
public TRoot Length => v.Length();
public override string? ToString()
{
return v.ToString();
}
}
internal class VectorDebugView4<TSelf, T, TRoot>(TSelf v)
where TSelf : IVector4<TSelf, T>, IMagnitude<TSelf, TRoot>
{
public T X => v[0];
public T Y => v[1];
public T Z => v[2];
public T W => v[3];
public TRoot Length => v.Length();
public override string? ToString()
{
return v.ToString();
}
}
/// <summary>Defines the cross product.</summary>
public interface ICrossProduct<TSelf>
where TSelf : ICrossProduct<TSelf>
{
/// <inheritdoc cref="Vector3.Cross" />
static abstract TSelf Cross(TSelf left, TSelf right);
}
/* ----------------------------------------------------------------------------
* Per-arity floating bundles. Each composes the two axes - the arity interface for layout, the
* family interface for math - and adds only what neither can carry: the transforms, which name a
* matrix or a quaternion the vector itself knows nothing about.
*
* WHY THE TRANSFORMS ARE DECLARED INLINE rather than composed from ITransform<TSelf, TInput, TBy>
* capability interfaces. CS0695: a generic type cannot inherit two instantiations of one generic
* interface if they MAY unify under substitution, and nothing proves TMatrix4x4 != TQuaternion.
* Probed 2026-08-24, all three cases:
*
* inherit ONE generic instantiation ITransform<TSelf, TSelf, TMatrix> compiles
* inherit TWO generic instantiations ... TMatrix and ... TQuat CS0695
* inherit TWO CONCRETE instantiations ... float4x4 and ... floatQuat compiles
*
* So the escape hatch is real but useless here: a bundle hardcoding float4x4 cannot serve double3,
* and the differential suites are one generic body over float and double. Every vector needs at
* least two transforms (by matrix and by rotation), so no generic bundle can compose them.
*
* The alternative was measured rather than assumed: attaching the capabilities to the concrete
* types instead works and keeps this file free of members it does not own, but moves the cost to
* every consumer - the arity-4 differential constraint went from one name to ten. Overloads within
* one interface are fine, so the bundle pays once, here.
* ---------------------------------------------------------------------------- */
/// <summary>Everything a 2-component floating-point vector can do.</summary>
public interface IFloatingVector2<TSelf, TComponent, TQuaternion, TMatrix3x2, TMatrix4x4>
: IVector2<TSelf, TComponent>,
IFloatingVector<TSelf, TComponent>,
IComponentwiseComparison<TSelf, bool2>
where TSelf : IFloatingVector2<TSelf, TComponent, TQuaternion, TMatrix3x2, TMatrix4x4>
{
/// <inheritdoc cref="Vector2.Transform(Vector2, Matrix3x2)" />
static abstract TSelf Transform(TSelf position, TMatrix3x2 matrix);
/// <inheritdoc cref="Vector2.Transform(Vector2, Matrix4x4)" />
static abstract TSelf Transform(TSelf position, TMatrix4x4 matrix);
/// <inheritdoc cref="Vector2.Transform(Vector2, Quaternion)" />
static abstract TSelf Transform(TSelf value, TQuaternion rotation);
/// <inheritdoc cref="Vector2.TransformNormal(Vector2, Matrix3x2)" />
static abstract TSelf TransformNormal(TSelf normal, TMatrix3x2 matrix);
/// <inheritdoc cref="Vector2.TransformNormal(Vector2, Matrix4x4)" />
static abstract TSelf TransformNormal(TSelf normal, TMatrix4x4 matrix);
}
/// <summary>Everything a 3-component floating-point vector can do.
/// <typeparamref name="TVector2" /> is the result of the matrix3x2 projection.</summary>
public interface IFloatingVector3<TSelf, TComponent, TVector2, TQuaternion, TMatrix3x2, TMatrix4x4>
: IVector3<TSelf, TComponent>,
IFloatingVector<TSelf, TComponent>,
ICrossProduct<TSelf>,
IComponentwiseComparison<TSelf, bool3>,
IMultiplyOperators<TSelf, TMatrix3x2, TVector2>
where TSelf : IFloatingVector3<TSelf, TComponent, TVector2, TQuaternion, TMatrix3x2, TMatrix4x4>
{
/// <summary>Static-method twin of the <c>vector * matrix3x2</c> operator (projects to 2 components).</summary>
static abstract TVector2 Multiply(TSelf vector, TMatrix3x2 matrix);
/// <inheritdoc cref="Vector3.Transform(Vector3, Matrix4x4)" />
static abstract TSelf Transform(TSelf position, TMatrix4x4 matrix);
/// <inheritdoc cref="Vector3.Transform(Vector3, Quaternion)" />
static abstract TSelf Transform(TSelf value, TQuaternion rotation);
/// <inheritdoc cref="Vector3.TransformNormal(Vector3, Matrix4x4)" />
static abstract TSelf TransformNormal(TSelf normal, TMatrix4x4 matrix);
}
/// <summary>Everything a 4-component floating-point vector can do.
/// <typeparamref name="TVector2" /> / <typeparamref name="TVector3" /> are the cross-dimension transform inputs.</summary>
public interface IFloatingVector4<TSelf, TComponent, TVector2, TVector3, TQuaternion, TMatrix4x4>
: IVector4<TSelf, TComponent>,
IFloatingVector<TSelf, TComponent>,
IComponentwiseComparison<TSelf, bool4>,
IMultiplyOperators<TSelf, TMatrix4x4, TSelf>
where TSelf : IFloatingVector4<TSelf, TComponent, TVector2, TVector3, TQuaternion, TMatrix4x4>
{
/// <summary>Static-method twin of the <c>vector * matrix4x4</c> operator.</summary>
static abstract TSelf Multiply(TSelf vector, TMatrix4x4 matrix);
/// <inheritdoc cref="Vector4.Transform(Vector4, Matrix4x4)" />
static abstract TSelf Transform(TSelf vector, TMatrix4x4 matrix);
/// <inheritdoc cref="Vector4.Transform(Vector4, Quaternion)" />
static abstract TSelf Transform(TSelf value, TQuaternion rotation);
// cross-dimension: 2/3-component input transformed up to a 4-component result
/// <inheritdoc cref="Vector4.Transform(Vector2, Matrix4x4)" />
static abstract TSelf Transform(TVector2 position, TMatrix4x4 matrix);
/// <inheritdoc cref="Vector4.Transform(Vector2, Quaternion)" />
static abstract TSelf Transform(TVector2 value, TQuaternion rotation);
/// <inheritdoc cref="Vector4.Transform(Vector3, Matrix4x4)" />
static abstract TSelf Transform(TVector3 position, TMatrix4x4 matrix);
/// <inheritdoc cref="Vector4.Transform(Vector3, Quaternion)" />
static abstract TSelf Transform(TVector3 value, TQuaternion rotation);
}

View file

@ -0,0 +1,279 @@
namespace Brutal.Numerics;
/* One shared body for the vectors' INumberBase TryConvertFrom* protocol - the per-type explicit
* implementations are one-line forwards into TryConvertFrom, with the overflow policy carried as
* a generic marker struct. Deduplicated for assembly size: the typeof dispatch below exists once
* instead of once per vector type x policy (it was ~27% of the library's IL as generated code),
* and still JIT-folds to the single live branch per instantiation - the BCL's own pattern.
*
* Semantics (also documented in Vector.numerics.tt): scalars embed along One - a broadcast; a
* sibling vector converts per lane when the arities match (the lane-count check inside FromLanes
* rejects a cross-arity pair). Quaternions embed scalars on the real axis instead, so they keep
* their own generated protocol. */
internal static class NumberConversion
{
/// <summary>The overflow policy of one TryConvertFrom flavor, as a JIT-foldable marker struct.</summary>
internal interface IPolicy
{
static abstract TComponent Convert<TComponent, TOther>(TOther value)
where TComponent : INumberBase<TComponent>
where TOther : INumberBase<TOther>;
}
internal readonly struct Checked : IPolicy
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TComponent Convert<TComponent, TOther>(TOther value)
where TComponent : INumberBase<TComponent>
where TOther : INumberBase<TOther>
{
return TComponent.CreateChecked(value);
}
}
internal readonly struct Saturating : IPolicy
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TComponent Convert<TComponent, TOther>(TOther value)
where TComponent : INumberBase<TComponent>
where TOther : INumberBase<TOther>
{
return TComponent.CreateSaturating(value);
}
}
internal readonly struct Truncating : IPolicy
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TComponent Convert<TComponent, TOther>(TOther value)
where TComponent : INumberBase<TComponent>
where TOther : INumberBase<TOther>
{
return TComponent.CreateTruncating(value);
}
}
// the supported-set dispatch: self, then the 8 scalar component types, then every non-bool
// vector type (cross-arity pairs fall out via the lane-count check)
internal static bool TryConvertFrom<TVector, TComponent, TOther, TPolicy>(TOther value, out TVector result)
where TVector : unmanaged, IVector<TVector, TComponent>
where TComponent : unmanaged, INumberBase<TComponent>
where TOther : INumberBase<TOther>
where TPolicy : IPolicy
{
if (typeof(TOther) == typeof(TVector))
{
result = (TVector)(object)value!;
return true;
}
if (typeof(TOther) == typeof(sbyte))
return Broadcast<TVector, TComponent, sbyte, TPolicy>((sbyte)(object)value!, out result);
if (typeof(TOther) == typeof(byte))
return Broadcast<TVector, TComponent, byte, TPolicy>((byte)(object)value!, out result);
if (typeof(TOther) == typeof(short))
return Broadcast<TVector, TComponent, short, TPolicy>((short)(object)value!, out result);
if (typeof(TOther) == typeof(ushort))
return Broadcast<TVector, TComponent, ushort, TPolicy>((ushort)(object)value!, out result);
if (typeof(TOther) == typeof(int))
return Broadcast<TVector, TComponent, int, TPolicy>((int)(object)value!, out result);
if (typeof(TOther) == typeof(uint))
return Broadcast<TVector, TComponent, uint, TPolicy>((uint)(object)value!, out result);
if (typeof(TOther) == typeof(long))
return Broadcast<TVector, TComponent, long, TPolicy>((long)(object)value!, out result);
if (typeof(TOther) == typeof(ulong))
return Broadcast<TVector, TComponent, ulong, TPolicy>((ulong)(object)value!, out result);
if (typeof(TOther) == typeof(float))
return Broadcast<TVector, TComponent, float, TPolicy>((float)(object)value!, out result);
if (typeof(TOther) == typeof(double))
return Broadcast<TVector, TComponent, double, TPolicy>((double)(object)value!, out result);
if (typeof(TOther) == typeof(sbyte2))
{
var other = (sbyte2)(object)value!;
return FromLanes<TVector, TComponent, sbyte, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(sbyte3))
{
var other = (sbyte3)(object)value!;
return FromLanes<TVector, TComponent, sbyte, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(sbyte4))
{
var other = (sbyte4)(object)value!;
return FromLanes<TVector, TComponent, sbyte, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(byte2))
{
var other = (byte2)(object)value!;
return FromLanes<TVector, TComponent, byte, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(byte3))
{
var other = (byte3)(object)value!;
return FromLanes<TVector, TComponent, byte, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(byte4))
{
var other = (byte4)(object)value!;
return FromLanes<TVector, TComponent, byte, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(short2))
{
var other = (short2)(object)value!;
return FromLanes<TVector, TComponent, short, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(short3))
{
var other = (short3)(object)value!;
return FromLanes<TVector, TComponent, short, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(short4))
{
var other = (short4)(object)value!;
return FromLanes<TVector, TComponent, short, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(ushort2))
{
var other = (ushort2)(object)value!;
return FromLanes<TVector, TComponent, ushort, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(ushort3))
{
var other = (ushort3)(object)value!;
return FromLanes<TVector, TComponent, ushort, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(ushort4))
{
var other = (ushort4)(object)value!;
return FromLanes<TVector, TComponent, ushort, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(int2))
{
var other = (int2)(object)value!;
return FromLanes<TVector, TComponent, int, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(int3))
{
var other = (int3)(object)value!;
return FromLanes<TVector, TComponent, int, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(int4))
{
var other = (int4)(object)value!;
return FromLanes<TVector, TComponent, int, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(uint2))
{
var other = (uint2)(object)value!;
return FromLanes<TVector, TComponent, uint, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(uint3))
{
var other = (uint3)(object)value!;
return FromLanes<TVector, TComponent, uint, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(uint4))
{
var other = (uint4)(object)value!;
return FromLanes<TVector, TComponent, uint, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(long2))
{
var other = (long2)(object)value!;
return FromLanes<TVector, TComponent, long, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(long3))
{
var other = (long3)(object)value!;
return FromLanes<TVector, TComponent, long, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(long4))
{
var other = (long4)(object)value!;
return FromLanes<TVector, TComponent, long, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(ulong2))
{
var other = (ulong2)(object)value!;
return FromLanes<TVector, TComponent, ulong, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(ulong3))
{
var other = (ulong3)(object)value!;
return FromLanes<TVector, TComponent, ulong, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(ulong4))
{
var other = (ulong4)(object)value!;
return FromLanes<TVector, TComponent, ulong, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(float2))
{
var other = (float2)(object)value!;
return FromLanes<TVector, TComponent, float, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(float3))
{
var other = (float3)(object)value!;
return FromLanes<TVector, TComponent, float, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(float4))
{
var other = (float4)(object)value!;
return FromLanes<TVector, TComponent, float, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(double2))
{
var other = (double2)(object)value!;
return FromLanes<TVector, TComponent, double, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(double3))
{
var other = (double3)(object)value!;
return FromLanes<TVector, TComponent, double, TPolicy>(other.AsSpan(), out result);
}
if (typeof(TOther) == typeof(double4))
{
var other = (double4)(object)value!;
return FromLanes<TVector, TComponent, double, TPolicy>(other.AsSpan(), out result);
}
result = default;
return false;
}
private static bool Broadcast<TVector, TComponent, TSource, TPolicy>(TSource value, out TVector result)
where TVector : unmanaged, IVector<TVector, TComponent>
where TComponent : unmanaged, INumberBase<TComponent>
where TSource : INumberBase<TSource>
where TPolicy : IPolicy
{
var converted = TPolicy.Convert<TComponent, TSource>(value);
Span<TComponent> lanes = stackalloc TComponent[TVector.ComponentCount];
lanes.Fill(converted);
result = TVector.Create(lanes);
return true;
}
private static bool FromLanes<TVector, TComponent, TSource, TPolicy>(
ReadOnlySpan<TSource> source,
out TVector result
)
where TVector : unmanaged, IVector<TVector, TComponent>
where TComponent : unmanaged, INumberBase<TComponent>
where TSource : INumberBase<TSource>
where TPolicy : IPolicy
{
if (source.Length != TVector.ComponentCount)
{
result = default;
return false;
}
Span<TComponent> lanes = stackalloc TComponent[source.Length];
for (var i = 0; i < source.Length; i++)
lanes[i] = TPolicy.Convert<TComponent, TSource>(source[i]);
result = TVector.Create(lanes);
return true;
}
}

View file

@ -0,0 +1,28 @@
// <auto-generated /> - edit Vector.copy.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool2
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void CopyTo(Span<bool> destination)
{
if (destination.Length < ComponentCount)
throw new ArgumentException("Length must be at least 2.", nameof(destination));
Unsafe.WriteUnaligned(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(destination)), this);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool TryCopyTo(Span<bool> destination)
{
if (destination.Length < ComponentCount)
return false;
Unsafe.WriteUnaligned(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(destination)), this);
return true;
}
}

View file

@ -0,0 +1,41 @@
// <auto-generated /> - edit Vector.equality.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool2
{
/// <inheritdoc />
public readonly override int GetHashCode()
{
return HashCode.Combine(X, Y);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(bool2 other)
{
return X == other.X && Y == other.Y;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is bool2 other && Equals(other);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(bool2 a, bool2 b)
{
return a.Equals(b);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(bool2 a, bool2 b)
{
return !(a == b);
}
}

View file

@ -0,0 +1,38 @@
// <auto-generated /> - edit Vector.format.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool2 : ISpanFormattable, IUtf8SpanFormattable
{
/// <inheritdoc />
public readonly override string ToString()
{
return ToString("G", CultureInfo.CurrentCulture);
}
/// <inheritdoc cref="Vector2.ToString(string?)" />
public readonly string ToString(string? format)
{
return ToString(format, CultureInfo.CurrentCulture);
}
/// <inheritdoc />
public readonly string ToString(string? format, IFormatProvider? formatProvider)
{
var separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
return $"<{X.ToString()}{separator} {Y.ToString()}>";
}
/// <inheritdoc />
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<bool2, bool>(this, destination, out charsWritten, format, provider);
}
/// <inheritdoc />
public readonly bool TryFormat(Span<byte> destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<bool2, bool>(this, destination, out bytesWritten, format, provider);
}
}

View file

@ -0,0 +1,105 @@
// <auto-generated /> - edit Vector.tt to modify
#nullable enable
namespace Brutal.Numerics;
/// <summary>
/// Implements a 2D vector with bool components.
/// </summary>
public partial struct bool2 : IVector2<bool2, bool>
, IBooleanVector<bool2, bool>
{
/// <inheritdoc />
public static int ComponentSize => sizeof(bool);
/// <summary>Gets the number of components.</summary>
public static int ComponentCount => 2;
/// <inheritdoc cref="Vector2.X" />
[XmlAttribute]
public bool X;
/// <inheritdoc cref="Vector2.Y" />
[XmlAttribute]
public bool Y;
bool IVector2<bool2, bool>.X { readonly get => X; set => X = value; }
bool IVector2<bool2, bool>.Y { readonly get => Y; set => Y = value; }
/// <inheritdoc cref="Vector2(float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool2(bool x, bool y)
{
X = x;
Y = y;
}
/// <inheritdoc cref="Vector2(float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool2(bool xy)
: this(xy, xy) { }
/// <summary>Creates a vector from the leading 2 elements of a span.</summary>
/// <param name="span">The elements to read; must contain at least 2, and any beyond that are ignored.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="span" /> holds fewer than 2 elements.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool2(ReadOnlySpan<bool> span)
{
if (span.Length < 2)
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 2.");
this = Unsafe.ReadUnaligned<bool2>(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(span)));
}
/// <inheritdoc cref="bool2(ReadOnlySpan{bool})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool2 IComponentTuple<bool2, bool>.Create(ReadOnlySpan<bool> span) => new(span);
/// <inheritdoc />
public static bool2 UnitX => new(true, false);
/// <inheritdoc />
public static bool2 UnitY => new(false, true);
/// <inheritdoc />
public bool this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
return Unsafe.Add(ref Unsafe.AsRef(in X), index);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
Unsafe.Add(ref X, index) = value;
}
}
public readonly void Deconstruct(out bool x, out bool y)
{
x = X;
y = Y;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<bool> AsSpan()
{
return MemoryMarshal.CreateSpan(ref Unsafe.As<bool2, bool>(ref this), 2);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ReadOnlySpan<bool> AsReadOnlySpan()
{
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<bool2, bool>(ref Unsafe.AsRef(in this)), 2);
}
}

View file

@ -0,0 +1,13 @@
// <auto-generated /> - edit Vector.math.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool2
{
/// <inheritdoc />
public readonly bool Any => X || Y;
/// <inheritdoc />
public readonly bool All => X && Y;
}

View file

@ -0,0 +1,53 @@
// <auto-generated /> - edit Vector.numerics.tt to modify
#nullable enable
namespace Brutal.Numerics;
// INumberBase
public partial struct bool2
{
/// <inheritdoc />
public static bool2 Zero => new(false);
/// <inheritdoc />
public static bool2 One => new(true);
}
// IBitwiseOperators
public partial struct bool2 : IBitwiseOperators<bool2, bool2, bool2>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool2 operator |(bool2 a, bool2 b)
{
return new bool2(a.X | b.X, a.Y | b.Y);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool2 operator &(bool2 a, bool2 b)
{
return new bool2(a.X & b.X, a.Y & b.Y);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool2 operator ^(bool2 a, bool2 b)
{
return new bool2(a.X ^ b.X, a.Y ^ b.Y);
}
/// <inheritdoc cref="IBitwiseOperators{TSelf, TOther, TResult}.op_OnesComplement" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool2 operator !(bool2 value)
{
return new bool2(!value.X, !value.Y);
}
// bool has no ~; the interface's complement is componentwise logical not
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool2 IBitwiseOperators<bool2, bool2, bool2>.operator ~(bool2 value)
{
return !value;
}
}

View file

@ -0,0 +1,80 @@
// <auto-generated /> - edit Vector.swizzle.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool2
{
/// <summary>
/// Swizzle readonly getter/setter for the X and Y components of the vector.
/// </summary>
[XmlIgnore]
public bool2 XY
{
readonly get => this;
set => this = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the Y and X components of the vector.
/// </summary>
[XmlIgnore]
public bool2 YX
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Y, X);
set
{
Y = value.X;
X = value.Y;
}
}
}
public partial struct bool2
{
/// <summary>
/// The Red component of the vector (synonym for X).
/// </summary>
[XmlIgnore]
public bool R
{
readonly get => X;
set => X = value;
}
/// <summary>
/// The Green component of the vector (synonym for Y).
/// </summary>
[XmlIgnore]
public bool G
{
readonly get => Y;
set => Y = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the Red and Green components of the vector.
/// </summary>
[XmlIgnore]
public bool2 RG
{
readonly get => this;
set => this = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the Green and Red components of the vector.
/// </summary>
[XmlIgnore]
public bool2 GR
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(G, R);
set
{
G = value.R;
R = value.G;
}
}
}

View file

@ -0,0 +1,28 @@
// <auto-generated /> - edit Vector.copy.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool3
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void CopyTo(Span<bool> destination)
{
if (destination.Length < ComponentCount)
throw new ArgumentException("Length must be at least 3.", nameof(destination));
Unsafe.WriteUnaligned(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(destination)), this);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool TryCopyTo(Span<bool> destination)
{
if (destination.Length < ComponentCount)
return false;
Unsafe.WriteUnaligned(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(destination)), this);
return true;
}
}

View file

@ -0,0 +1,41 @@
// <auto-generated /> - edit Vector.equality.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool3
{
/// <inheritdoc />
public readonly override int GetHashCode()
{
return HashCode.Combine(X, Y, Z);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(bool3 other)
{
return X == other.X && Y == other.Y && Z == other.Z;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is bool3 other && Equals(other);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(bool3 a, bool3 b)
{
return a.Equals(b);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(bool3 a, bool3 b)
{
return !(a == b);
}
}

View file

@ -0,0 +1,38 @@
// <auto-generated /> - edit Vector.format.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool3 : ISpanFormattable, IUtf8SpanFormattable
{
/// <inheritdoc />
public readonly override string ToString()
{
return ToString("G", CultureInfo.CurrentCulture);
}
/// <inheritdoc cref="Vector3.ToString(string?)" />
public readonly string ToString(string? format)
{
return ToString(format, CultureInfo.CurrentCulture);
}
/// <inheritdoc />
public readonly string ToString(string? format, IFormatProvider? formatProvider)
{
var separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
return $"<{X.ToString()}{separator} {Y.ToString()}{separator} {Z.ToString()}>";
}
/// <inheritdoc />
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<bool3, bool>(this, destination, out charsWritten, format, provider);
}
/// <inheritdoc />
public readonly bool TryFormat(Span<byte> destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<bool3, bool>(this, destination, out bytesWritten, format, provider);
}
}

View file

@ -0,0 +1,121 @@
// <auto-generated /> - edit Vector.tt to modify
#nullable enable
namespace Brutal.Numerics;
/// <summary>
/// Implements a 3D vector with bool components.
/// </summary>
public partial struct bool3 : IVector3<bool3, bool>
, IBooleanVector<bool3, bool>
{
/// <inheritdoc />
public static int ComponentSize => sizeof(bool);
/// <summary>Gets the number of components.</summary>
public static int ComponentCount => 3;
/// <inheritdoc cref="Vector3.X" />
[XmlAttribute]
public bool X;
/// <inheritdoc cref="Vector3.Y" />
[XmlAttribute]
public bool Y;
/// <inheritdoc cref="Vector3.Z" />
[XmlAttribute]
public bool Z;
bool IVector3<bool3, bool>.X { readonly get => X; set => X = value; }
bool IVector3<bool3, bool>.Y { readonly get => Y; set => Y = value; }
bool IVector3<bool3, bool>.Z { readonly get => Z; set => Z = value; }
/// <inheritdoc cref="Vector3(float, float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool3(bool x, bool y, bool z)
{
X = x;
Y = y;
Z = z;
}
/// <inheritdoc cref="Vector3(float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool3(bool xyz)
: this(xyz, xyz, xyz) { }
/// <inheritdoc cref="Vector3(Vector2, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool3(bool2 xy, bool z)
: this(xy.X, xy.Y, z) { }
/// <summary>Creates a vector from the leading 3 elements of a span.</summary>
/// <param name="span">The elements to read; must contain at least 3, and any beyond that are ignored.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="span" /> holds fewer than 3 elements.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool3(ReadOnlySpan<bool> span)
{
if (span.Length < 3)
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 3.");
this = Unsafe.ReadUnaligned<bool3>(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(span)));
}
/// <inheritdoc cref="bool3(ReadOnlySpan{bool})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool3 IComponentTuple<bool3, bool>.Create(ReadOnlySpan<bool> span) => new(span);
/// <inheritdoc />
public static bool3 UnitX => new(true, false, false);
/// <inheritdoc />
public static bool3 UnitY => new(false, true, false);
/// <inheritdoc />
public static bool3 UnitZ => new(false, false, true);
/// <inheritdoc />
public bool this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
return Unsafe.Add(ref Unsafe.AsRef(in X), index);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
Unsafe.Add(ref X, index) = value;
}
}
public readonly void Deconstruct(out bool x, out bool y, out bool z)
{
x = X;
y = Y;
z = Z;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<bool> AsSpan()
{
return MemoryMarshal.CreateSpan(ref Unsafe.As<bool3, bool>(ref this), 3);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ReadOnlySpan<bool> AsReadOnlySpan()
{
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<bool3, bool>(ref Unsafe.AsRef(in this)), 3);
}
}

View file

@ -0,0 +1,13 @@
// <auto-generated /> - edit Vector.math.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool3
{
/// <inheritdoc />
public readonly bool Any => X || Y || Z;
/// <inheritdoc />
public readonly bool All => X && Y && Z;
}

View file

@ -0,0 +1,53 @@
// <auto-generated /> - edit Vector.numerics.tt to modify
#nullable enable
namespace Brutal.Numerics;
// INumberBase
public partial struct bool3
{
/// <inheritdoc />
public static bool3 Zero => new(false);
/// <inheritdoc />
public static bool3 One => new(true);
}
// IBitwiseOperators
public partial struct bool3 : IBitwiseOperators<bool3, bool3, bool3>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool3 operator |(bool3 a, bool3 b)
{
return new bool3(a.X | b.X, a.Y | b.Y, a.Z | b.Z);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool3 operator &(bool3 a, bool3 b)
{
return new bool3(a.X & b.X, a.Y & b.Y, a.Z & b.Z);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool3 operator ^(bool3 a, bool3 b)
{
return new bool3(a.X ^ b.X, a.Y ^ b.Y, a.Z ^ b.Z);
}
/// <inheritdoc cref="IBitwiseOperators{TSelf, TOther, TResult}.op_OnesComplement" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool3 operator !(bool3 value)
{
return new bool3(!value.X, !value.Y, !value.Z);
}
// bool has no ~; the interface's complement is componentwise logical not
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool3 IBitwiseOperators<bool3, bool3, bool3>.operator ~(bool3 value)
{
return !value;
}
}

View file

@ -0,0 +1,400 @@
// <auto-generated /> - edit Vector.swizzle.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool3
{
/// <summary>
/// Swizzle readonly getter/setter for the X and Y components of the vector.
/// </summary>
[XmlIgnore]
public bool2 XY
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(X, Y);
set
{
X = value.X;
Y = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the X and Z components of the vector.
/// </summary>
[XmlIgnore]
public bool2 XZ
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(X, Z);
set
{
X = value.X;
Z = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Y and X components of the vector.
/// </summary>
[XmlIgnore]
public bool2 YX
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Y, X);
set
{
Y = value.X;
X = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Y and Z components of the vector.
/// </summary>
[XmlIgnore]
public bool2 YZ
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Y, Z);
set
{
Y = value.X;
Z = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Z and X components of the vector.
/// </summary>
[XmlIgnore]
public bool2 ZX
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Z, X);
set
{
Z = value.X;
X = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Z and Y components of the vector.
/// </summary>
[XmlIgnore]
public bool2 ZY
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Z, Y);
set
{
Z = value.X;
Y = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the X, Y and Z components of the vector.
/// </summary>
[XmlIgnore]
public bool3 XYZ
{
readonly get => this;
set => this = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the X, Z and Y components of the vector.
/// </summary>
[XmlIgnore]
public bool3 XZY
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(X, Z, Y);
set
{
X = value.X;
Z = value.Y;
Y = value.Z;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Y, X and Z components of the vector.
/// </summary>
[XmlIgnore]
public bool3 YXZ
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Y, X, Z);
set
{
Y = value.X;
X = value.Y;
Z = value.Z;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Y, Z and X components of the vector.
/// </summary>
[XmlIgnore]
public bool3 YZX
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Y, Z, X);
set
{
Y = value.X;
Z = value.Y;
X = value.Z;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Z, X and Y components of the vector.
/// </summary>
[XmlIgnore]
public bool3 ZXY
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Z, X, Y);
set
{
Z = value.X;
X = value.Y;
Y = value.Z;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Z, Y and X components of the vector.
/// </summary>
[XmlIgnore]
public bool3 ZYX
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Z, Y, X);
set
{
Z = value.X;
Y = value.Y;
X = value.Z;
}
}
}
public partial struct bool3
{
/// <summary>
/// The Red component of the vector (synonym for X).
/// </summary>
[XmlIgnore]
public bool R
{
readonly get => X;
set => X = value;
}
/// <summary>
/// The Green component of the vector (synonym for Y).
/// </summary>
[XmlIgnore]
public bool G
{
readonly get => Y;
set => Y = value;
}
/// <summary>
/// The Blue component of the vector (synonym for Z).
/// </summary>
[XmlIgnore]
public bool B
{
readonly get => Z;
set => Z = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the Red and Green components of the vector.
/// </summary>
[XmlIgnore]
public bool2 RG
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(R, G);
set
{
R = value.R;
G = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Red and Blue components of the vector.
/// </summary>
[XmlIgnore]
public bool2 RB
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(R, B);
set
{
R = value.R;
B = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Green and Red components of the vector.
/// </summary>
[XmlIgnore]
public bool2 GR
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(G, R);
set
{
G = value.R;
R = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Green and Blue components of the vector.
/// </summary>
[XmlIgnore]
public bool2 GB
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(G, B);
set
{
G = value.R;
B = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Blue and Red components of the vector.
/// </summary>
[XmlIgnore]
public bool2 BR
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(B, R);
set
{
B = value.R;
R = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Blue and Green components of the vector.
/// </summary>
[XmlIgnore]
public bool2 BG
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(B, G);
set
{
B = value.R;
G = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Red, Green, and Blue components of the vector.
/// </summary>
[XmlIgnore]
public bool3 RGB
{
readonly get => this;
set => this = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the Red, Blue, and Green components of the vector.
/// </summary>
[XmlIgnore]
public bool3 RBG
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(R, B, G);
set
{
R = value.R;
B = value.G;
G = value.B;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Green, Red, and Blue components of the vector.
/// </summary>
[XmlIgnore]
public bool3 GRB
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(G, R, B);
set
{
G = value.R;
R = value.G;
B = value.B;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Green, Blue, and Red components of the vector.
/// </summary>
[XmlIgnore]
public bool3 GBR
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(G, B, R);
set
{
G = value.R;
B = value.G;
R = value.B;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Blue, Red, and Green components of the vector.
/// </summary>
[XmlIgnore]
public bool3 BRG
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(B, R, G);
set
{
B = value.R;
R = value.G;
G = value.B;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Blue, Green, and Red components of the vector.
/// </summary>
[XmlIgnore]
public bool3 BGR
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(B, G, R);
set
{
B = value.R;
G = value.G;
R = value.B;
}
}
}

View file

@ -0,0 +1,28 @@
// <auto-generated /> - edit Vector.copy.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool4
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void CopyTo(Span<bool> destination)
{
if (destination.Length < ComponentCount)
throw new ArgumentException("Length must be at least 4.", nameof(destination));
Unsafe.WriteUnaligned(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(destination)), this);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool TryCopyTo(Span<bool> destination)
{
if (destination.Length < ComponentCount)
return false;
Unsafe.WriteUnaligned(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(destination)), this);
return true;
}
}

View file

@ -0,0 +1,41 @@
// <auto-generated /> - edit Vector.equality.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool4
{
/// <inheritdoc />
public readonly override int GetHashCode()
{
return HashCode.Combine(X, Y, Z, W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(bool4 other)
{
return X == other.X && Y == other.Y && Z == other.Z && W == other.W;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is bool4 other && Equals(other);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(bool4 a, bool4 b)
{
return a.Equals(b);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(bool4 a, bool4 b)
{
return !(a == b);
}
}

View file

@ -0,0 +1,38 @@
// <auto-generated /> - edit Vector.format.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool4 : ISpanFormattable, IUtf8SpanFormattable
{
/// <inheritdoc />
public readonly override string ToString()
{
return ToString("G", CultureInfo.CurrentCulture);
}
/// <inheritdoc cref="Vector4.ToString(string?)" />
public readonly string ToString(string? format)
{
return ToString(format, CultureInfo.CurrentCulture);
}
/// <inheritdoc />
public readonly string ToString(string? format, IFormatProvider? formatProvider)
{
var separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
return $"<{X.ToString()}{separator} {Y.ToString()}{separator} {Z.ToString()}{separator} {W.ToString()}>";
}
/// <inheritdoc />
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<bool4, bool>(this, destination, out charsWritten, format, provider);
}
/// <inheritdoc />
public readonly bool TryFormat(Span<byte> destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<bool4, bool>(this, destination, out bytesWritten, format, provider);
}
}

View file

@ -0,0 +1,146 @@
// <auto-generated /> - edit Vector.tt to modify
#nullable enable
namespace Brutal.Numerics;
/// <summary>
/// Implements a 4D vector with bool components.
/// </summary>
public partial struct bool4 : IVector4<bool4, bool>
, IBooleanVector<bool4, bool>
{
/// <inheritdoc />
public static int ComponentSize => sizeof(bool);
/// <summary>Gets the number of components.</summary>
public static int ComponentCount => 4;
/// <inheritdoc cref="Vector4.X" />
[XmlAttribute]
public bool X;
/// <inheritdoc cref="Vector4.Y" />
[XmlAttribute]
public bool Y;
/// <inheritdoc cref="Vector4.Z" />
[XmlAttribute]
public bool Z;
/// <inheritdoc cref="Vector4.W" />
[XmlAttribute]
public bool W;
bool IVector4<bool4, bool>.X { readonly get => X; set => X = value; }
bool IVector4<bool4, bool>.Y { readonly get => Y; set => Y = value; }
bool IVector4<bool4, bool>.Z { readonly get => Z; set => Z = value; }
bool IVector4<bool4, bool>.W { readonly get => W; set => W = value; }
/// <inheritdoc cref="Vector4(float, float, float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool4(bool x, bool y, bool z, bool w)
{
X = x;
Y = y;
Z = z;
W = w;
}
/// <inheritdoc cref="Vector4(float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool4(bool xyzw)
: this(xyzw, xyzw, xyzw, xyzw) { }
/// <inheritdoc cref="Vector4(Vector3, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool4(bool3 xyz, bool w)
: this(xyz.X, xyz.Y, xyz.Z, w) { }
/// <summary>
/// Creates a new instance of <see cref="bool4" /> from two <see cref="bool2" /> instances.
/// </summary>
/// <param name="xy">The first two components.</param>
/// <param name="zw">The last two components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool4(bool2 xy, bool2 zw)
: this(xy.X, xy.Y, zw.X, zw.Y) { }
/// <inheritdoc cref="Vector4(Vector2, float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool4(bool2 xy, bool z, bool w)
: this(xy.X, xy.Y, z, w) { }
/// <summary>Creates a vector from the leading 4 elements of a span.</summary>
/// <param name="span">The elements to read; must contain at least 4, and any beyond that are ignored.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="span" /> holds fewer than 4 elements.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool4(ReadOnlySpan<bool> span)
{
if (span.Length < 4)
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 4.");
this = Unsafe.ReadUnaligned<bool4>(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(span)));
}
/// <inheritdoc cref="bool4(ReadOnlySpan{bool})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool4 IComponentTuple<bool4, bool>.Create(ReadOnlySpan<bool> span) => new(span);
/// <inheritdoc />
public static bool4 UnitX => new(true, false, false, false);
/// <inheritdoc />
public static bool4 UnitY => new(false, true, false, false);
/// <inheritdoc />
public static bool4 UnitZ => new(false, false, true, false);
/// <inheritdoc />
public static bool4 UnitW => new(false, false, false, true);
/// <inheritdoc />
public bool this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
return Unsafe.Add(ref Unsafe.AsRef(in X), index);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
Unsafe.Add(ref X, index) = value;
}
}
public readonly void Deconstruct(out bool x, out bool y, out bool z, out bool w)
{
x = X;
y = Y;
z = Z;
w = W;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<bool> AsSpan()
{
return MemoryMarshal.CreateSpan(ref Unsafe.As<bool4, bool>(ref this), 4);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ReadOnlySpan<bool> AsReadOnlySpan()
{
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<bool4, bool>(ref Unsafe.AsRef(in this)), 4);
}
}

Some files were not shown because too many files have changed in this diff Show more