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
+4 -4
View File
@@ -131,7 +131,7 @@ public class SkewTests
var series = new TSeries(times, values);
// 1. Batch Mode (static method)
var batchSeries = Skew.Calculate(series, period);
var batchSeries = Skew.Batch(series, period);
double expected = batchSeries.Last.Value;
// 2. Span Mode (static method with spans)
@@ -192,7 +192,7 @@ public class SkewTests
var series = new TSeries(times, values);
var tseriesResult = Skew.Calculate(series, 10);
var tseriesResult = Skew.Batch(series, 10);
Skew.Batch(source.AsSpan(), output.AsSpan(), 10);
for (int i = 0; i < count; i++)
@@ -313,7 +313,7 @@ public class SkewTests
// Batch
var series = new TSeries(new System.Collections.Generic.List<long>(new long[data.Length]), new System.Collections.Generic.List<double>(data));
var batchResult = Skew.Calculate(series, period);
var batchResult = Skew.Batch(series, period);
for (int i = 0; i < data.Length; i++)
{
@@ -391,7 +391,7 @@ public class SkewTests
var series = new TSeries(new System.Collections.Generic.List<long>(new long[count]), new System.Collections.Generic.List<double>(data));
// Batch calculation
var batchResult = Skew.Calculate(series, 10);
var batchResult = Skew.Batch(series, 10);
// Verify last value against streaming
var skew = new Skew(10);
+9 -2
View File
@@ -222,7 +222,7 @@ public sealed class Skew : AbstractBase
}
}
public static TSeries Calculate(TSeries source, int period, bool isPopulation = false)
public static TSeries Batch(TSeries source, int period, bool isPopulation = false)
{
var skew = new Skew(period, isPopulation);
return skew.Update(source);
@@ -260,6 +260,13 @@ public sealed class Skew : AbstractBase
CalculateScalarCore(source, output, period, isPopulation);
}
public static (TSeries Results, Skew Indicator) Calculate(TSeries source, int period, bool isPopulation = false)
{
var indicator = new Skew(period, isPopulation);
TSeries results = indicator.Update(source);
return (results, indicator);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void CalculateScalarCore(ReadOnlySpan<double> source, Span<double> output, int period, bool isPopulation)
{
@@ -547,4 +554,4 @@ public sealed class Skew : AbstractBase
Unsafe.Add(ref outRef, i) = CalculateSkewFromSums(sum, sumSq, sumCu, n, isPopulation);
}
}
}
}