Initial commit.
This commit is contained in:
1 parent
e5b0fea18c
commit
9f35f6c558
94 files changed
+12857
No files matched your search
@@ -0,0 +1,41 @@
|
||||
using PeterO.Numbers;
|
||||
|
||||
namespace PerfectNumbers.Core;
|
||||
|
||||
public sealed class AlphaCache
|
||||
{
|
||||
private readonly Dictionary<(EInteger P, int K), AlphaValues> _cache = new();
|
||||
|
||||
public AlphaValues Get(EInteger p, int k)
|
||||
{
|
||||
if (!_cache.TryGetValue((p, k), out var values))
|
||||
{
|
||||
ERational alphaPValue = AlphaCalculations.ComputeAlphaP(p, k);
|
||||
ERational alphaMValue = RationalNumbers.Two.Divide(alphaPValue);
|
||||
values = new AlphaValues(alphaMValue, alphaPValue);
|
||||
_cache[(p, k)] = values;
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_cache.Clear();
|
||||
}
|
||||
|
||||
public int Count => _cache.Count;
|
||||
|
||||
public readonly struct AlphaValues
|
||||
{
|
||||
public readonly ERational AlphaM;
|
||||
public readonly ERational AlphaP;
|
||||
|
||||
public AlphaValues(ERational alphaM, ERational alphaP)
|
||||
{
|
||||
AlphaM = alphaM;
|
||||
AlphaP = alphaP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user