better kernel fma
This commit is contained in:
@@ -178,12 +178,9 @@ namespace StgSharp.Mathematics.Numeric
|
||||
)
|
||||
{
|
||||
// Caller guarantees: indices in range, layout is dense square.
|
||||
int k_c = y >> 2;
|
||||
int k_r = x >> 2;
|
||||
|
||||
MatrixKernelEnumerator enumerator = new(_size.KernelColumnLength, _size.KernelRowLength,
|
||||
k_c, k_r);
|
||||
return Buffer + _boarder.GetIndexOffset(k_c, k_r, in enumerator);
|
||||
x, y);
|
||||
return Buffer + _boarder.GetIndexOffset(x, y, in enumerator);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="Random"
|
||||
// Project: StgSharp
|
||||
@@ -88,7 +88,7 @@ namespace StgSharp.Mathematics
|
||||
///
|
||||
/// </returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T Random<T>() where T: unmanaged, IConvertible, INumber<T>
|
||||
public static T Random<T>() where T : unmanaged, IConvertible, INumber<T>
|
||||
|
||||
{
|
||||
if (randomSeed == null)
|
||||
@@ -97,13 +97,9 @@ namespace StgSharp.Mathematics
|
||||
string originSeed =
|
||||
($"{((Assembly.GetEntryAssembly() == null) ? (Assembly.GetAssembly(typeof(World))!) :
|
||||
Assembly.GetEntryAssembly())}") + ($"{DateTime.UtcNow.ToString("o")}");
|
||||
using (SHA256 sha = SHA256.Create()) {
|
||||
randomSeed = sha.ComputeHash(Encoding.UTF8.GetBytes(originSeed));
|
||||
}
|
||||
}
|
||||
using (SHA256 sha = SHA256.Create()) {
|
||||
randomSeed = sha.ComputeHash(randomSeed);
|
||||
randomSeed = SHA256.HashData(Encoding.UTF8.GetBytes(originSeed));
|
||||
}
|
||||
randomSeed = SHA256.HashData(randomSeed);
|
||||
fixed (byte* bptr = randomSeed) {
|
||||
return *(T*)bptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user