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
+2 -2
View File
@@ -231,7 +231,7 @@ public class SsfTests
var tseriesResult = Ssf.Calculate(series, 10).Results;
// Calculate with Span API
Ssf.Calculate(source.AsSpan(), output.AsSpan(), 10);
Ssf.Batch(source.AsSpan(), output.AsSpan(), 10);
// Compare results
for (int i = 0; i < 100; i++)
@@ -257,7 +257,7 @@ public class SsfTests
var tValues = series.Values.ToArray();
var spanInput = new ReadOnlySpan<double>(tValues);
var spanOutput = new double[tValues.Length];
Ssf.Calculate(spanInput, spanOutput, period);
Ssf.Batch(spanInput, spanOutput, period);
double spanResult = spanOutput[^1];
// 3. Streaming Mode
+9 -9
View File
@@ -315,15 +315,8 @@ public sealed class Ssf : AbstractBase
}
}
public static (TSeries Results, Ssf Indicator) Calculate(TSeries source, int period)
{
var ssf = new Ssf(period);
TSeries results = ssf.Update(source);
return (results, ssf);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int period)
public static void Batch(ReadOnlySpan<double> source, Span<double> output, int period)
{
if (period <= 0)
{
@@ -353,6 +346,13 @@ public sealed class Ssf : AbstractBase
CalculateCore(source, output, c1, c2, c3, period, ref state);
}
public static (TSeries Results, Ssf Indicator) Calculate(TSeries source, int period)
{
var ssf = new Ssf(period);
TSeries results = ssf.Update(source);
return (results, ssf);
}
public override void Reset()
{
_state = State.New();
@@ -371,4 +371,4 @@ public sealed class Ssf : AbstractBase
}
base.Dispose(disposing);
}
}
}