mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-23 21:18:04 +00:00
normalization of methods
This commit is contained in:
@@ -97,7 +97,7 @@ public class AccelTests
|
||||
|
||||
// Output must be same length as source
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
Accel.Calculate(source.AsSpan(), wrongSizeOutput.AsSpan()));
|
||||
Accel.Batch(source.AsSpan(), wrongSizeOutput.AsSpan()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -110,7 +110,7 @@ public class AccelTests
|
||||
// 1. Batch Mode (static span)
|
||||
var tValues = series.Values.ToArray();
|
||||
var batchOutput = new double[tValues.Length];
|
||||
Accel.Calculate(tValues, batchOutput);
|
||||
Accel.Batch(tValues, batchOutput);
|
||||
double expected = batchOutput[^1];
|
||||
|
||||
// 2. Streaming Mode
|
||||
@@ -122,7 +122,7 @@ public class AccelTests
|
||||
double streamingResult = streamingInd.Last.Value;
|
||||
|
||||
// 3. TSeries Batch Mode
|
||||
var batchSeriesResult = Accel.Calculate(series);
|
||||
var batchSeriesResult = Accel.Batch(series);
|
||||
double tseriesResult = batchSeriesResult.Last.Value;
|
||||
|
||||
Assert.Equal(expected, streamingResult, precision: 9);
|
||||
@@ -207,7 +207,7 @@ public class AccelTests
|
||||
|
||||
// Batch
|
||||
var batchResults = new double[count];
|
||||
Accel.Calculate(data, batchResults);
|
||||
Accel.Batch(data, batchResults);
|
||||
|
||||
// Compare
|
||||
for (int i = 0; i < count; i++)
|
||||
|
||||
@@ -109,7 +109,7 @@ public class AccelValidationTests
|
||||
double[] expected = [0, 0, 2, 2, 2, 2];
|
||||
double[] output = new double[data.Length];
|
||||
|
||||
Accel.Calculate(data, output);
|
||||
Accel.Batch(data, output);
|
||||
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
|
||||
@@ -129,7 +129,7 @@ public sealed class Accel : AbstractBase
|
||||
var tSpan = CollectionsMarshal.AsSpan(t);
|
||||
var vSpan = CollectionsMarshal.AsSpan(v);
|
||||
|
||||
Calculate(sourceValues, vSpan);
|
||||
Batch(sourceValues, vSpan);
|
||||
sourceTimes.CopyTo(tSpan);
|
||||
|
||||
// Prime state with last two values using cached span
|
||||
@@ -176,7 +176,7 @@ public sealed class Accel : AbstractBase
|
||||
}
|
||||
}
|
||||
|
||||
public static TSeries Calculate(TSeries source)
|
||||
public static TSeries Batch(TSeries source)
|
||||
{
|
||||
var accel = new Accel();
|
||||
return accel.Update(source);
|
||||
@@ -187,7 +187,7 @@ public sealed class Accel : AbstractBase
|
||||
/// accel[i] = source[i] - 2*source[i-1] + source[i-2]
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Calculate(ReadOnlySpan<double> source, Span<double> output)
|
||||
public static void Batch(ReadOnlySpan<double> source, Span<double> output)
|
||||
{
|
||||
if (source.Length != output.Length)
|
||||
{
|
||||
@@ -314,6 +314,13 @@ public sealed class Accel : AbstractBase
|
||||
}
|
||||
}
|
||||
|
||||
public static (TSeries Results, Accel Indicator) Calculate(TSeries source)
|
||||
{
|
||||
var indicator = new Accel();
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static double FindFinite(double a, double b, double c)
|
||||
{
|
||||
@@ -334,4 +341,4 @@ public sealed class Accel : AbstractBase
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user