Readme for new namespace; New file for special expression format in text regex.

Signed-off-by: Nitload <Nitload_Creater@outlook.com>
This commit is contained in:
2026-09-09 23:39:51 +08:00
33 changed files with 1225 additions and 937 deletions
@@ -16,38 +16,83 @@ namespace Nitload.Mathematics.Numeric.Graphics
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
<<<<<<< HEAD
public static Vec3<double> ConvertToDouble(Vec3<long> source)
=======
public static Vec3<double> ConvertToDouble(
Vec3<long> source
)
>>>>>>> 8755185e78a8091ca252c1342249110180446be3
{
return FromVector256Unsafe(Vector256.ConvertToDouble(source.AsVector256Safe()));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
<<<<<<< HEAD
public static Vec3<double> ConvertToDouble(Vec3<ulong> source)
=======
public static Vec3<double> ConvertToDouble(
Vec3<ulong> source
)
>>>>>>> 8755185e78a8091ca252c1342249110180446be3
{
return FromVector256Unsafe(Vector256.ConvertToDouble(source.AsVector256Safe()));
}
<<<<<<< HEAD
#region cast
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec3<float> ConvertToSingle(Vec3<int> source)
=======
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec3<float> ConvertToSingle(
Vec3<int> source
)
>>>>>>> 8755185e78a8091ca252c1342249110180446be3
{
return FromVector128Unsafe(Vector128.ConvertToSingle(source.AsVector128Safe()));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
<<<<<<< HEAD
public static Vec3<float> ConvertToSingle(Vec3<uint> source)
=======
public static Vec3<float> ConvertToSingle(
Vec3<uint> source
)
>>>>>>> 8755185e78a8091ca252c1342249110180446be3
{
return FromVector128Unsafe(Vector128.ConvertToSingle(source.AsVector128Safe()));
}
<<<<<<< HEAD
public static bool IsParallel<T>(Vec3<T> left, Vec3<T> right) where T: unmanaged,INumber<T>
=======
public static Vec3<T> FromSpan<T>(
ReadOnlySpan<T> span
) where T : unmanaged, INumber<T>
{
if (span.Length < 3) {
throw new ArgumentException("Span length must be at least 3.", nameof(span));
}
return new(span[0], span[1], span[2]);
}
public static bool IsParallel<T>(
Vec3<T> left,
Vec3<T> right
) where T : unmanaged,INumber<T>
>>>>>>> 8755185e78a8091ca252c1342249110180446be3
{
return Cross(left, right).Equals(T.Zero);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static Vector128<T> AsVector128Safe<T>(this Vec3<T> source) where T: unmanaged, INumber<T>
internal static Vector128<T> AsVector128Safe<T>(
this Vec3<T> source
) where T : unmanaged, INumber<T>
{
Vector128<T> result = Vector128<T>.Zero;
Unsafe.WriteUnaligned(ref Unsafe.As<Vector128<T>, byte>(ref result), source);
@@ -55,7 +100,9 @@ namespace Nitload.Mathematics.Numeric.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static Vector128<T> AsVector128Unsafe<T>(this Vec3<T> source) where T: unmanaged, INumber<T>
internal static Vector128<T> AsVector128Unsafe<T>(
this Vec3<T> source
) where T : unmanaged, INumber<T>
{
Unsafe.SkipInit(out Vector128<T> result);
Unsafe.WriteUnaligned(ref Unsafe.As<Vector128<T>, byte>(ref result), source);
@@ -63,7 +110,9 @@ namespace Nitload.Mathematics.Numeric.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static Vector256<T> AsVector256Safe<T>(this Vec3<T> source) where T: unmanaged, INumber<T>
internal static Vector256<T> AsVector256Safe<T>(
this Vec3<T> source
) where T : unmanaged, INumber<T>
{
Vector256<T> result = Vector256<T>.Zero;
Unsafe.WriteUnaligned(ref Unsafe.As<Vector256<T>, byte>(ref result), source);
@@ -71,7 +120,9 @@ namespace Nitload.Mathematics.Numeric.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static Vector256<T> AsVector256Unsafe<T>(this Vec3<T> source) where T: unmanaged, INumber<T>
internal static Vector256<T> AsVector256Unsafe<T>(
this Vec3<T> source
) where T : unmanaged, INumber<T>
{
Unsafe.SkipInit(out Vector256<T> result);
Unsafe.WriteUnaligned(ref Unsafe.As<Vector256<T>, byte>(ref result), source);
@@ -79,23 +130,33 @@ namespace Nitload.Mathematics.Numeric.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static Vec3<T> FromVector128Unsafe<T>(Vector128<T> source) where T: unmanaged, INumber<T>
internal static Vec3<T> FromVector128Unsafe<T>(
Vector128<T> source
) where T : unmanaged, INumber<T>
{
return Unsafe.As<Vector128<T>, Vec3<T>>(ref source);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static Vec3<T> FromVector256Unsafe<T>(Vector256<T> source) where T: unmanaged, INumber<T>
internal static Vec3<T> FromVector256Unsafe<T>(
Vector256<T> source
) where T : unmanaged, INumber<T>
{
return Unsafe.As<Vector256<T>, Vec3<T>>(ref source);
}
<<<<<<< HEAD
#ednregion
=======
>>>>>>> 8755185e78a8091ca252c1342249110180446be3
#region cross
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec3<T> Cross<T>(Vec3<T> left, Vec3<T> right) where T: unmanaged, INumber<T>
public static Vec3<T> Cross<T>(
Vec3<T> left,
Vec3<T> right
) where T : unmanaged, INumber<T>
{
if (typeof(T) == typeof(float))
{
@@ -144,7 +205,10 @@ namespace Nitload.Mathematics.Numeric.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vec3<double> CrossDouble(Vec3<double> left, Vec3<double> right)
private static Vec3<double> CrossDouble(
Vec3<double> left,
Vec3<double> right
)
{
Vector256<double> l = left.AsVector256Safe();
Vector256<double> r = right.AsVector256Safe();
@@ -155,7 +219,10 @@ namespace Nitload.Mathematics.Numeric.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vec3<int> CrossInt32(Vec3<int> left, Vec3<int> right)
private static Vec3<int> CrossInt32(
Vec3<int> left,
Vec3<int> right
)
{
Vector128<int> l = left.AsVector128Safe();
Vector128<int> r = right.AsVector128Safe();
@@ -166,7 +233,10 @@ namespace Nitload.Mathematics.Numeric.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vec3<float> CrossSingle(Vec3<float> left, Vec3<float> right)
private static Vec3<float> CrossSingle(
Vec3<float> left,
Vec3<float> right
)
{
Vector128<float> l = left.AsVector128Safe();
Vector128<float> r = right.AsVector128Safe();
@@ -177,7 +247,10 @@ namespace Nitload.Mathematics.Numeric.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vec3<uint> CrossUInt32(Vec3<uint> left, Vec3<uint> right)
private static Vec3<uint> CrossUInt32(
Vec3<uint> left,
Vec3<uint> right
)
{
Vector128<uint> l = left.AsVector128Safe();
Vector128<uint> r = right.AsVector128Safe();
@@ -188,7 +261,10 @@ namespace Nitload.Mathematics.Numeric.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vec3<ulong> CrossUInt64(Vec3<ulong> left, Vec3<ulong> right)
private static Vec3<ulong> CrossUInt64(
Vec3<ulong> left,
Vec3<ulong> right
)
{
Vector256<ulong> l = left.AsVector256Safe();
Vector256<ulong> r = right.AsVector256Safe();
@@ -199,7 +275,10 @@ namespace Nitload.Mathematics.Numeric.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vec3<long> CrossInt64(Vec3<long> left, Vec3<long> right)
private static Vec3<long> CrossInt64(
Vec3<long> left,
Vec3<long> right
)
{
Vector256<long> l = left.AsVector256Safe();
Vector256<long> r = right.AsVector256Safe();