mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-24 13:38:05 +00:00
normalization of methods
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user