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
@@ -102,7 +102,7 @@ public class JerkTests
// Output must be same length as source
Assert.Throws<ArgumentException>(() =>
Jerk.Calculate(source.AsSpan(), wrongSizeOutput.AsSpan()));
Jerk.Batch(source.AsSpan(), wrongSizeOutput.AsSpan()));
}
[Fact]
@@ -115,7 +115,7 @@ public class JerkTests
// 1. Batch Mode (static span)
var tValues = series.Values.ToArray();
var batchOutput = new double[tValues.Length];
Jerk.Calculate(tValues, batchOutput);
Jerk.Batch(tValues, batchOutput);
double expected = batchOutput[^1];
// 2. Streaming Mode
@@ -127,7 +127,7 @@ public class JerkTests
double streamingResult = streamingInd.Last.Value;
// 3. TSeries Batch Mode
var batchSeriesResult = Jerk.Calculate(series);
var batchSeriesResult = Jerk.Batch(series);
double tseriesResult = batchSeriesResult.Last.Value;
Assert.Equal(expected, streamingResult, precision: 9);
@@ -211,7 +211,7 @@ public class JerkTests
// Batch
var batchResults = new double[count];
Jerk.Calculate(data, batchResults);
Jerk.Batch(data, batchResults);
// Compare
for (int i = 0; i < count; i++)
+1 -1
View File
@@ -128,7 +128,7 @@ public class JerkValidationTests
double[] expected = [0, 0, 0, 6, 6, 6];
double[] output = new double[data.Length];
Jerk.Calculate(data, output);
Jerk.Batch(data, output);
for (int i = 0; i < data.Length; i++)
{
+11 -4
View File
@@ -146,7 +146,7 @@ public sealed class Jerk : AbstractBase
var tSpan = CollectionsMarshal.AsSpan(t);
var vSpan = CollectionsMarshal.AsSpan(v);
Calculate(sourceValues, vSpan);
Batch(sourceValues, vSpan);
sourceTimes.CopyTo(tSpan);
// Prime state with last three values using cached span
@@ -200,7 +200,7 @@ public sealed class Jerk : AbstractBase
}
}
public static TSeries Calculate(TSeries source)
public static TSeries Batch(TSeries source)
{
var jerk = new Jerk();
return jerk.Update(source);
@@ -211,7 +211,7 @@ public sealed class Jerk : AbstractBase
/// jerk[i] = source[i] - 3*source[i-1] + 3*source[i-2] - source[i-3]
/// </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)
{
@@ -385,6 +385,13 @@ public sealed class Jerk : AbstractBase
}
}
public static (TSeries Results, Jerk Indicator) Calculate(TSeries source)
{
var indicator = new Jerk();
TSeries results = indicator.Update(source);
return (results, indicator);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static double FindFinite(double a, double b, double c, double d)
{
@@ -410,4 +417,4 @@ public sealed class Jerk : AbstractBase
return 0.0;
}
}
}