normalization of methods

This commit is contained in:
Miha Kralj
2026-02-10 21:33:16 -08:00
parent 915d7a007b
commit 6d6259a47d
527 changed files with 10525 additions and 2123 deletions
+5 -5
View File
@@ -28,11 +28,11 @@ public class BesselTests
double[] output = new double[5];
var exLength = Assert.Throws<ArgumentException>(() =>
Bessel.Calculate(source.AsSpan(), output.AsSpan(), 1));
Bessel.Batch(source.AsSpan(), output.AsSpan(), 1));
Assert.Equal("length", exLength.ParamName);
var exLengthZero = Assert.Throws<ArgumentException>(() =>
Bessel.Calculate(source.AsSpan(), output.AsSpan(), 0));
Bessel.Batch(source.AsSpan(), output.AsSpan(), 0));
Assert.Equal("length", exLengthZero.ParamName);
}
@@ -43,7 +43,7 @@ public class BesselTests
double[] wrongSizeOutput = new double[3];
var ex = Assert.Throws<ArgumentException>(() =>
Bessel.Calculate(source.AsSpan(), wrongSizeOutput.AsSpan(), 14));
Bessel.Batch(source.AsSpan(), wrongSizeOutput.AsSpan(), 14));
Assert.Equal("output", ex.ParamName);
}
@@ -252,7 +252,7 @@ public class BesselTests
var tseriesResult = Bessel.Calculate(series, 14).Results;
Bessel.Calculate(source.AsSpan(), output.AsSpan(), 14);
Bessel.Batch(source.AsSpan(), output.AsSpan(), 14);
for (int i = 0; i < 100; i++)
{
@@ -276,7 +276,7 @@ public class BesselTests
var tValues = series.Values.ToArray();
var spanInput = new ReadOnlySpan<double>(tValues);
var spanOutput = new double[tValues.Length];
Bessel.Calculate(spanInput, spanOutput, length);
Bessel.Batch(spanInput, spanOutput, length);
double spanResult = spanOutput[^1];
// 3. Streaming Mode
@@ -47,7 +47,7 @@ public sealed class BesselValidationTests : IDisposable
// Same data via Span API
var src = _testData.Data.Values.ToArray();
var outSpan = new double[src.Length];
Bessel.Calculate(src.AsSpan(), outSpan.AsSpan(), length);
Bessel.Batch(src.AsSpan(), outSpan.AsSpan(), length);
// Verify last window for convergence and consistency
ValidationHelper.VerifyData(qResult, outSpan, lookback: 0, skip: length, tolerance: ValidationHelper.DefaultTolerance);
+8 -8
View File
@@ -481,12 +481,6 @@ public sealed class Bessel : AbstractBase
/// <para><b>Complexity:</b> O(n) where n = source.Count</para>
/// <para>The returned indicator maintains state and can continue processing new values.</para>
/// </remarks>
public static (TSeries Results, Bessel Indicator) Calculate(TSeries source, int length)
{
var bessel = new Bessel(length);
TSeries results = bessel.Update(source);
return (results, bessel);
}
/// <summary>
/// Calculates filtered values for a span of doubles (stateless batch processing).
@@ -504,7 +498,7 @@ public sealed class Bessel : AbstractBase
/// <para>SIMD optimization is not applicable due to IIR recursive data dependency.</para>
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int length)
public static void Batch(ReadOnlySpan<double> source, Span<double> output, int length)
{
if (length < 2)
{
@@ -531,6 +525,12 @@ public sealed class Bessel : AbstractBase
CalculateCore(source, output, c1, c2, c3, length, ref state);
}
public static (TSeries Results, Bessel Indicator) Calculate(TSeries source, int length)
{
var bessel = new Bessel(length);
TSeries results = bessel.Update(source);
return (results, bessel);
}
/// <summary>
/// Event handler for reactive updates from subscribed publishers.
@@ -567,4 +567,4 @@ public sealed class Bessel : AbstractBase
}
base.Dispose(disposing);
}
}
}