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
+1 -1
View File
@@ -44,7 +44,7 @@ public class SgfTests
// 3. Span Mode
double[] spanInput = series.Values.ToArray();
double[] spanOutput = new double[spanInput.Length];
Sgf.Calculate(spanInput, spanOutput, period, polyOrder);
Sgf.Batch(spanInput, spanOutput, period, polyOrder);
// Assert
for (int i = 0; i < series.Count; i++)
+1 -1
View File
@@ -201,7 +201,7 @@ public class SgfValidationTests : IDisposable
foreach (var (period, order) in scenarios)
{
double[] output = new double[source.Length];
Sgf.Calculate(source.AsSpan(), output.AsSpan(), period, order);
Sgf.Batch(source.AsSpan(), output.AsSpan(), period, order);
var expected = CalculateExpectedSgf(source, period, order);
+20 -7
View File
@@ -177,7 +177,7 @@ public sealed class Sgf : AbstractBase
}
var resultValues = new double[source.Count];
Calculate(source.Values, resultValues, _period, _polyOrder);
Batch(source.Values, resultValues, _period, _polyOrder);
var result = new TSeries();
var times = source.Times;
@@ -197,16 +197,14 @@ public sealed class Sgf : AbstractBase
return result;
}
public override void Prime(ReadOnlySpan<double> source, TimeSpan? step = null)
public static TSeries Batch(TSeries source, int period, int polyOrder = 2)
{
foreach (double value in source)
{
Update(new TValue(DateTime.MinValue, value), isNew: true);
}
var indicator = new Sgf(period, polyOrder);
return indicator.Update(source);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int period, int polyOrder = 2)
public static void Batch(ReadOnlySpan<double> source, Span<double> output, int period, int polyOrder = 2)
{
if (source.Length != output.Length)
{
@@ -262,6 +260,21 @@ public sealed class Sgf : AbstractBase
}
}
public override void Prime(ReadOnlySpan<double> source, TimeSpan? step = null)
{
foreach (double value in source)
{
Update(new TValue(DateTime.MinValue, value), isNew: true);
}
}
public static (TSeries Results, Sgf Indicator) Calculate(TSeries source, int period, int polyOrder = 2)
{
var indicator = new Sgf(period, polyOrder);
TSeries results = indicator.Update(source);
return (results, indicator);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void CalculateWeightsSpan(Span<double> weights, int period, int polyOrder)
{