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

View file

@ -0,0 +1,28 @@
// <auto-generated /> - edit Vector.copy.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct double4
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void CopyTo(Span<double> destination)
{
if (destination.Length < ComponentCount)
throw new ArgumentException("Length must be at least 4.", nameof(destination));
Unsafe.WriteUnaligned(ref Unsafe.As<double, byte>(ref MemoryMarshal.GetReference(destination)), this);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool TryCopyTo(Span<double> destination)
{
if (destination.Length < ComponentCount)
return false;
Unsafe.WriteUnaligned(ref Unsafe.As<double, 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 double4
{
/// <inheritdoc />
public readonly override int GetHashCode()
{
return HashCode.Combine(X, Y, Z, W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(double4 other)
{
return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z) && W.Equals(other.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is double4 other && Equals(other);
}
/// <summary>IEEE lane-wise equality over every component: any NaN component makes this false (contrast <see cref="Equals(double4)" />, which is NaN-reflexive), and -0 equals +0.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(double4 a, double4 b)
{
return a.X == b.X && a.Y == b.Y && a.Z == b.Z && a.W == b.W;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(double4 a, double4 b)
{
return !(a == b);
}
}

View file

@ -0,0 +1,92 @@
// <auto-generated /> - edit Vector.format.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct double4 : ISpanFormattable, IUtf8SpanFormattable, ISpanParsable<double4>
{
/// <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(format, formatProvider)}{separator} {Y.ToString(format, formatProvider)}{separator} {Z.ToString(format, formatProvider)}{separator} {W.ToString(format, formatProvider)}>";
}
/// <inheritdoc />
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<double4, double>(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<double4, double>(this, destination, out bytesWritten, format, provider);
}
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
public static double4 Parse(string s, IFormatProvider? provider)
{
ArgumentNullException.ThrowIfNull(s);
return Parse(s.AsSpan(), NumberStyles.Float, provider);
}
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
public static double4 Parse(ReadOnlySpan<char> s, IFormatProvider? provider = null)
{
return Parse(s, NumberStyles.Float, provider);
}
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
public static double4 Parse(string s, NumberStyles style, IFormatProvider? provider)
{
ArgumentNullException.ThrowIfNull(s);
return Parse(s.AsSpan(), style, provider);
}
/// <summary>Parses from the <see cref="ToString()" /> format, <c>&lt;1, 2, 3&gt;</c>.</summary>
/// <exception cref="FormatException">The input is not in a valid format, or a component fails to parse.</exception>
public static double4 Parse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider)
{
if (!TryParse(s, style, provider, out var result))
throw new FormatException($"'{s}' is not in a valid double4 format.");
return result;
}
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out double4)" />
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out double4 result)
{
return TryParse(s.AsSpan(), NumberStyles.Float, provider, out result);
}
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out double4)" />
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out double4 result)
{
return TryParse(s, NumberStyles.Float, provider, out result);
}
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out double4)" />
public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out double4 result)
{
return TryParse(s.AsSpan(), style, provider, out result);
}
/// <summary>Parses from the <see cref="ToString()" /> format, <c>&lt;1, 2, 3&gt;</c>.</summary>
/// <returns>true if the input parsed as a double4.</returns>
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out double4 result)
{
return StringHelpers.TryParse<double4, double>(s, style, provider, out result);
}
}

View file

@ -0,0 +1,148 @@
// <auto-generated /> - edit Vector.tt to modify
#nullable enable
namespace Brutal.Numerics;
/// <summary>
/// Implements a 4D vector with double components.
/// </summary>
[DebuggerTypeProxy(typeof(VectorDebugView4<double4, double, double>))]
public partial struct double4 : IVector4<double4, double>
, IFloatingVector<double4, double>
, IFloatingVector4<double4, double, double2, double3, doubleQuat, double4x4>
{
/// <inheritdoc />
public static int ComponentSize => sizeof(double);
/// <summary>Gets the number of components.</summary>
public static int ComponentCount => 4;
/// <inheritdoc cref="Vector4.X" />
[XmlAttribute]
public double X;
/// <inheritdoc cref="Vector4.Y" />
[XmlAttribute]
public double Y;
/// <inheritdoc cref="Vector4.Z" />
[XmlAttribute]
public double Z;
/// <inheritdoc cref="Vector4.W" />
[XmlAttribute]
public double W;
double IVector4<double4, double>.X { readonly get => X; set => X = value; }
double IVector4<double4, double>.Y { readonly get => Y; set => Y = value; }
double IVector4<double4, double>.Z { readonly get => Z; set => Z = value; }
double IVector4<double4, double>.W { readonly get => W; set => W = value; }
/// <inheritdoc cref="Vector4(float, float, float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public double4(double x, double y, double z, double w)
{
X = x;
Y = y;
Z = z;
W = w;
}
/// <inheritdoc cref="Vector4(float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public double4(double xyzw)
: this(xyzw, xyzw, xyzw, xyzw) { }
/// <inheritdoc cref="Vector4(Vector3, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public double4(double3 xyz, double w)
: this(xyz.X, xyz.Y, xyz.Z, w) { }
/// <summary>
/// Creates a new instance of <see cref="double4" /> from two <see cref="double2" /> instances.
/// </summary>
/// <param name="xy">The first two components.</param>
/// <param name="zw">The last two components.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public double4(double2 xy, double2 zw)
: this(xy.X, xy.Y, zw.X, zw.Y) { }
/// <inheritdoc cref="Vector4(Vector2, float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public double4(double2 xy, double z, double 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 double4(ReadOnlySpan<double> span)
{
if (span.Length < 4)
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 4.");
this = Unsafe.ReadUnaligned<double4>(ref Unsafe.As<double, byte>(ref MemoryMarshal.GetReference(span)));
}
/// <inheritdoc cref="double4(ReadOnlySpan{double})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static double4 IComponentTuple<double4, double>.Create(ReadOnlySpan<double> span) => new(span);
/// <inheritdoc />
public static double4 UnitX => new(1, 0, 0, 0);
/// <inheritdoc />
public static double4 UnitY => new(0, 1, 0, 0);
/// <inheritdoc />
public static double4 UnitZ => new(0, 0, 1, 0);
/// <inheritdoc />
public static double4 UnitW => new(0, 0, 0, 1);
/// <inheritdoc />
public double 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 double x, out double y, out double z, out double w)
{
x = X;
y = Y;
z = Z;
w = W;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<double> AsSpan()
{
return MemoryMarshal.CreateSpan(ref Unsafe.As<double4, double>(ref this), 4);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ReadOnlySpan<double> AsReadOnlySpan()
{
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<double4, double>(ref Unsafe.AsRef(in this)), 4);
}
}

View file

@ -0,0 +1,62 @@
// <auto-generated /> - edit Vector.math-metric.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct double4
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly double Length()
{
return double.Sqrt(LengthSquared());
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly double LengthSquared()
{
return Dot(this, this);
}
/// <inheritdoc cref="Vector4.Distance" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double Distance(double4 a, double4 b)
{
return double.Sqrt(DistanceSquared(a, b));
}
/// <inheritdoc cref="Vector4.DistanceSquared" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double DistanceSquared(double4 a, double4 b)
{
var difference = a - b;
return Dot(difference, difference);
}
/// <inheritdoc cref="Vector4.Dot" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double Dot(double4 a, double4 b)
{
return a.X * b.X + a.Y * b.Y + a.Z * b.Z + a.W * b.W;
}
/// <inheritdoc cref="Vector4.Normalize" />
/// <exception cref="DivideByZeroException">Thrown when the input vector is a zero vector.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Normalize(double4 value)
{
var lengthSquared = Dot(value, value);
if (lengthSquared == 0)
throw new DivideByZeroException();
return value / double.Sqrt(lengthSquared);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 NormalizeOrZero(double4 value)
{
var length = double.Sqrt(Dot(value, value));
return length == 0 ? Zero : value / length;
}
}

View file

@ -0,0 +1,97 @@
// <auto-generated /> - edit Vector.math.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct double4
{
/// <inheritdoc cref="float4.Multiply(float4, float4x4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Multiply(double4 vector, double4x4 matrix)
{
var result = matrix.X * vector.X;
result += matrix.Y * vector.Y;
result += matrix.Z * vector.Z;
result += matrix.W * vector.W;
return result;
}
/// <inheritdoc cref="Multiply(double4, double4x4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator *(double4 vector, double4x4 matrix)
{
return Multiply(vector, matrix);
}
/// <summary>Reflects a vector off the hyperplane with the given unit normal.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Reflect(double4 vector, double4 normal)
{
return vector - 2 * Dot(vector, normal) * normal;
}
/// <inheritdoc cref="Vector4.Transform(Vector2, Matrix4x4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double2 position, double4x4 matrix)
{
var result = matrix.X * position.X;
result += matrix.Y * position.Y;
result += matrix.W;
return result;
}
/// <inheritdoc cref="Vector4.Transform(Vector2, Quaternion)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double2 value, doubleQuat rotation)
{
// widen in a register: x, y, 0, 1
var wide = Vector256.IsHardwareAccelerated
? Unsafe.BitCast<Vector256<double>, double4>(Vector256.Create(value.X, value.Y, 0.0, 1.0))
: new double4(value, 0, 1);
return Transform(wide, rotation);
}
/// <inheritdoc cref="Vector4.Transform(Vector3, Matrix4x4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double3 position, double4x4 matrix)
{
var result = matrix.X * position.X;
result += matrix.Y * position.Y;
result += matrix.Z * position.Z;
result += matrix.W;
return result;
}
/// <inheritdoc cref="Vector4.Transform(Vector3, Quaternion)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double3 value, doubleQuat rotation)
{
// widen in a register: x, y, z, 1
var wide = Vector256.IsHardwareAccelerated
? Unsafe.BitCast<Vector256<double>, double4>(Vector256.Create(value.X, value.Y, value.Z, 1.0))
: new double4(value, 1);
return Transform(wide, rotation);
}
/// <inheritdoc cref="Vector4.Transform(Vector4, Matrix4x4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double4 vector, double4x4 matrix)
{
return Multiply(vector, matrix);
}
/// <inheritdoc cref="Vector4.Transform(Vector4, Quaternion)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double4 value, doubleQuat rotation)
{
var conjugate = doubleQuat.Conjugate(rotation);
var temp = doubleQuat.Concatenate(conjugate, Unsafe.BitCast<double4, doubleQuat>(value));
return Unsafe.BitCast<doubleQuat, double4>(doubleQuat.Concatenate(temp, rotation));
}
}

View file

@ -0,0 +1,54 @@
// <auto-generated /> - edit Vector.numerics-binary.tt to modify
#nullable enable
namespace Brutal.Numerics;
// IBinaryNumber
public partial struct double4 : IBinaryNumber<double4>
{
/// <summary>Determines if every component of a value is a power of two.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool IBinaryNumber<double4>.IsPow2(double4 value)
{
return double.IsPow2(value.X) && double.IsPow2(value.Y) && double.IsPow2(value.Z) && double.IsPow2(value.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static double4 IBitwiseOperators<double4, double4, double4>.operator &(double4 a, double4 b)
{
return Unsafe.BitCast<long4, double4>(Unsafe.BitCast<double4, long4>(a) & Unsafe.BitCast<double4, long4>(b));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static double4 IBitwiseOperators<double4, double4, double4>.operator |(double4 a, double4 b)
{
return Unsafe.BitCast<long4, double4>(Unsafe.BitCast<double4, long4>(a) | Unsafe.BitCast<double4, long4>(b));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static double4 IBitwiseOperators<double4, double4, double4>.operator ^(double4 a, double4 b)
{
return Unsafe.BitCast<long4, double4>(Unsafe.BitCast<double4, long4>(a) ^ Unsafe.BitCast<double4, long4>(b));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static double4 IBitwiseOperators<double4, double4, double4>.operator ~(double4 value)
{
return Unsafe.BitCast<long4, double4>(~Unsafe.BitCast<double4, long4>(value));
}
}
// the componentwise predicate mask (no interface to mirror) - the per-lane truth IsPow2 collapses
public partial struct double4
{
/// <summary>Determines which components of a value are powers of two.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsPow2(double4 value)
{
return new bool4(double.IsPow2(value.X), double.IsPow2(value.Y), double.IsPow2(value.Z), double.IsPow2(value.W));
}
}

View file

@ -0,0 +1,443 @@
// <auto-generated /> - edit Vector.numerics-floating.tt to modify
#nullable enable
namespace Brutal.Numerics;
// IFloatingPointConstants
public partial struct double4 : IFloatingPointConstants<double4>
{
/// <inheritdoc />
public static double4 E => new(double.E);
/// <inheritdoc />
public static double4 Pi => new(double.Pi);
/// <inheritdoc />
public static double4 Tau => new(double.Tau);
}
// IExponentialFunctions
public partial struct double4 : IExponentialFunctions<double4>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Exp(double4 value)
{
return new(double.Exp(value.X), double.Exp(value.Y), double.Exp(value.Z), double.Exp(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Exp2(double4 value)
{
return new double4(double.Exp2(value.X), double.Exp2(value.Y), double.Exp2(value.Z), double.Exp2(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Exp10(double4 value)
{
return new double4(double.Exp10(value.X), double.Exp10(value.Y), double.Exp10(value.Z), double.Exp10(value.W));
}
}
// ILogarithmicFunctions
public partial struct double4 : ILogarithmicFunctions<double4>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Log(double4 value)
{
return new(double.Log(value.X), double.Log(value.Y), double.Log(value.Z), double.Log(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Log(double4 value, double4 newBase)
{
return new double4(double.Log(value.X, newBase.X), double.Log(value.Y, newBase.Y), double.Log(value.Z, newBase.Z), double.Log(value.W, newBase.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Log2(double4 value)
{
return new(double.Log2(value.X), double.Log2(value.Y), double.Log2(value.Z), double.Log2(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Log10(double4 value)
{
return new double4(double.Log10(value.X), double.Log10(value.Y), double.Log10(value.Z), double.Log10(value.W));
}
}
// IPowerFunctions
public partial struct double4 : IPowerFunctions<double4>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Pow(double4 value, double4 power)
{
return new double4(double.Pow(value.X, power.X), double.Pow(value.Y, power.Y), double.Pow(value.Z, power.Z), double.Pow(value.W, power.W));
}
}
// IRootFunctions
public partial struct double4 : IRootFunctions<double4>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Cbrt(double4 value)
{
return new double4(double.Cbrt(value.X), double.Cbrt(value.Y), double.Cbrt(value.Z), double.Cbrt(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Hypot(double4 a, double4 b)
{
return new(double.Hypot(a.X, b.X), double.Hypot(a.Y, b.Y), double.Hypot(a.Z, b.Z), double.Hypot(a.W, b.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 RootN(double4 value, int n)
{
return new double4(double.RootN(value.X, n), double.RootN(value.Y, n), double.RootN(value.Z, n), double.RootN(value.W, n));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Sqrt(double4 value)
{
return new(double.Sqrt(value.X), double.Sqrt(value.Y), double.Sqrt(value.Z), double.Sqrt(value.W));
}
}
// ITrigonometricFunctions
public partial struct double4 : ITrigonometricFunctions<double4>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Sin(double4 value)
{
return new(double.Sin(value.X), double.Sin(value.Y), double.Sin(value.Z), double.Sin(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Cos(double4 value)
{
return new(double.Cos(value.X), double.Cos(value.Y), double.Cos(value.Z), double.Cos(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static (double4 Sin, double4 Cos) SinCos(double4 value)
{
var (sinX, cosX) = double.SinCos(value.X);
var (sinY, cosY) = double.SinCos(value.Y);
var (sinZ, cosZ) = double.SinCos(value.Z);
var (sinW, cosW) = double.SinCos(value.W);
return (new(sinX, sinY, sinZ, sinW), new(cosX, cosY, cosZ, cosW));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Tan(double4 value)
{
return new double4(double.Tan(value.X), double.Tan(value.Y), double.Tan(value.Z), double.Tan(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Asin(double4 value)
{
return new double4(double.Asin(value.X), double.Asin(value.Y), double.Asin(value.Z), double.Asin(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Acos(double4 value)
{
return new double4(double.Acos(value.X), double.Acos(value.Y), double.Acos(value.Z), double.Acos(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Atan(double4 value)
{
return new double4(double.Atan(value.X), double.Atan(value.Y), double.Atan(value.Z), double.Atan(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 SinPi(double4 value)
{
return new double4(double.SinPi(value.X), double.SinPi(value.Y), double.SinPi(value.Z), double.SinPi(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 CosPi(double4 value)
{
return new double4(double.CosPi(value.X), double.CosPi(value.Y), double.CosPi(value.Z), double.CosPi(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 TanPi(double4 value)
{
return new double4(double.TanPi(value.X), double.TanPi(value.Y), double.TanPi(value.Z), double.TanPi(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 AsinPi(double4 value)
{
return new double4(double.AsinPi(value.X), double.AsinPi(value.Y), double.AsinPi(value.Z), double.AsinPi(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 AcosPi(double4 value)
{
return new double4(double.AcosPi(value.X), double.AcosPi(value.Y), double.AcosPi(value.Z), double.AcosPi(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 AtanPi(double4 value)
{
return new double4(double.AtanPi(value.X), double.AtanPi(value.Y), double.AtanPi(value.Z), double.AtanPi(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static (double4 SinPi, double4 CosPi) SinCosPi(double4 value)
{
return (SinPi(value), CosPi(value));
}
/// <inheritdoc cref="double.DegreesToRadians" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 DegreesToRadians(double4 degrees)
{
return new(double.DegreesToRadians(degrees.X), double.DegreesToRadians(degrees.Y), double.DegreesToRadians(degrees.Z), double.DegreesToRadians(degrees.W));
}
/// <inheritdoc cref="double.RadiansToDegrees" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 RadiansToDegrees(double4 radians)
{
return new(double.RadiansToDegrees(radians.X), double.RadiansToDegrees(radians.Y), double.RadiansToDegrees(radians.Z), double.RadiansToDegrees(radians.W));
}
}
// IHyperbolicFunctions
public partial struct double4 : IHyperbolicFunctions<double4>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Sinh(double4 value)
{
return new double4(double.Sinh(value.X), double.Sinh(value.Y), double.Sinh(value.Z), double.Sinh(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Cosh(double4 value)
{
return new double4(double.Cosh(value.X), double.Cosh(value.Y), double.Cosh(value.Z), double.Cosh(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Tanh(double4 value)
{
return new double4(double.Tanh(value.X), double.Tanh(value.Y), double.Tanh(value.Z), double.Tanh(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Asinh(double4 value)
{
return new double4(double.Asinh(value.X), double.Asinh(value.Y), double.Asinh(value.Z), double.Asinh(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Acosh(double4 value)
{
return new double4(double.Acosh(value.X), double.Acosh(value.Y), double.Acosh(value.Z), double.Acosh(value.W));
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Atanh(double4 value)
{
return new double4(double.Atanh(value.X), double.Atanh(value.Y), double.Atanh(value.Z), double.Atanh(value.W));
}
}
// IFloatingPoint
public partial struct double4 : IFloatingPoint<double4>
{
/// <inheritdoc cref="double.Floor(double)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Floor(double4 value)
{
return new(double.Floor(value.X), double.Floor(value.Y), double.Floor(value.Z), double.Floor(value.W));
}
/// <inheritdoc cref="double.Ceiling(double)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Ceiling(double4 value)
{
return new(double.Ceiling(value.X), double.Ceiling(value.Y), double.Ceiling(value.Z), double.Ceiling(value.W));
}
/// <inheritdoc cref="double.Round(double)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Round(double4 value)
{
return new(double.Round(value.X), double.Round(value.Y), double.Round(value.Z), double.Round(value.W));
}
/// <inheritdoc cref="double.Truncate(double)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Truncate(double4 value)
{
return new(double.Truncate(value.X), double.Truncate(value.Y), double.Truncate(value.Z), double.Truncate(value.W));
}
/// <inheritdoc cref="double.Round(double, int, MidpointRounding)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Round(double4 value, int digits, MidpointRounding mode)
{
return new double4(double.Round(value.X, digits, mode), double.Round(value.Y, digits, mode), double.Round(value.Z, digits, mode), double.Round(value.W, digits, mode));
}
// One exponent and significand PER LANE, so there is no single honest answer: explicit and throwing.
int IFloatingPoint<double4>.GetExponentByteCount() =>
throw new NotSupportedException($"{nameof(double4)} has one exponent per component.");
int IFloatingPoint<double4>.GetExponentShortestBitLength() =>
throw new NotSupportedException($"{nameof(double4)} has one exponent per component.");
int IFloatingPoint<double4>.GetSignificandBitLength() =>
throw new NotSupportedException($"{nameof(double4)} has one significand per component.");
int IFloatingPoint<double4>.GetSignificandByteCount() =>
throw new NotSupportedException($"{nameof(double4)} has one significand per component.");
bool IFloatingPoint<double4>.TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten) =>
throw new NotSupportedException($"{nameof(double4)} has one exponent per component.");
bool IFloatingPoint<double4>.TryWriteExponentLittleEndian(Span<byte> destination, out int bytesWritten) =>
throw new NotSupportedException($"{nameof(double4)} has one exponent per component.");
bool IFloatingPoint<double4>.TryWriteSignificandBigEndian(Span<byte> destination, out int bytesWritten) =>
throw new NotSupportedException($"{nameof(double4)} has one significand per component.");
bool IFloatingPoint<double4>.TryWriteSignificandLittleEndian(Span<byte> destination, out int bytesWritten) =>
throw new NotSupportedException($"{nameof(double4)} has one significand per component.");
}
// IFloatingPointIeee754
public partial struct double4 : IFloatingPointIeee754<double4>
{
/// <summary>Gets a vector whose components are NaN.</summary>
public static double4 NaN => new(double.NaN);
/// <inheritdoc cref="double.Epsilon" />
public static double4 Epsilon => new(double.Epsilon);
/// <inheritdoc cref="double.NegativeZero" />
public static double4 NegativeZero => new(double.NegativeZero);
/// <inheritdoc cref="double.PositiveInfinity" />
public static double4 PositiveInfinity => new(double.PositiveInfinity);
/// <inheritdoc cref="double.NegativeInfinity" />
public static double4 NegativeInfinity => new(double.NegativeInfinity);
/// <inheritdoc cref="double.Atan2" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Atan2(double4 y, double4 x)
{
return new double4(double.Atan2(y.X, x.X), double.Atan2(y.Y, x.Y), double.Atan2(y.Z, x.Z), double.Atan2(y.W, x.W));
}
/// <inheritdoc cref="double.Atan2Pi" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Atan2Pi(double4 y, double4 x)
{
return new double4(double.Atan2Pi(y.X, x.X), double.Atan2Pi(y.Y, x.Y), double.Atan2Pi(y.Z, x.Z), double.Atan2Pi(y.W, x.W));
}
/// <inheritdoc cref="double.BitDecrement" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 BitDecrement(double4 value)
{
return new double4(double.BitDecrement(value.X), double.BitDecrement(value.Y), double.BitDecrement(value.Z), double.BitDecrement(value.W));
}
/// <inheritdoc cref="double.BitIncrement" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 BitIncrement(double4 value)
{
return new double4(double.BitIncrement(value.X), double.BitIncrement(value.Y), double.BitIncrement(value.Z), double.BitIncrement(value.W));
}
/// <inheritdoc cref="double.FusedMultiplyAdd" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 FusedMultiplyAdd(double4 a, double4 b, double4 addend)
{
return new(double.FusedMultiplyAdd(a.X, b.X, addend.X), double.FusedMultiplyAdd(a.Y, b.Y, addend.Y), double.FusedMultiplyAdd(a.Z, b.Z, addend.Z), double.FusedMultiplyAdd(a.W, b.W, addend.W));
}
/// <inheritdoc cref="double.MultiplyAddEstimate" />
/// <remarks>Permitted but not required to fuse; use <see cref="FusedMultiplyAdd" /> where the single rounding is required.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 MultiplyAddEstimate(double4 a, double4 b, double4 addend)
{
return new(double.MultiplyAddEstimate(a.X, b.X, addend.X), double.MultiplyAddEstimate(a.Y, b.Y, addend.Y), double.MultiplyAddEstimate(a.Z, b.Z, addend.Z), double.MultiplyAddEstimate(a.W, b.W, addend.W));
}
/// <inheritdoc cref="double.Ieee754Remainder" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Ieee754Remainder(double4 a, double4 b)
{
return new double4(double.Ieee754Remainder(a.X, b.X), double.Ieee754Remainder(a.Y, b.Y), double.Ieee754Remainder(a.Z, b.Z), double.Ieee754Remainder(a.W, b.W));
}
/// <inheritdoc cref="double.ScaleB" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 ScaleB(double4 value, int n)
{
return new double4(double.ScaleB(value.X, n), double.ScaleB(value.Y, n), double.ScaleB(value.Z, n), double.ScaleB(value.W, n));
}
// ILogB's int return cannot hold one exponent per lane - same shape as Sign
static int IFloatingPointIeee754<double4>.ILogB(double4 value) =>
throw new NotSupportedException($"{nameof(double4)} has one exponent per component.");
/// <inheritdoc cref="Vector4.Lerp(Vector4, Vector4, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Lerp(double4 a, double4 b, double amount)
{
return new(double.Lerp(a.X, b.X, amount), double.Lerp(a.Y, b.Y, amount), double.Lerp(a.Z, b.Z, amount), double.Lerp(a.W, b.W, amount));
}
/// <inheritdoc cref="Sqrt" />
[Obsolete("Renamed to Sqrt (the generic-math name; SquareRoot was the System.Numerics vector spelling).")]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 SquareRoot(double4 value)
{
return Sqrt(value);
}
}

View file

@ -0,0 +1,545 @@
// <auto-generated /> - edit Vector.numerics.tt to modify
#nullable enable
namespace Brutal.Numerics;
// INumberBase
public partial struct double4 : INumberBase<double4>
{
/// <inheritdoc />
public static double4 Zero => new(0);
/// <inheritdoc />
public static double4 One => new(1);
static double4 IAdditiveIdentity<double4, double4>.AdditiveIdentity => Zero;
static double4 IMultiplicativeIdentity<double4, double4>.MultiplicativeIdentity => One;
static int INumberBase<double4>.Radix => 2; // every component type is binary
/// <inheritdoc cref="Vector4.Abs" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Abs(double4 value)
{
return new(double.Abs(value.X), double.Abs(value.Y), double.Abs(value.Z), double.Abs(value.W));
}
static bool INumberBase<double4>.IsCanonical(double4 value) => true;
static bool INumberBase<double4>.IsComplexNumber(double4 value) => false;
static bool INumberBase<double4>.IsImaginaryNumber(double4 value) => false;
/// <summary>Determines if every component of a value is zero.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsZero(double4 value)
{
return value == Zero;
}
/// <summary>Determines if every component of a value is an even integral value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsEvenInteger(double4 value)
{
return double.IsEvenInteger(value.X) && double.IsEvenInteger(value.Y) && double.IsEvenInteger(value.Z) && double.IsEvenInteger(value.W);
}
/// <summary>Determines if every component of a value is an odd integral value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsOddInteger(double4 value)
{
return double.IsOddInteger(value.X) && double.IsOddInteger(value.Y) && double.IsOddInteger(value.Z) && double.IsOddInteger(value.W);
}
/// <summary>Determines if every component of a value is negative.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsNegative(double4 value)
{
return double.IsNegative(value.X) && double.IsNegative(value.Y) && double.IsNegative(value.Z) && double.IsNegative(value.W);
}
/// <summary>Determines if every component of a value is positive.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsPositive(double4 value)
{
return double.IsPositive(value.X) && double.IsPositive(value.Y) && double.IsPositive(value.Z) && double.IsPositive(value.W);
}
/// <summary>Determines if every component of a value is finite.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsFinite(double4 value)
{
return double.IsFinite(value.X) && double.IsFinite(value.Y) && double.IsFinite(value.Z) && double.IsFinite(value.W);
}
/// <summary>Determines if every component of a value is infinite.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsInfinity(double4 value)
{
return double.IsInfinity(value.X) && double.IsInfinity(value.Y) && double.IsInfinity(value.Z) && double.IsInfinity(value.W);
}
/// <summary>Determines if every component of a value is negative infinity.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsNegativeInfinity(double4 value)
{
return double.IsNegativeInfinity(value.X) && double.IsNegativeInfinity(value.Y) && double.IsNegativeInfinity(value.Z) && double.IsNegativeInfinity(value.W);
}
/// <summary>Determines if every component of a value is positive infinity.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsPositiveInfinity(double4 value)
{
return double.IsPositiveInfinity(value.X) && double.IsPositiveInfinity(value.Y) && double.IsPositiveInfinity(value.Z) && double.IsPositiveInfinity(value.W);
}
/// <summary>Determines if every component of a value is an integral value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsInteger(double4 value)
{
return double.IsInteger(value.X) && double.IsInteger(value.Y) && double.IsInteger(value.Z) && double.IsInteger(value.W);
}
/// <summary>Determines if every component of a value is a real value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsRealNumber(double4 value)
{
return double.IsRealNumber(value.X) && double.IsRealNumber(value.Y) && double.IsRealNumber(value.Z) && double.IsRealNumber(value.W);
}
/// <summary>Determines if any component of a value is NaN.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsNaN(double4 value)
{
return double.IsNaN(value.X) || double.IsNaN(value.Y) || double.IsNaN(value.Z) || double.IsNaN(value.W);
}
/// <summary>Determines if every component of a value is normal.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsNormal(double4 value)
{
return double.IsNormal(value.X) && double.IsNormal(value.Y) && double.IsNormal(value.Z) && double.IsNormal(value.W);
}
/// <summary>Determines if every component of a value is subnormal.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool INumberBase<double4>.IsSubnormal(double4 value)
{
return double.IsSubnormal(value.X) && double.IsSubnormal(value.Y) && double.IsSubnormal(value.Z) && double.IsSubnormal(value.W);
}
/// <summary>Computes, componentwise, the value whose magnitude is greater.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 MaxMagnitude(double4 a, double4 b)
{
return new(double.MaxMagnitude(a.X, b.X), double.MaxMagnitude(a.Y, b.Y), double.MaxMagnitude(a.Z, b.Z), double.MaxMagnitude(a.W, b.W));
}
/// <summary>Computes, componentwise, the value whose magnitude is greater, preferring numbers over NaN.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 MaxMagnitudeNumber(double4 a, double4 b)
{
return new(double.MaxMagnitudeNumber(a.X, b.X), double.MaxMagnitudeNumber(a.Y, b.Y), double.MaxMagnitudeNumber(a.Z, b.Z), double.MaxMagnitudeNumber(a.W, b.W));
}
/// <summary>Computes, componentwise, the value whose magnitude is smaller.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 MinMagnitude(double4 a, double4 b)
{
return new(double.MinMagnitude(a.X, b.X), double.MinMagnitude(a.Y, b.Y), double.MinMagnitude(a.Z, b.Z), double.MinMagnitude(a.W, b.W));
}
/// <summary>Computes, componentwise, the value whose magnitude is smaller, preferring numbers over NaN.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 MinMagnitudeNumber(double4 a, double4 b)
{
return new(double.MinMagnitudeNumber(a.X, b.X), double.MinMagnitudeNumber(a.Y, b.Y), double.MinMagnitudeNumber(a.Z, b.Z), double.MinMagnitudeNumber(a.W, b.W));
}
/// <inheritdoc cref="Vector4.Add" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Add(double4 a, double4 b)
{
return a + b;
}
/// <inheritdoc cref="Vector4.Divide(Vector4, Vector4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Divide(double4 a, double4 b)
{
return a / b;
}
/// <inheritdoc cref="Vector4.Multiply(Vector4, Vector4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Multiply(double4 a, double4 b)
{
return a * b;
}
/// <inheritdoc cref="Vector4.Negate" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Negate(double4 value)
{
return -value;
}
/// <inheritdoc cref="Vector4.Subtract" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Subtract(double4 a, double4 b)
{
return a - b;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator +(double4 a, double4 b)
{
return new(a.X + b.X, a.Y + b.Y, a.Z + b.Z, a.W + b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator -(double4 a, double4 b)
{
return new(a.X - b.X, a.Y - b.Y, a.Z - b.Z, a.W - b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator *(double4 a, double4 b)
{
return new(a.X * b.X, a.Y * b.Y, a.Z * b.Z, a.W * b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator /(double4 a, double4 b)
{
return new(a.X / b.X, a.Y / b.Y, a.Z / b.Z, a.W / b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator -(double4 a)
{
return new(-a.X, -a.Y, -a.Z, -a.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator +(double4 a)
{
return a;
}
// ++/-- are well-defined (+/- One) but a footgun on a concrete vector: generic-plane only.
static double4 IIncrementOperators<double4>.operator ++(double4 value) => value + One;
static double4 IDecrementOperators<double4>.operator --(double4 value) => value - One;
static bool INumberBase<double4>.TryConvertFromChecked<TOther>(TOther value, out double4 result)
{
return NumberConversion.TryConvertFrom<double4, double, TOther, NumberConversion.Checked>(value, out result);
}
static bool INumberBase<double4>.TryConvertToChecked<TOther>(double4 value, [MaybeNullWhen(false)] out TOther result)
{
result = default;
return false;
}
static bool INumberBase<double4>.TryConvertFromSaturating<TOther>(TOther value, out double4 result)
{
return NumberConversion.TryConvertFrom<double4, double, TOther, NumberConversion.Saturating>(value, out result);
}
static bool INumberBase<double4>.TryConvertToSaturating<TOther>(double4 value, [MaybeNullWhen(false)] out TOther result)
{
result = default;
return false;
}
static bool INumberBase<double4>.TryConvertFromTruncating<TOther>(TOther value, out double4 result)
{
return NumberConversion.TryConvertFrom<double4, double, TOther, NumberConversion.Truncating>(value, out result);
}
static bool INumberBase<double4>.TryConvertToTruncating<TOther>(double4 value, [MaybeNullWhen(false)] out TOther result)
{
result = default;
return false;
}
}
// IMultiplyOperators<TSelf, TComponent, TSelf>, IDivisionOperators<TSelf, TComponent, TSelf>
public partial struct double4
: IMultiplyOperators<double4, double, double4>
, IDivisionOperators<double4, double, double4>
{
/// <inheritdoc cref="Vector4.Divide(Vector4, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Divide(double4 a, double b)
{
return a / b;
}
/// <inheritdoc cref="Vector4.Multiply(Vector4, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Multiply(double4 a, double b)
{
return a * b;
}
/// <inheritdoc cref="Vector4.Multiply(float, Vector4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Multiply(double a, double4 b)
{
return a * b;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator *(double4 a, double b)
{
return new(a.X * b, a.Y * b, a.Z * b, a.W * b);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator /(double4 a, double b)
{
return new(a.X / b, a.Y / b, a.Z / b, a.W / b);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator *(double a, double4 b)
{
return new(a * b.X, a * b.Y, a * b.Z, a * b.W);
}
}
// INumber
public partial struct double4 : INumber<double4>
{
/// <inheritdoc cref="Vector4.Clamp" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Clamp(double4 value, double4 min, double4 max)
{
// HLSL contract when min > max: max wins (clamp is Max-then-Min); pinned in
// Clamp_InvertedBounds_MatchesBcl. NOT scalar T.Clamp, which throws on inversion.
return Min(Max(value, min), max);
}
/// <inheritdoc cref="Vector4.Max" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Max(double4 a, double4 b)
{
return new(double.Max(a.X, b.X), double.Max(a.Y, b.Y), double.Max(a.Z, b.Z), double.Max(a.W, b.W));
}
/// <inheritdoc cref="Vector4.Min" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Min(double4 a, double4 b)
{
return new(double.Min(a.X, b.X), double.Min(a.Y, b.Y), double.Min(a.Z, b.Z), double.Min(a.W, b.W));
}
/// <summary>Selects, componentwise, the larger value, preferring numbers over NaN.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 MaxNumber(double4 a, double4 b)
{
return new(double.MaxNumber(a.X, b.X), double.MaxNumber(a.Y, b.Y), double.MaxNumber(a.Z, b.Z), double.MaxNumber(a.W, b.W));
}
/// <summary>Selects, componentwise, the smaller value, preferring numbers over NaN.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 MinNumber(double4 a, double4 b)
{
return new(double.MinNumber(a.X, b.X), double.MinNumber(a.Y, b.Y), double.MinNumber(a.Z, b.Z), double.MinNumber(a.W, b.W));
}
/// <summary>Copies, componentwise, the sign of <paramref name="sign" /> onto the magnitude of <paramref name="value" />.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 CopySign(double4 value, double4 sign)
{
return new(double.CopySign(value.X, sign.X), double.CopySign(value.Y, sign.Y), double.CopySign(value.Z, sign.Z), double.CopySign(value.W, sign.W));
}
// the Native variants permit either NaN/signed-zero behavior - forwarding is always legal
static double4 INumber<double4>.ClampNative(double4 value, double4 min, double4 max) => Clamp(value, min, max);
static double4 INumber<double4>.MaxNative(double4 a, double4 b) => Max(a, b);
static double4 INumber<double4>.MinNative(double4 a, double4 b) => Min(a, b);
// Sign's int return cannot hold a per-lane answer, and a collapsed one would lie for mixed signs
static int INumber<double4>.Sign(double4 value) =>
throw new NotSupportedException($"{nameof(double4)} has no scalar sign.");
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator %(double4 a, double4 b)
{
return new double4(a.X % b.X, a.Y % b.Y, a.Z % b.Z, a.W % b.W);
}
int IComparable.CompareTo(object? obj) =>
throw new NotSupportedException($"{nameof(double4)} has no total order.");
int IComparable<double4>.CompareTo(double4 other) =>
throw new NotSupportedException($"{nameof(double4)} has no total order.");
static bool IComparisonOperators<double4, double4, bool>.operator <(double4 a, double4 b) =>
throw new NotSupportedException($"{nameof(double4)} has no total order.");
static bool IComparisonOperators<double4, double4, bool>.operator <=(double4 a, double4 b) =>
throw new NotSupportedException($"{nameof(double4)} has no total order.");
static bool IComparisonOperators<double4, double4, bool>.operator >(double4 a, double4 b) =>
throw new NotSupportedException($"{nameof(double4)} has no total order.");
static bool IComparisonOperators<double4, double4, bool>.operator >=(double4 a, double4 b) =>
throw new NotSupportedException($"{nameof(double4)} has no total order.");
}
// IComponentwiseComparison + the componentwise predicate masks (no interface to mirror)
public partial struct double4 : IComponentwiseComparison<double4, bool4>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 operator <(double4 a, double4 b)
{
return new bool4(a.X < b.X, a.Y < b.Y, a.Z < b.Z, a.W < b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 operator <=(double4 a, double4 b)
{
return new bool4(a.X <= b.X, a.Y <= b.Y, a.Z <= b.Z, a.W <= b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 operator >(double4 a, double4 b)
{
return new bool4(a.X > b.X, a.Y > b.Y, a.Z > b.Z, a.W > b.W);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 operator >=(double4 a, double4 b)
{
return new bool4(a.X >= b.X, a.Y >= b.Y, a.Z >= b.Z, a.W >= b.W);
}
/// <summary>Determines which components of a value are zero.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsZero(double4 value)
{
return new bool4(value.X == 0, value.Y == 0, value.Z == 0, value.W == 0);
}
/// <summary>Determines which components of a value are an even integral value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsEvenInteger(double4 value)
{
return new bool4(double.IsEvenInteger(value.X), double.IsEvenInteger(value.Y), double.IsEvenInteger(value.Z), double.IsEvenInteger(value.W));
}
/// <summary>Determines which components of a value are an odd integral value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsOddInteger(double4 value)
{
return new bool4(double.IsOddInteger(value.X), double.IsOddInteger(value.Y), double.IsOddInteger(value.Z), double.IsOddInteger(value.W));
}
/// <summary>Determines which components of a value are negative.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsNegative(double4 value)
{
return new bool4(double.IsNegative(value.X), double.IsNegative(value.Y), double.IsNegative(value.Z), double.IsNegative(value.W));
}
/// <summary>Determines which components of a value are positive.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsPositive(double4 value)
{
return new bool4(double.IsPositive(value.X), double.IsPositive(value.Y), double.IsPositive(value.Z), double.IsPositive(value.W));
}
/// <summary>Determines which components of a value are finite.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsFinite(double4 value)
{
return new bool4(double.IsFinite(value.X), double.IsFinite(value.Y), double.IsFinite(value.Z), double.IsFinite(value.W));
}
/// <summary>Determines which components of a value are infinite.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsInfinity(double4 value)
{
return new bool4(double.IsInfinity(value.X), double.IsInfinity(value.Y), double.IsInfinity(value.Z), double.IsInfinity(value.W));
}
/// <summary>Determines which components of a value are negative infinity.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsNegativeInfinity(double4 value)
{
return new bool4(double.IsNegativeInfinity(value.X), double.IsNegativeInfinity(value.Y), double.IsNegativeInfinity(value.Z), double.IsNegativeInfinity(value.W));
}
/// <summary>Determines which components of a value are positive infinity.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsPositiveInfinity(double4 value)
{
return new bool4(double.IsPositiveInfinity(value.X), double.IsPositiveInfinity(value.Y), double.IsPositiveInfinity(value.Z), double.IsPositiveInfinity(value.W));
}
/// <summary>Determines which components of a value are an integral value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsInteger(double4 value)
{
return new bool4(double.IsInteger(value.X), double.IsInteger(value.Y), double.IsInteger(value.Z), double.IsInteger(value.W));
}
/// <summary>Determines which components of a value are a real value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsRealNumber(double4 value)
{
return new bool4(double.IsRealNumber(value.X), double.IsRealNumber(value.Y), double.IsRealNumber(value.Z), double.IsRealNumber(value.W));
}
/// <summary>Determines which components of a value are NaN.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsNaN(double4 value)
{
return new bool4(double.IsNaN(value.X), double.IsNaN(value.Y), double.IsNaN(value.Z), double.IsNaN(value.W));
}
/// <summary>Determines which components of a value are normal.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsNormal(double4 value)
{
return new bool4(double.IsNormal(value.X), double.IsNormal(value.Y), double.IsNormal(value.Z), double.IsNormal(value.W));
}
/// <summary>Determines which components of a value are subnormal.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 IsSubnormal(double4 value)
{
return new bool4(double.IsSubnormal(value.X), double.IsSubnormal(value.Y), double.IsSubnormal(value.Z), double.IsSubnormal(value.W));
}
}
// ISignedNumber
public partial struct double4 : ISignedNumber<double4>
{
/// <inheritdoc />
public static double4 NegativeOne => new(-1);
}

View file

@ -0,0 +1,210 @@
// <auto-generated /> - edit Vector.pack.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct double4
{
public static double4 Unpack(in sbyte4 vector, Func<sbyte, double> elementConverter)
{
VectorPack.Pack(vector, out double4 result, elementConverter);
return result;
}
public static double4 Unpack(in byte4 vector, Func<byte, double> elementConverter)
{
VectorPack.Pack(vector, out double4 result, elementConverter);
return result;
}
public static double4 Unpack(in short4 vector, Func<short, double> elementConverter)
{
VectorPack.Pack(vector, out double4 result, elementConverter);
return result;
}
public static double4 Unpack(in ushort4 vector, Func<ushort, double> elementConverter)
{
VectorPack.Pack(vector, out double4 result, elementConverter);
return result;
}
public static double4 Unpack(in int4 vector, Func<int, double> elementConverter)
{
VectorPack.Pack(vector, out double4 result, elementConverter);
return result;
}
public static double4 Unpack(in uint4 vector, Func<uint, double> elementConverter)
{
VectorPack.Pack(vector, out double4 result, elementConverter);
return result;
}
public static double4 Unpack(in float4 vector, Func<float, double> elementConverter)
{
VectorPack.Pack(vector, out double4 result, elementConverter);
return result;
}
public static double4 Unpack(in sbyte4 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
{
return Unpack(vector, PackUtils.SByte.ToDouble(mode));
}
public static double4 Unpack(in byte4 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
{
return Unpack(vector, PackUtils.Byte.ToDouble(mode));
}
public static double4 Unpack(in short4 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
{
return Unpack(vector, PackUtils.Short.ToDouble(mode));
}
public static double4 Unpack(in ushort4 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
{
return Unpack(vector, PackUtils.UShort.ToDouble(mode));
}
public static double4 Unpack(in int4 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
{
return Unpack(vector, PackUtils.Int.ToDouble(mode));
}
public static double4 Unpack(in uint4 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
{
return Unpack(vector, PackUtils.UInt.ToDouble(mode));
}
public static double4 Unpack(in float4 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
{
return Unpack(vector, PackUtils.Float.ToDouble(mode));
}
public static void UnpackSpan(
in ReadOnlySpan<sbyte4> source,
Span<double4> destination,
Func<sbyte, double> elementConverter
)
{
VectorPack.Pack(source, destination, elementConverter);
}
public static void UnpackSpan(
in ReadOnlySpan<byte4> source,
Span<double4> destination,
Func<byte, double> elementConverter
)
{
VectorPack.Pack(source, destination, elementConverter);
}
public static void UnpackSpan(
in ReadOnlySpan<short4> source,
Span<double4> destination,
Func<short, double> elementConverter
)
{
VectorPack.Pack(source, destination, elementConverter);
}
public static void UnpackSpan(
in ReadOnlySpan<ushort4> source,
Span<double4> destination,
Func<ushort, double> elementConverter
)
{
VectorPack.Pack(source, destination, elementConverter);
}
public static void UnpackSpan(
in ReadOnlySpan<int4> source,
Span<double4> destination,
Func<int, double> elementConverter
)
{
VectorPack.Pack(source, destination, elementConverter);
}
public static void UnpackSpan(
in ReadOnlySpan<uint4> source,
Span<double4> destination,
Func<uint, double> elementConverter
)
{
VectorPack.Pack(source, destination, elementConverter);
}
public static void UnpackSpan(
in ReadOnlySpan<float4> source,
Span<double4> destination,
Func<float, double> elementConverter
)
{
VectorPack.Pack(source, destination, elementConverter);
}
public static void UnpackSpan(
in ReadOnlySpan<sbyte4> source,
Span<double4> destination,
Unpack.Float mode = Numerics.Unpack.Float.Cast
)
{
UnpackSpan(source, destination, PackUtils.SByte.ToDouble(mode));
}
public static void UnpackSpan(
in ReadOnlySpan<byte4> source,
Span<double4> destination,
Unpack.Float mode = Numerics.Unpack.Float.Cast
)
{
UnpackSpan(source, destination, PackUtils.Byte.ToDouble(mode));
}
public static void UnpackSpan(
in ReadOnlySpan<short4> source,
Span<double4> destination,
Unpack.Float mode = Numerics.Unpack.Float.Cast
)
{
UnpackSpan(source, destination, PackUtils.Short.ToDouble(mode));
}
public static void UnpackSpan(
in ReadOnlySpan<ushort4> source,
Span<double4> destination,
Unpack.Float mode = Numerics.Unpack.Float.Cast
)
{
UnpackSpan(source, destination, PackUtils.UShort.ToDouble(mode));
}
public static void UnpackSpan(
in ReadOnlySpan<int4> source,
Span<double4> destination,
Unpack.Float mode = Numerics.Unpack.Float.Cast
)
{
UnpackSpan(source, destination, PackUtils.Int.ToDouble(mode));
}
public static void UnpackSpan(
in ReadOnlySpan<uint4> source,
Span<double4> destination,
Unpack.Float mode = Numerics.Unpack.Float.Cast
)
{
UnpackSpan(source, destination, PackUtils.UInt.ToDouble(mode));
}
public static void UnpackSpan(
in ReadOnlySpan<float4> source,
Span<double4> destination,
Unpack.Float mode = Numerics.Unpack.Float.Cast
)
{
UnpackSpan(source, destination, PackUtils.Float.ToDouble(mode));
}
}

File diff suppressed because it is too large Load diff