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
@@ -101,7 +101,7 @@ public class Cheby2Tests
// Span
var spanResults = new double[count];
Cheby2.Calculate(values, spanResults, period, 5.0);
Cheby2.Batch(values, spanResults, period, 5.0);
// Compare
for (int i = 0; i < count; i++)
+15 -3
View File
@@ -136,7 +136,7 @@ public sealed class Cheby2 : AbstractBase
double[] values = source.Values.ToArray();
double[] results = new double[values.Length];
Calculate(values, results, Period, Attenuation);
Batch(values, results, Period, Attenuation);
TSeries output = [];
for (int i = 0; i < values.Length; i++)
@@ -217,8 +217,14 @@ public sealed class Cheby2 : AbstractBase
Last = default;
}
public static TSeries Batch(TSeries source, int period, double attenuation = 5.0)
{
var indicator = new Cheby2(period, attenuation);
return indicator.Update(source);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int period, double attenuation = 5.0)
public static void Batch(ReadOnlySpan<double> source, Span<double> output, int period, double attenuation = 5.0)
{
if (source.Length != output.Length)
{
@@ -322,6 +328,12 @@ public sealed class Cheby2 : AbstractBase
filt1 = filt;
}
}
public static (TSeries Results, Cheby2 Indicator) Calculate(TSeries source, int period, double attenuation = 5.0)
{
var indicator = new Cheby2(period, attenuation);
TSeries results = indicator.Update(source);
return (results, indicator);
}
/// <summary>
/// Unsubscribes from the source publisher if one was provided during construction.
@@ -334,4 +346,4 @@ public sealed class Cheby2 : AbstractBase
}
base.Dispose(disposing);
}
}
}