mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 13:08:24 +01:00
first
This commit is contained in:
parent
bd62d51ec9
commit
b578433e37
11 changed files with 784842 additions and 0 deletions
28
Brutal.Numerics/Vector/double2/double2.copy.gen.cs
Normal file
28
Brutal.Numerics/Vector/double2/double2.copy.gen.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// <auto-generated /> - edit Vector.copy.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double2
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly void CopyTo(Span<double> destination)
|
||||
{
|
||||
if (destination.Length < ComponentCount)
|
||||
throw new ArgumentException("Length must be at least 2.", 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;
|
||||
}
|
||||
}
|
||||
41
Brutal.Numerics/Vector/double2/double2.equality.gen.cs
Normal file
41
Brutal.Numerics/Vector/double2/double2.equality.gen.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// <auto-generated /> - edit Vector.equality.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double2
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public readonly override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(X, Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Equals(double2 other)
|
||||
{
|
||||
return X.Equals(other.X) && Y.Equals(other.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly override bool Equals([NotNullWhen(true)] object? obj)
|
||||
{
|
||||
return obj is double2 other && Equals(other);
|
||||
}
|
||||
|
||||
/// <summary>IEEE lane-wise equality over every component: any NaN component makes this false (contrast <see cref="Equals(double2)" />, which is NaN-reflexive), and -0 equals +0.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(double2 a, double2 b)
|
||||
{
|
||||
return a.X == b.X && a.Y == b.Y;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(double2 a, double2 b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
}
|
||||
92
Brutal.Numerics/Vector/double2/double2.format.gen.cs
Normal file
92
Brutal.Numerics/Vector/double2/double2.format.gen.cs
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
// <auto-generated /> - edit Vector.format.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double2 : ISpanFormattable, IUtf8SpanFormattable, ISpanParsable<double2>
|
||||
{
|
||||
/// <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(format, formatProvider)}{separator} {Y.ToString(format, formatProvider)}>";
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
return StringHelpers.TryFormat<double2, 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<double2, double>(this, destination, out bytesWritten, format, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static double2 Parse(string s, IFormatProvider? provider)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(s);
|
||||
return Parse(s.AsSpan(), NumberStyles.Float, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static double2 Parse(ReadOnlySpan<char> s, IFormatProvider? provider = null)
|
||||
{
|
||||
return Parse(s, NumberStyles.Float, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static double2 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><1, 2, 3></c>.</summary>
|
||||
/// <exception cref="FormatException">The input is not in a valid format, or a component fails to parse.</exception>
|
||||
public static double2 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 double2 format.");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out double2)" />
|
||||
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out double2 result)
|
||||
{
|
||||
return TryParse(s.AsSpan(), NumberStyles.Float, provider, out result);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out double2)" />
|
||||
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out double2 result)
|
||||
{
|
||||
return TryParse(s, NumberStyles.Float, provider, out result);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out double2)" />
|
||||
public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out double2 result)
|
||||
{
|
||||
return TryParse(s.AsSpan(), style, provider, out result);
|
||||
}
|
||||
|
||||
/// <summary>Parses from the <see cref="ToString()" /> format, <c><1, 2, 3></c>.</summary>
|
||||
/// <returns>true if the input parsed as a double2.</returns>
|
||||
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out double2 result)
|
||||
{
|
||||
return StringHelpers.TryParse<double2, double>(s, style, provider, out result);
|
||||
}
|
||||
}
|
||||
107
Brutal.Numerics/Vector/double2/double2.gen.cs
Normal file
107
Brutal.Numerics/Vector/double2/double2.gen.cs
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
// <auto-generated /> - edit Vector.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
/// <summary>
|
||||
/// Implements a 2D vector with double components.
|
||||
/// </summary>
|
||||
[DebuggerTypeProxy(typeof(VectorDebugView2<double2, double, double>))]
|
||||
public partial struct double2 : IVector2<double2, double>
|
||||
, IFloatingVector<double2, double>
|
||||
, IFloatingVector2<double2, double, doubleQuat, double3x2, double4x4>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static int ComponentSize => sizeof(double);
|
||||
|
||||
/// <summary>Gets the number of components.</summary>
|
||||
public static int ComponentCount => 2;
|
||||
|
||||
/// <inheritdoc cref="Vector2.X" />
|
||||
[XmlAttribute]
|
||||
public double X;
|
||||
|
||||
/// <inheritdoc cref="Vector2.Y" />
|
||||
[XmlAttribute]
|
||||
public double Y;
|
||||
|
||||
double IVector2<double2, double>.X { readonly get => X; set => X = value; }
|
||||
|
||||
double IVector2<double2, double>.Y { readonly get => Y; set => Y = value; }
|
||||
|
||||
/// <inheritdoc cref="Vector2(float, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public double2(double x, double y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2(float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public double2(double 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 double2(ReadOnlySpan<double> span)
|
||||
{
|
||||
if (span.Length < 2)
|
||||
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 2.");
|
||||
|
||||
this = Unsafe.ReadUnaligned<double2>(ref Unsafe.As<double, byte>(ref MemoryMarshal.GetReference(span)));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double2(ReadOnlySpan{double})" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static double2 IComponentTuple<double2, double>.Create(ReadOnlySpan<double> span) => new(span);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static double2 UnitX => new(1, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static double2 UnitY => new(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)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Span<double> AsSpan()
|
||||
{
|
||||
return MemoryMarshal.CreateSpan(ref Unsafe.As<double2, double>(ref this), 2);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly ReadOnlySpan<double> AsReadOnlySpan()
|
||||
{
|
||||
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<double2, double>(ref Unsafe.AsRef(in this)), 2);
|
||||
}
|
||||
}
|
||||
62
Brutal.Numerics/Vector/double2/double2.math-metric.gen.cs
Normal file
62
Brutal.Numerics/Vector/double2/double2.math-metric.gen.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// <auto-generated /> - edit Vector.math-metric.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double2
|
||||
{
|
||||
/// <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="Vector2.Distance" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double Distance(double2 a, double2 b)
|
||||
{
|
||||
return double.Sqrt(DistanceSquared(a, b));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.DistanceSquared" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double DistanceSquared(double2 a, double2 b)
|
||||
{
|
||||
var difference = a - b;
|
||||
return Dot(difference, difference);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Dot" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double Dot(double2 a, double2 b)
|
||||
{
|
||||
return a.X * b.X + a.Y * b.Y;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Normalize" />
|
||||
/// <exception cref="DivideByZeroException">Thrown when the input vector is a zero vector.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Normalize(double2 value)
|
||||
{
|
||||
var lengthSquared = Dot(value, value);
|
||||
if (lengthSquared == 0)
|
||||
throw new DivideByZeroException();
|
||||
return value / double.Sqrt(lengthSquared);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 NormalizeOrZero(double2 value)
|
||||
{
|
||||
var length = double.Sqrt(Dot(value, value));
|
||||
return length == 0 ? Zero : value / length;
|
||||
}
|
||||
}
|
||||
60
Brutal.Numerics/Vector/double2/double2.math.gen.cs
Normal file
60
Brutal.Numerics/Vector/double2/double2.math.gen.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
// <auto-generated /> - edit Vector.math.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double2
|
||||
{
|
||||
/// <inheritdoc cref="Vector2.Reflect" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Reflect(double2 vector, double2 normal)
|
||||
{
|
||||
return vector - 2 * Dot(vector, normal) * normal;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Transform(Vector2, Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Transform(double2 position, double3x2 matrix)
|
||||
{
|
||||
var result = matrix.X * position.X;
|
||||
|
||||
result += matrix.Y * position.Y;
|
||||
result += matrix.Z;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Transform(Vector2, Matrix4x4)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Transform(double2 position, double4x4 matrix)
|
||||
{
|
||||
return double4.Transform(position, matrix).XY;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Transform(Vector2, Quaternion)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Transform(double2 value, doubleQuat rotation)
|
||||
{
|
||||
return double4.Transform(value, rotation).XY;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.TransformNormal(Vector2, Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 TransformNormal(double2 normal, double3x2 matrix)
|
||||
{
|
||||
var result = matrix.X * normal.X;
|
||||
result += matrix.Y * normal.Y;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.TransformNormal(Vector2, Matrix4x4)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 TransformNormal(double2 normal, double4x4 matrix)
|
||||
{
|
||||
var result = matrix.X * normal.X;
|
||||
|
||||
result += matrix.Y * normal.Y;
|
||||
|
||||
return result.XY;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// <auto-generated /> - edit Vector.numerics-binary.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
// IBinaryNumber
|
||||
public partial struct double2 : IBinaryNumber<double2>
|
||||
{
|
||||
/// <summary>Determines if every component of a value is a power of two.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool IBinaryNumber<double2>.IsPow2(double2 value)
|
||||
{
|
||||
return double.IsPow2(value.X) && double.IsPow2(value.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static double2 IBitwiseOperators<double2, double2, double2>.operator &(double2 a, double2 b)
|
||||
{
|
||||
return Unsafe.BitCast<long2, double2>(Unsafe.BitCast<double2, long2>(a) & Unsafe.BitCast<double2, long2>(b));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static double2 IBitwiseOperators<double2, double2, double2>.operator |(double2 a, double2 b)
|
||||
{
|
||||
return Unsafe.BitCast<long2, double2>(Unsafe.BitCast<double2, long2>(a) | Unsafe.BitCast<double2, long2>(b));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static double2 IBitwiseOperators<double2, double2, double2>.operator ^(double2 a, double2 b)
|
||||
{
|
||||
return Unsafe.BitCast<long2, double2>(Unsafe.BitCast<double2, long2>(a) ^ Unsafe.BitCast<double2, long2>(b));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static double2 IBitwiseOperators<double2, double2, double2>.operator ~(double2 value)
|
||||
{
|
||||
return Unsafe.BitCast<long2, double2>(~Unsafe.BitCast<double2, long2>(value));
|
||||
}
|
||||
}
|
||||
|
||||
// the componentwise predicate mask (no interface to mirror) - the per-lane truth IsPow2 collapses
|
||||
public partial struct double2
|
||||
{
|
||||
/// <summary>Determines which components of a value are powers of two.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsPow2(double2 value)
|
||||
{
|
||||
return new bool2(double.IsPow2(value.X), double.IsPow2(value.Y));
|
||||
}
|
||||
}
|
||||
441
Brutal.Numerics/Vector/double2/double2.numerics-floating.gen.cs
Normal file
441
Brutal.Numerics/Vector/double2/double2.numerics-floating.gen.cs
Normal file
|
|
@ -0,0 +1,441 @@
|
|||
// <auto-generated /> - edit Vector.numerics-floating.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
// IFloatingPointConstants
|
||||
public partial struct double2 : IFloatingPointConstants<double2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static double2 E => new(double.E);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static double2 Pi => new(double.Pi);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static double2 Tau => new(double.Tau);
|
||||
}
|
||||
|
||||
// IExponentialFunctions
|
||||
public partial struct double2 : IExponentialFunctions<double2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Exp(double2 value)
|
||||
{
|
||||
return new(double.Exp(value.X), double.Exp(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Exp2(double2 value)
|
||||
{
|
||||
return new double2(double.Exp2(value.X), double.Exp2(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Exp10(double2 value)
|
||||
{
|
||||
return new double2(double.Exp10(value.X), double.Exp10(value.Y));
|
||||
}
|
||||
}
|
||||
|
||||
// ILogarithmicFunctions
|
||||
public partial struct double2 : ILogarithmicFunctions<double2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Log(double2 value)
|
||||
{
|
||||
return new(double.Log(value.X), double.Log(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Log(double2 value, double2 newBase)
|
||||
{
|
||||
return new double2(double.Log(value.X, newBase.X), double.Log(value.Y, newBase.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Log2(double2 value)
|
||||
{
|
||||
return new(double.Log2(value.X), double.Log2(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Log10(double2 value)
|
||||
{
|
||||
return new double2(double.Log10(value.X), double.Log10(value.Y));
|
||||
}
|
||||
}
|
||||
|
||||
// IPowerFunctions
|
||||
public partial struct double2 : IPowerFunctions<double2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Pow(double2 value, double2 power)
|
||||
{
|
||||
return new double2(double.Pow(value.X, power.X), double.Pow(value.Y, power.Y));
|
||||
}
|
||||
}
|
||||
|
||||
// IRootFunctions
|
||||
public partial struct double2 : IRootFunctions<double2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Cbrt(double2 value)
|
||||
{
|
||||
return new double2(double.Cbrt(value.X), double.Cbrt(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Hypot(double2 a, double2 b)
|
||||
{
|
||||
return new(double.Hypot(a.X, b.X), double.Hypot(a.Y, b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 RootN(double2 value, int n)
|
||||
{
|
||||
return new double2(double.RootN(value.X, n), double.RootN(value.Y, n));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Sqrt(double2 value)
|
||||
{
|
||||
return new(double.Sqrt(value.X), double.Sqrt(value.Y));
|
||||
}
|
||||
}
|
||||
|
||||
// ITrigonometricFunctions
|
||||
public partial struct double2 : ITrigonometricFunctions<double2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Sin(double2 value)
|
||||
{
|
||||
return new(double.Sin(value.X), double.Sin(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Cos(double2 value)
|
||||
{
|
||||
return new(double.Cos(value.X), double.Cos(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static (double2 Sin, double2 Cos) SinCos(double2 value)
|
||||
{
|
||||
var (sinX, cosX) = double.SinCos(value.X);
|
||||
var (sinY, cosY) = double.SinCos(value.Y);
|
||||
return (new(sinX, sinY), new(cosX, cosY));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Tan(double2 value)
|
||||
{
|
||||
return new double2(double.Tan(value.X), double.Tan(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Asin(double2 value)
|
||||
{
|
||||
return new double2(double.Asin(value.X), double.Asin(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Acos(double2 value)
|
||||
{
|
||||
return new double2(double.Acos(value.X), double.Acos(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Atan(double2 value)
|
||||
{
|
||||
return new double2(double.Atan(value.X), double.Atan(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 SinPi(double2 value)
|
||||
{
|
||||
return new double2(double.SinPi(value.X), double.SinPi(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 CosPi(double2 value)
|
||||
{
|
||||
return new double2(double.CosPi(value.X), double.CosPi(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 TanPi(double2 value)
|
||||
{
|
||||
return new double2(double.TanPi(value.X), double.TanPi(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 AsinPi(double2 value)
|
||||
{
|
||||
return new double2(double.AsinPi(value.X), double.AsinPi(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 AcosPi(double2 value)
|
||||
{
|
||||
return new double2(double.AcosPi(value.X), double.AcosPi(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 AtanPi(double2 value)
|
||||
{
|
||||
return new double2(double.AtanPi(value.X), double.AtanPi(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static (double2 SinPi, double2 CosPi) SinCosPi(double2 value)
|
||||
{
|
||||
return (SinPi(value), CosPi(value));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.DegreesToRadians" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 DegreesToRadians(double2 degrees)
|
||||
{
|
||||
return new(double.DegreesToRadians(degrees.X), double.DegreesToRadians(degrees.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.RadiansToDegrees" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 RadiansToDegrees(double2 radians)
|
||||
{
|
||||
return new(double.RadiansToDegrees(radians.X), double.RadiansToDegrees(radians.Y));
|
||||
}
|
||||
}
|
||||
|
||||
// IHyperbolicFunctions
|
||||
public partial struct double2 : IHyperbolicFunctions<double2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Sinh(double2 value)
|
||||
{
|
||||
return new double2(double.Sinh(value.X), double.Sinh(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Cosh(double2 value)
|
||||
{
|
||||
return new double2(double.Cosh(value.X), double.Cosh(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Tanh(double2 value)
|
||||
{
|
||||
return new double2(double.Tanh(value.X), double.Tanh(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Asinh(double2 value)
|
||||
{
|
||||
return new double2(double.Asinh(value.X), double.Asinh(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Acosh(double2 value)
|
||||
{
|
||||
return new double2(double.Acosh(value.X), double.Acosh(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Atanh(double2 value)
|
||||
{
|
||||
return new double2(double.Atanh(value.X), double.Atanh(value.Y));
|
||||
}
|
||||
}
|
||||
|
||||
// IFloatingPoint
|
||||
public partial struct double2 : IFloatingPoint<double2>
|
||||
{
|
||||
/// <inheritdoc cref="double.Floor(double)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Floor(double2 value)
|
||||
{
|
||||
return new(double.Floor(value.X), double.Floor(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Ceiling(double)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Ceiling(double2 value)
|
||||
{
|
||||
return new(double.Ceiling(value.X), double.Ceiling(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Round(double)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Round(double2 value)
|
||||
{
|
||||
return new(double.Round(value.X), double.Round(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Truncate(double)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Truncate(double2 value)
|
||||
{
|
||||
return new(double.Truncate(value.X), double.Truncate(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Round(double, int, MidpointRounding)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Round(double2 value, int digits, MidpointRounding mode)
|
||||
{
|
||||
return new double2(double.Round(value.X, digits, mode), double.Round(value.Y, digits, mode));
|
||||
}
|
||||
|
||||
// One exponent and significand PER LANE, so there is no single honest answer: explicit and throwing.
|
||||
|
||||
int IFloatingPoint<double2>.GetExponentByteCount() =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has one exponent per component.");
|
||||
|
||||
int IFloatingPoint<double2>.GetExponentShortestBitLength() =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has one exponent per component.");
|
||||
|
||||
int IFloatingPoint<double2>.GetSignificandBitLength() =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has one significand per component.");
|
||||
|
||||
int IFloatingPoint<double2>.GetSignificandByteCount() =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has one significand per component.");
|
||||
|
||||
bool IFloatingPoint<double2>.TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has one exponent per component.");
|
||||
|
||||
bool IFloatingPoint<double2>.TryWriteExponentLittleEndian(Span<byte> destination, out int bytesWritten) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has one exponent per component.");
|
||||
|
||||
bool IFloatingPoint<double2>.TryWriteSignificandBigEndian(Span<byte> destination, out int bytesWritten) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has one significand per component.");
|
||||
|
||||
bool IFloatingPoint<double2>.TryWriteSignificandLittleEndian(Span<byte> destination, out int bytesWritten) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has one significand per component.");
|
||||
}
|
||||
|
||||
// IFloatingPointIeee754
|
||||
public partial struct double2 : IFloatingPointIeee754<double2>
|
||||
{
|
||||
/// <summary>Gets a vector whose components are NaN.</summary>
|
||||
public static double2 NaN => new(double.NaN);
|
||||
|
||||
/// <inheritdoc cref="double.Epsilon" />
|
||||
public static double2 Epsilon => new(double.Epsilon);
|
||||
|
||||
/// <inheritdoc cref="double.NegativeZero" />
|
||||
public static double2 NegativeZero => new(double.NegativeZero);
|
||||
|
||||
/// <inheritdoc cref="double.PositiveInfinity" />
|
||||
public static double2 PositiveInfinity => new(double.PositiveInfinity);
|
||||
|
||||
/// <inheritdoc cref="double.NegativeInfinity" />
|
||||
public static double2 NegativeInfinity => new(double.NegativeInfinity);
|
||||
|
||||
/// <inheritdoc cref="double.Atan2" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Atan2(double2 y, double2 x)
|
||||
{
|
||||
return new double2(double.Atan2(y.X, x.X), double.Atan2(y.Y, x.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Atan2Pi" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Atan2Pi(double2 y, double2 x)
|
||||
{
|
||||
return new double2(double.Atan2Pi(y.X, x.X), double.Atan2Pi(y.Y, x.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.BitDecrement" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 BitDecrement(double2 value)
|
||||
{
|
||||
return new double2(double.BitDecrement(value.X), double.BitDecrement(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.BitIncrement" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 BitIncrement(double2 value)
|
||||
{
|
||||
return new double2(double.BitIncrement(value.X), double.BitIncrement(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.FusedMultiplyAdd" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 FusedMultiplyAdd(double2 a, double2 b, double2 addend)
|
||||
{
|
||||
return new(double.FusedMultiplyAdd(a.X, b.X, addend.X), double.FusedMultiplyAdd(a.Y, b.Y, addend.Y));
|
||||
}
|
||||
|
||||
/// <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 double2 MultiplyAddEstimate(double2 a, double2 b, double2 addend)
|
||||
{
|
||||
return new(double.MultiplyAddEstimate(a.X, b.X, addend.X), double.MultiplyAddEstimate(a.Y, b.Y, addend.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Ieee754Remainder" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Ieee754Remainder(double2 a, double2 b)
|
||||
{
|
||||
return new double2(double.Ieee754Remainder(a.X, b.X), double.Ieee754Remainder(a.Y, b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.ScaleB" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 ScaleB(double2 value, int n)
|
||||
{
|
||||
return new double2(double.ScaleB(value.X, n), double.ScaleB(value.Y, n));
|
||||
}
|
||||
|
||||
// ILogB's int return cannot hold one exponent per lane - same shape as Sign
|
||||
static int IFloatingPointIeee754<double2>.ILogB(double2 value) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has one exponent per component.");
|
||||
|
||||
/// <inheritdoc cref="Vector2.Lerp(Vector2, Vector2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Lerp(double2 a, double2 b, double amount)
|
||||
{
|
||||
return new(double.Lerp(a.X, b.X, amount), double.Lerp(a.Y, b.Y, amount));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Sqrt" />
|
||||
[Obsolete("Renamed to Sqrt (the generic-math name; SquareRoot was the System.Numerics vector spelling).")]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 SquareRoot(double2 value)
|
||||
{
|
||||
return Sqrt(value);
|
||||
}
|
||||
}
|
||||
545
Brutal.Numerics/Vector/double2/double2.numerics.gen.cs
Normal file
545
Brutal.Numerics/Vector/double2/double2.numerics.gen.cs
Normal file
|
|
@ -0,0 +1,545 @@
|
|||
// <auto-generated /> - edit Vector.numerics.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
// INumberBase
|
||||
public partial struct double2 : INumberBase<double2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static double2 Zero => new(0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static double2 One => new(1);
|
||||
|
||||
static double2 IAdditiveIdentity<double2, double2>.AdditiveIdentity => Zero;
|
||||
|
||||
static double2 IMultiplicativeIdentity<double2, double2>.MultiplicativeIdentity => One;
|
||||
|
||||
static int INumberBase<double2>.Radix => 2; // every component type is binary
|
||||
|
||||
/// <inheritdoc cref="Vector2.Abs" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Abs(double2 value)
|
||||
{
|
||||
return new(double.Abs(value.X), double.Abs(value.Y));
|
||||
}
|
||||
|
||||
static bool INumberBase<double2>.IsCanonical(double2 value) => true;
|
||||
|
||||
static bool INumberBase<double2>.IsComplexNumber(double2 value) => false;
|
||||
|
||||
static bool INumberBase<double2>.IsImaginaryNumber(double2 value) => false;
|
||||
|
||||
/// <summary>Determines if every component of a value is zero.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsZero(double2 value)
|
||||
{
|
||||
return value == Zero;
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is an even integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsEvenInteger(double2 value)
|
||||
{
|
||||
return double.IsEvenInteger(value.X) && double.IsEvenInteger(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is an odd integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsOddInteger(double2 value)
|
||||
{
|
||||
return double.IsOddInteger(value.X) && double.IsOddInteger(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is negative.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsNegative(double2 value)
|
||||
{
|
||||
return double.IsNegative(value.X) && double.IsNegative(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is positive.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsPositive(double2 value)
|
||||
{
|
||||
return double.IsPositive(value.X) && double.IsPositive(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is finite.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsFinite(double2 value)
|
||||
{
|
||||
return double.IsFinite(value.X) && double.IsFinite(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is infinite.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsInfinity(double2 value)
|
||||
{
|
||||
return double.IsInfinity(value.X) && double.IsInfinity(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is negative infinity.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsNegativeInfinity(double2 value)
|
||||
{
|
||||
return double.IsNegativeInfinity(value.X) && double.IsNegativeInfinity(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is positive infinity.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsPositiveInfinity(double2 value)
|
||||
{
|
||||
return double.IsPositiveInfinity(value.X) && double.IsPositiveInfinity(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is an integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsInteger(double2 value)
|
||||
{
|
||||
return double.IsInteger(value.X) && double.IsInteger(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is a real value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsRealNumber(double2 value)
|
||||
{
|
||||
return double.IsRealNumber(value.X) && double.IsRealNumber(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if any component of a value is NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsNaN(double2 value)
|
||||
{
|
||||
return double.IsNaN(value.X) || double.IsNaN(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is normal.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsNormal(double2 value)
|
||||
{
|
||||
return double.IsNormal(value.X) && double.IsNormal(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is subnormal.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double2>.IsSubnormal(double2 value)
|
||||
{
|
||||
return double.IsSubnormal(value.X) && double.IsSubnormal(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is greater.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 MaxMagnitude(double2 a, double2 b)
|
||||
{
|
||||
return new(double.MaxMagnitude(a.X, b.X), double.MaxMagnitude(a.Y, b.Y));
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is greater, preferring numbers over NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 MaxMagnitudeNumber(double2 a, double2 b)
|
||||
{
|
||||
return new(double.MaxMagnitudeNumber(a.X, b.X), double.MaxMagnitudeNumber(a.Y, b.Y));
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is smaller.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 MinMagnitude(double2 a, double2 b)
|
||||
{
|
||||
return new(double.MinMagnitude(a.X, b.X), double.MinMagnitude(a.Y, b.Y));
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is smaller, preferring numbers over NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 MinMagnitudeNumber(double2 a, double2 b)
|
||||
{
|
||||
return new(double.MinMagnitudeNumber(a.X, b.X), double.MinMagnitudeNumber(a.Y, b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Add" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Add(double2 a, double2 b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Divide(Vector2, Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Divide(double2 a, double2 b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Multiply(Vector2, Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Multiply(double2 a, double2 b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Negate" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Negate(double2 value)
|
||||
{
|
||||
return -value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Subtract" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Subtract(double2 a, double2 b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 operator +(double2 a, double2 b)
|
||||
{
|
||||
return new(a.X + b.X, a.Y + b.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 operator -(double2 a, double2 b)
|
||||
{
|
||||
return new(a.X - b.X, a.Y - b.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 operator *(double2 a, double2 b)
|
||||
{
|
||||
return new(a.X * b.X, a.Y * b.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 operator /(double2 a, double2 b)
|
||||
{
|
||||
return new(a.X / b.X, a.Y / b.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 operator -(double2 a)
|
||||
{
|
||||
return new(-a.X, -a.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 operator +(double2 a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
// ++/-- are well-defined (+/- One) but a footgun on a concrete vector: generic-plane only.
|
||||
|
||||
static double2 IIncrementOperators<double2>.operator ++(double2 value) => value + One;
|
||||
|
||||
static double2 IDecrementOperators<double2>.operator --(double2 value) => value - One;
|
||||
|
||||
|
||||
static bool INumberBase<double2>.TryConvertFromChecked<TOther>(TOther value, out double2 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<double2, double, TOther, NumberConversion.Checked>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<double2>.TryConvertToChecked<TOther>(double2 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool INumberBase<double2>.TryConvertFromSaturating<TOther>(TOther value, out double2 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<double2, double, TOther, NumberConversion.Saturating>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<double2>.TryConvertToSaturating<TOther>(double2 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool INumberBase<double2>.TryConvertFromTruncating<TOther>(TOther value, out double2 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<double2, double, TOther, NumberConversion.Truncating>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<double2>.TryConvertToTruncating<TOther>(double2 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// IMultiplyOperators<TSelf, TComponent, TSelf>, IDivisionOperators<TSelf, TComponent, TSelf>
|
||||
public partial struct double2
|
||||
: IMultiplyOperators<double2, double, double2>
|
||||
, IDivisionOperators<double2, double, double2>
|
||||
{
|
||||
/// <inheritdoc cref="Vector2.Divide(Vector2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Divide(double2 a, double b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Multiply(Vector2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Multiply(double2 a, double b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Multiply(float, Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Multiply(double a, double2 b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 operator *(double2 a, double b)
|
||||
{
|
||||
return new(a.X * b, a.Y * b);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 operator /(double2 a, double b)
|
||||
{
|
||||
return new(a.X / b, a.Y / b);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 operator *(double a, double2 b)
|
||||
{
|
||||
return new(a * b.X, a * b.Y);
|
||||
}
|
||||
}
|
||||
|
||||
// INumber
|
||||
public partial struct double2 : INumber<double2>
|
||||
{
|
||||
/// <inheritdoc cref="Vector2.Clamp" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Clamp(double2 value, double2 min, double2 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="Vector2.Max" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Max(double2 a, double2 b)
|
||||
{
|
||||
return new(double.Max(a.X, b.X), double.Max(a.Y, b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Min" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Min(double2 a, double2 b)
|
||||
{
|
||||
return new(double.Min(a.X, b.X), double.Min(a.Y, b.Y));
|
||||
}
|
||||
|
||||
/// <summary>Selects, componentwise, the larger value, preferring numbers over NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 MaxNumber(double2 a, double2 b)
|
||||
{
|
||||
return new(double.MaxNumber(a.X, b.X), double.MaxNumber(a.Y, b.Y));
|
||||
}
|
||||
|
||||
/// <summary>Selects, componentwise, the smaller value, preferring numbers over NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 MinNumber(double2 a, double2 b)
|
||||
{
|
||||
return new(double.MinNumber(a.X, b.X), double.MinNumber(a.Y, b.Y));
|
||||
}
|
||||
|
||||
/// <summary>Copies, componentwise, the sign of <paramref name="sign" /> onto the magnitude of <paramref name="value" />.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 CopySign(double2 value, double2 sign)
|
||||
{
|
||||
return new(double.CopySign(value.X, sign.X), double.CopySign(value.Y, sign.Y));
|
||||
}
|
||||
|
||||
// the Native variants permit either NaN/signed-zero behavior - forwarding is always legal
|
||||
static double2 INumber<double2>.ClampNative(double2 value, double2 min, double2 max) => Clamp(value, min, max);
|
||||
|
||||
static double2 INumber<double2>.MaxNative(double2 a, double2 b) => Max(a, b);
|
||||
|
||||
static double2 INumber<double2>.MinNative(double2 a, double2 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<double2>.Sign(double2 value) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has no scalar sign.");
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 operator %(double2 a, double2 b)
|
||||
{
|
||||
return new double2(a.X % b.X, a.Y % b.Y);
|
||||
}
|
||||
|
||||
int IComparable.CompareTo(object? obj) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has no total order.");
|
||||
|
||||
int IComparable<double2>.CompareTo(double2 other) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<double2, double2, bool>.operator <(double2 a, double2 b) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<double2, double2, bool>.operator <=(double2 a, double2 b) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<double2, double2, bool>.operator >(double2 a, double2 b) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<double2, double2, bool>.operator >=(double2 a, double2 b) =>
|
||||
throw new NotSupportedException($"{nameof(double2)} has no total order.");
|
||||
}
|
||||
|
||||
// IComponentwiseComparison + the componentwise predicate masks (no interface to mirror)
|
||||
public partial struct double2 : IComponentwiseComparison<double2, bool2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 operator <(double2 a, double2 b)
|
||||
{
|
||||
return new bool2(a.X < b.X, a.Y < b.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 operator <=(double2 a, double2 b)
|
||||
{
|
||||
return new bool2(a.X <= b.X, a.Y <= b.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 operator >(double2 a, double2 b)
|
||||
{
|
||||
return new bool2(a.X > b.X, a.Y > b.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 operator >=(double2 a, double2 b)
|
||||
{
|
||||
return new bool2(a.X >= b.X, a.Y >= b.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are zero.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsZero(double2 value)
|
||||
{
|
||||
return new bool2(value.X == 0, value.Y == 0);
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are an even integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsEvenInteger(double2 value)
|
||||
{
|
||||
return new bool2(double.IsEvenInteger(value.X), double.IsEvenInteger(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are an odd integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsOddInteger(double2 value)
|
||||
{
|
||||
return new bool2(double.IsOddInteger(value.X), double.IsOddInteger(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are negative.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsNegative(double2 value)
|
||||
{
|
||||
return new bool2(double.IsNegative(value.X), double.IsNegative(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are positive.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsPositive(double2 value)
|
||||
{
|
||||
return new bool2(double.IsPositive(value.X), double.IsPositive(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are finite.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsFinite(double2 value)
|
||||
{
|
||||
return new bool2(double.IsFinite(value.X), double.IsFinite(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are infinite.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsInfinity(double2 value)
|
||||
{
|
||||
return new bool2(double.IsInfinity(value.X), double.IsInfinity(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are negative infinity.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsNegativeInfinity(double2 value)
|
||||
{
|
||||
return new bool2(double.IsNegativeInfinity(value.X), double.IsNegativeInfinity(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are positive infinity.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsPositiveInfinity(double2 value)
|
||||
{
|
||||
return new bool2(double.IsPositiveInfinity(value.X), double.IsPositiveInfinity(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are an integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsInteger(double2 value)
|
||||
{
|
||||
return new bool2(double.IsInteger(value.X), double.IsInteger(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are a real value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsRealNumber(double2 value)
|
||||
{
|
||||
return new bool2(double.IsRealNumber(value.X), double.IsRealNumber(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsNaN(double2 value)
|
||||
{
|
||||
return new bool2(double.IsNaN(value.X), double.IsNaN(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are normal.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsNormal(double2 value)
|
||||
{
|
||||
return new bool2(double.IsNormal(value.X), double.IsNormal(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are subnormal.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsSubnormal(double2 value)
|
||||
{
|
||||
return new bool2(double.IsSubnormal(value.X), double.IsSubnormal(value.Y));
|
||||
}
|
||||
}
|
||||
|
||||
// ISignedNumber
|
||||
public partial struct double2 : ISignedNumber<double2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static double2 NegativeOne => new(-1);
|
||||
}
|
||||
210
Brutal.Numerics/Vector/double2/double2.pack.gen.cs
Normal file
210
Brutal.Numerics/Vector/double2/double2.pack.gen.cs
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
// <auto-generated /> - edit Vector.pack.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double2
|
||||
{
|
||||
public static double2 Unpack(in sbyte2 vector, Func<sbyte, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double2 Unpack(in byte2 vector, Func<byte, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double2 Unpack(in short2 vector, Func<short, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double2 Unpack(in ushort2 vector, Func<ushort, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double2 Unpack(in int2 vector, Func<int, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double2 Unpack(in uint2 vector, Func<uint, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double2 Unpack(in float2 vector, Func<float, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double2 Unpack(in sbyte2 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.SByte.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double2 Unpack(in byte2 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.Byte.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double2 Unpack(in short2 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.Short.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double2 Unpack(in ushort2 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.UShort.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double2 Unpack(in int2 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.Int.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double2 Unpack(in uint2 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.UInt.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double2 Unpack(in float2 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.Float.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<sbyte2> source,
|
||||
Span<double2> destination,
|
||||
Func<sbyte, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<byte2> source,
|
||||
Span<double2> destination,
|
||||
Func<byte, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<short2> source,
|
||||
Span<double2> destination,
|
||||
Func<short, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<ushort2> source,
|
||||
Span<double2> destination,
|
||||
Func<ushort, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<int2> source,
|
||||
Span<double2> destination,
|
||||
Func<int, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<uint2> source,
|
||||
Span<double2> destination,
|
||||
Func<uint, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<float2> source,
|
||||
Span<double2> destination,
|
||||
Func<float, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<sbyte2> source,
|
||||
Span<double2> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.SByte.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<byte2> source,
|
||||
Span<double2> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.Byte.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<short2> source,
|
||||
Span<double2> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.Short.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<ushort2> source,
|
||||
Span<double2> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.UShort.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<int2> source,
|
||||
Span<double2> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.Int.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<uint2> source,
|
||||
Span<double2> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.UInt.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<float2> source,
|
||||
Span<double2> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.Float.ToDouble(mode));
|
||||
}
|
||||
}
|
||||
80
Brutal.Numerics/Vector/double2/double2.swizzle.gen.cs
Normal file
80
Brutal.Numerics/Vector/double2/double2.swizzle.gen.cs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// <auto-generated /> - edit Vector.swizzle.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double2
|
||||
{
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the X and Y components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 XY
|
||||
{
|
||||
readonly get => this;
|
||||
set => this = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Y and X components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 YX
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, X);
|
||||
set
|
||||
{
|
||||
Y = value.X;
|
||||
X = value.Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial struct double2
|
||||
{
|
||||
/// <summary>
|
||||
/// The Red component of the vector (synonym for X).
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double R
|
||||
{
|
||||
readonly get => X;
|
||||
set => X = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Green component of the vector (synonym for Y).
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double G
|
||||
{
|
||||
readonly get => Y;
|
||||
set => Y = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Red and Green components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 RG
|
||||
{
|
||||
readonly get => this;
|
||||
set => this = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Green and Red components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 GR
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, X);
|
||||
set
|
||||
{
|
||||
G = value.R;
|
||||
R = value.G;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue