Compilation errors fixed.
This commit is contained in:
1 parent
4f73d89716
commit
dde01cf8b9
2 files changed
+14
-21
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Buffers.Binary;
|
using System.Buffers.Binary;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using PerfectNumbers.Core.Gpu;
|
using PerfectNumbers.Core.Gpu;
|
||||||
@@ -331,23 +332,19 @@ internal static partial class PrimeOrderCalculator
|
|||||||
ArrayPool<FactorEntry> factorPool = FactorPool;
|
ArrayPool<FactorEntry> factorPool = FactorPool;
|
||||||
|
|
||||||
FactorEntry[]? tempArray = null;
|
FactorEntry[]? tempArray = null;
|
||||||
|
ReadOnlySpan<FactorEntry> factorSpan = factors.Factors;
|
||||||
|
int length = factors.Count;
|
||||||
|
int capacity = length + 1;
|
||||||
|
|
||||||
|
Span<FactorEntry> buffer = capacity <= FactorEntryStackThreshold ? stackalloc FactorEntry[capacity] : default;
|
||||||
|
if (capacity > FactorEntryStackThreshold)
|
||||||
|
{
|
||||||
|
tempArray = factorPool.Rent(capacity);
|
||||||
|
buffer = tempArray.AsSpan(0, capacity);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ReadOnlySpan<FactorEntry> factorSpan = factors.Factors;
|
|
||||||
int length = factors.Count;
|
|
||||||
int capacity = length + 1;
|
|
||||||
|
|
||||||
Span<FactorEntry> buffer;
|
|
||||||
if (capacity <= FactorEntryStackThreshold)
|
|
||||||
{
|
|
||||||
buffer = stackalloc FactorEntry[capacity];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tempArray = factorPool.Rent(capacity);
|
|
||||||
buffer = tempArray.AsSpan(0, capacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
factorSpan.CopyTo(buffer);
|
factorSpan.CopyTo(buffer);
|
||||||
|
|
||||||
bool isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(factors.Cofactor);
|
bool isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(factors.Cofactor);
|
||||||
|
|||||||
@@ -347,14 +347,10 @@ public static class ULongExtensions
|
|||||||
ulong result = divisor.MontgomeryOne;
|
ulong result = divisor.MontgomeryOne;
|
||||||
ulong nPrime = divisor.NPrime;
|
ulong nPrime = divisor.NPrime;
|
||||||
|
|
||||||
Span<ulong> oddPowerStorage;
|
Span<ulong> oddPowerStorage = oddPowerCount <= PerfectNumberConstants.MaxOddPowersCount ? stackalloc ulong[PerfectNumberConstants.MaxOddPowersCount] : default;
|
||||||
ulong[]? pooledOddPowers = null;
|
ulong[]? pooledOddPowers = null;
|
||||||
|
|
||||||
if (oddPowerCount <= PerfectNumberConstants.MaxOddPowersCount)
|
if (oddPowerCount < PerfectNumberConstants.PooledArrayThreshold)
|
||||||
{
|
|
||||||
oddPowerStorage = stackalloc ulong[PerfectNumberConstants.MaxOddPowersCount];
|
|
||||||
}
|
|
||||||
else if (oddPowerCount < PerfectNumberConstants.PooledArrayThreshold)
|
|
||||||
{
|
{
|
||||||
oddPowerStorage = new ulong[oddPowerCount];
|
oddPowerStorage = new ulong[oddPowerCount];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user