mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 22:08:05 +00:00
normalization of methods
This commit is contained in:
@@ -70,7 +70,7 @@ public class HpfTests
|
||||
var tseriesResult = hpf.Update(source);
|
||||
var spanOutput = new double[source.Count];
|
||||
|
||||
Hpf.Calculate(source.Values, spanOutput, 40, out _);
|
||||
Hpf.Batch(source.Values, spanOutput, 40, out _);
|
||||
|
||||
for (int i = 0; i < source.Count; i++)
|
||||
{
|
||||
@@ -118,6 +118,6 @@ public class HpfTests
|
||||
{
|
||||
double[] src = new double[10];
|
||||
double[] dst = new double[5];
|
||||
Assert.Throws<ArgumentException>(() => Hpf.Calculate(src, dst, 40, out _));
|
||||
Assert.Throws<ArgumentException>(() => Hpf.Batch(src, dst, 40, out _));
|
||||
}
|
||||
}
|
||||
|
||||
+17
-4
@@ -181,7 +181,7 @@ public sealed class Hpf : AbstractBase
|
||||
|
||||
var output = new double[source.Count];
|
||||
|
||||
Calculate(source.Values, output, Length, out var endState);
|
||||
Batch(source.Values, output, Length, out var endState);
|
||||
|
||||
_state = new State
|
||||
{
|
||||
@@ -206,17 +206,22 @@ public sealed class Hpf : AbstractBase
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int length)
|
||||
public static TSeries Batch(TSeries source, int length = 40)
|
||||
{
|
||||
Calculate(source, output, length, out _);
|
||||
var indicator = new Hpf(length);
|
||||
return indicator.Update(source);
|
||||
}
|
||||
|
||||
public static void Batch(ReadOnlySpan<double> source, Span<double> output, int length)
|
||||
{
|
||||
Batch(source, output, length, out _);
|
||||
}
|
||||
/// <summary>
|
||||
/// Batch HPF. Returns end state so callers can restore streaming state without replay.
|
||||
/// NaN/Inf => carry-forward last finite source.
|
||||
/// Outputs 0 for the first two finite samples, then runs the 2-pole recursion.
|
||||
/// </summary>
|
||||
public static void Calculate(
|
||||
public static void Batch(
|
||||
ReadOnlySpan<double> source,
|
||||
Span<double> output,
|
||||
int length,
|
||||
@@ -304,6 +309,14 @@ public sealed class Hpf : AbstractBase
|
||||
state = (hp1, hp2, src1, src2, samples, hasSrc);
|
||||
}
|
||||
|
||||
public static (TSeries Results, Hpf Indicator) Calculate(TSeries source, int length = 40)
|
||||
{
|
||||
var indicator = new Hpf(length);
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Unsubscribes from the source publisher if one was provided during construction.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user