chore: repo cleanup and code quality improvements
- Remove global.json (SDK pinning unnecessary) - Remove nuget.config, move MyGet source to .csproj RestoreAdditionalProjectSources - Gitignore ndepend/ entirely, move badges to docs/img/ - Update README.md and docs/ndepend.md badge paths - Add NDepend project property to QuanTAlib.slnx - Expand .editorconfig ReSharper/diagnostic suppressions - Use ArgumentOutOfRangeException instead of ArgumentException - Use discard _ for unused event sender parameters - Remove quantalib.code-workspace and sonar-suppressions.json - Add filter signature SVGs
|
After Width: | Height: | Size: 546 KiB |
@@ -117,13 +117,9 @@ public sealed class ALaguerre : AbstractBase
|
||||
}
|
||||
source.Pub += Handle;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool IsHot => _s.Count >= WarmupPeriod;
|
||||
|
||||
private const int StackAllocThreshold = 512;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Prime(ReadOnlySpan<double> source, TimeSpan? step = null)
|
||||
{
|
||||
if (source.Length == 0)
|
||||
@@ -203,8 +199,6 @@ public sealed class ALaguerre : AbstractBase
|
||||
}
|
||||
return _lastValidValue;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public override TValue Update(TValue input, bool isNew = true)
|
||||
{
|
||||
@@ -230,8 +224,6 @@ public sealed class ALaguerre : AbstractBase
|
||||
PubEvent(Last, isNew);
|
||||
return Last;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||
public override TSeries Update(TSeries source)
|
||||
{
|
||||
@@ -571,8 +563,6 @@ public sealed class ALaguerre : AbstractBase
|
||||
coeffBuf, ref cHead, ref cCount,
|
||||
ref state, ref lastValid);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Reset()
|
||||
{
|
||||
_s = State.New();
|
||||
|
||||
@@ -247,9 +247,6 @@ public sealed class BaxterKing : AbstractBase
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static double SoftBandPass(double value) => value;
|
||||
|
||||
public static TSeries Batch(TSeries source, int pLow = 6, int pHigh = 32, int k = 12)
|
||||
{
|
||||
double[] input = source.Values.ToArray();
|
||||
|
||||
@@ -34,7 +34,7 @@ public sealed class Butter2 : AbstractBase
|
||||
CalculateCoefficients();
|
||||
Name = $"Butter2({_period})";
|
||||
WarmupPeriod = 4 * period;
|
||||
_handler = new TValuePublishedHandler(Handle);
|
||||
_handler = Handle;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public sealed class Butter3 : AbstractBase
|
||||
CalculateCoefficients();
|
||||
Name = $"Butter3({_period})";
|
||||
WarmupPeriod = 6 * period;
|
||||
_handler = new TValuePublishedHandler(Handle);
|
||||
_handler = Handle;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
@@ -232,19 +232,6 @@ public sealed class Cfitz : AbstractBase
|
||||
return weightedSum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the ideal band-pass weight B_j for lag j.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static double IdealWeight(double wl, double wh, int j)
|
||||
{
|
||||
if (j == 0)
|
||||
{
|
||||
return (wh - wl) / Math.PI;
|
||||
}
|
||||
return (Math.Sin(j * wh) - Math.Sin(j * wl)) / (Math.PI * j);
|
||||
}
|
||||
|
||||
public static TSeries Batch(TSeries source, int pLow = 6, int pHigh = 32)
|
||||
{
|
||||
double[] input = source.Values.ToArray();
|
||||
|
||||
@@ -65,7 +65,7 @@ public sealed class Cheby1 : AbstractBase
|
||||
double wc = 2.0 * Math.PI / period;
|
||||
double Wc = Math.Tan(wc * 0.5);
|
||||
double epsilon = Math.Sqrt(Math.Pow(10.0, safeRipple * 0.1) - 1.0);
|
||||
double mu = System.Math.Asinh(1.0 / epsilon) * 0.5;
|
||||
double mu = Math.Asinh(1.0 / epsilon) * 0.5;
|
||||
double sinhMu = Math.Sinh(mu);
|
||||
double coshMu = Math.Cosh(mu);
|
||||
double sigma = -sinhMu * Wc;
|
||||
@@ -226,7 +226,7 @@ public sealed class Cheby1 : AbstractBase
|
||||
double wc = 2.0 * Math.PI / period;
|
||||
double Wc = Math.Tan(wc * 0.5);
|
||||
double epsilon = Math.Sqrt(Math.Pow(10.0, safeRipple * 0.1) - 1.0);
|
||||
double mu = System.Math.Asinh(1.0 / epsilon) * 0.5;
|
||||
double mu = Math.Asinh(1.0 / epsilon) * 0.5;
|
||||
double sinhMu = Math.Sinh(mu);
|
||||
double coshMu = Math.Cosh(mu);
|
||||
double sigma = -sinhMu * Wc;
|
||||
|
||||
@@ -65,7 +65,7 @@ public sealed class Cheby2 : AbstractBase
|
||||
double wc = 2.0 * Math.PI / period;
|
||||
double Wc = 2.0 * Math.Tan(wc * 0.5);
|
||||
double epsilon = 1.0 / Math.Sqrt(Math.Pow(10.0, safeAtten * 0.1) - 1.0);
|
||||
double mu = System.Math.Asinh(1.0 / epsilon) * 0.5;
|
||||
double mu = Math.Asinh(1.0 / epsilon) * 0.5;
|
||||
double sinhMu = Math.Sinh(mu);
|
||||
double coshMu = Math.Cosh(mu);
|
||||
double sqrt2 = Math.Sqrt(2.0);
|
||||
@@ -246,7 +246,7 @@ public sealed class Cheby2 : AbstractBase
|
||||
double wc = 2.0 * Math.PI / period;
|
||||
double Wc = 2.0 * Math.Tan(wc * 0.5);
|
||||
double epsilon = 1.0 / Math.Sqrt(Math.Pow(10.0, safeAtten * 0.1) - 1.0);
|
||||
double mu = System.Math.Asinh(1.0 / epsilon) * 0.5;
|
||||
double mu = Math.Asinh(1.0 / epsilon) * 0.5;
|
||||
double sinhMu = Math.Sinh(mu);
|
||||
double coshMu = Math.Cosh(mu);
|
||||
double sqrt2 = Math.Sqrt(2.0);
|
||||
|
||||
@@ -278,53 +278,53 @@ public sealed class Gauss : AbstractBase
|
||||
weights[i] *= invSum;
|
||||
}
|
||||
|
||||
// Apply filter
|
||||
for (int i = 0; i < source.Length; i++)
|
||||
{
|
||||
double result = 0;
|
||||
double wSum = 0;
|
||||
// Apply filter
|
||||
for (int i = 0; i < source.Length; i++)
|
||||
{
|
||||
double result = 0;
|
||||
double wSum = 0;
|
||||
|
||||
// This loop logic matches the RingBuffer partial fill logic.
|
||||
// If i < kernelSize, we don't have enough history.
|
||||
// The available history is source[0]...source[i].
|
||||
// This history maps to the END of the kernel weights.
|
||||
// E.g. if we have only 1 item (index i=0), it corresponds to weights[kernelSize-1].
|
||||
// This loop logic matches the RingBuffer partial fill logic.
|
||||
// If i < kernelSize, we don't have enough history.
|
||||
// The available history is source[0]...source[i].
|
||||
// This history maps to the END of the kernel weights.
|
||||
// E.g. if we have only 1 item (index i=0), it corresponds to weights[kernelSize-1].
|
||||
|
||||
int count = Math.Min(i + 1, kernelSize);
|
||||
int count = Math.Min(i + 1, kernelSize);
|
||||
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
// Source index: i - (count - 1) + j
|
||||
// if j=0, source index is i - count + 1.
|
||||
// if count=kernelSize, init index is i - kernelSize + 1.
|
||||
// if count=1 (i=0), init index is 0.
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
// Source index: i - (count - 1) + j
|
||||
// if j=0, source index is i - count + 1.
|
||||
// if count=kernelSize, init index is i - kernelSize + 1.
|
||||
// if count=1 (i=0), init index is 0.
|
||||
|
||||
int srcIdx = i - (count - 1) + j;
|
||||
double val = source[srcIdx];
|
||||
int srcIdx = i - (count - 1) + j;
|
||||
double val = source[srcIdx];
|
||||
|
||||
if (!double.IsNaN(val))
|
||||
{
|
||||
// Weight index:
|
||||
// If full buffer, we use full weights 0..kernelSize-1.
|
||||
// If partial, we align to end of weights.
|
||||
// j=0 (oldest available) -> weights[kernelSize - count]
|
||||
int weightIdx = kernelSize - count + j;
|
||||
if (!double.IsNaN(val))
|
||||
{
|
||||
// Weight index:
|
||||
// If full buffer, we use full weights 0..kernelSize-1.
|
||||
// If partial, we align to end of weights.
|
||||
// j=0 (oldest available) -> weights[kernelSize - count]
|
||||
int weightIdx = kernelSize - count + j;
|
||||
|
||||
double w = weights[weightIdx];
|
||||
result += val * w;
|
||||
wSum += w;
|
||||
}
|
||||
}
|
||||
double w = weights[weightIdx];
|
||||
result += val * w;
|
||||
wSum += w;
|
||||
}
|
||||
}
|
||||
|
||||
if (wSum > 0)
|
||||
{
|
||||
output[i] = result / wSum;
|
||||
}
|
||||
else
|
||||
{
|
||||
output[i] = double.NaN;
|
||||
}
|
||||
}
|
||||
if (wSum > 0)
|
||||
{
|
||||
output[i] = result / wSum;
|
||||
}
|
||||
else
|
||||
{
|
||||
output[i] = double.NaN;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
|
After Width: | Height: | Size: 543 KiB |
@@ -81,14 +81,11 @@ public sealed class Hann : AbstractBase
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void GenerateWeights()
|
||||
{
|
||||
double coefSum = 0;
|
||||
double denom = Length - 1;
|
||||
|
||||
for (int i = 0; i < Length; i++)
|
||||
{
|
||||
double w = 0.5 * (1.0 - Math.Cos(2.0 * Math.PI * i / denom));
|
||||
_weights[i] = w;
|
||||
coefSum += w;
|
||||
_weights[i] = 0.5 * (1.0 - Math.Cos(2.0 * Math.PI * i / denom));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 545 KiB |
|
After Width: | Height: | Size: 544 KiB |
|
After Width: | Height: | Size: 545 KiB |
|
After Width: | Height: | Size: 532 KiB |
|
After Width: | Height: | Size: 544 KiB |
|
After Width: | Height: | Size: 531 KiB |
|
After Width: | Height: | Size: 537 KiB |
|
After Width: | Height: | Size: 548 KiB |
@@ -33,7 +33,7 @@ public sealed class Ssf3 : AbstractBase
|
||||
CalculateCoefficients();
|
||||
Name = $"Ssf3({_period})";
|
||||
WarmupPeriod = 6 * period;
|
||||
_handler = new TValuePublishedHandler(Handle);
|
||||
_handler = Handle;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 546 KiB |