style patterns

This commit is contained in:
Miha Kralj
2026-01-25 16:01:45 -08:00
parent 2836f253c4
commit e59665c8f0
399 changed files with 6892 additions and 1323 deletions
+17 -2
View File
@@ -41,7 +41,9 @@ public sealed class PseudoHuber : BiInputIndicatorBase
: base(period, $"PseudoHuber({period},{delta:F3})")
{
if (delta <= 0)
{
throw new ArgumentException("Delta must be positive", nameof(delta));
}
Delta = delta;
_deltaSquared = delta * delta;
@@ -65,7 +67,9 @@ public sealed class PseudoHuber : BiInputIndicatorBase
public static TSeries Calculate(TSeries actual, TSeries predicted, int period, double delta = 1.0)
{
if (actual.Count != predicted.Count)
{
throw new ArgumentException("Actual and predicted series must have the same length", nameof(predicted));
}
int len = actual.Count;
var t = new List<long>(len);
@@ -89,14 +93,25 @@ public sealed class PseudoHuber : BiInputIndicatorBase
public static void Batch(ReadOnlySpan<double> actual, ReadOnlySpan<double> predicted, Span<double> output, int period, double delta = 1.0)
{
if (actual.Length != predicted.Length || actual.Length != output.Length)
{
throw new ArgumentException("All spans must have the same length", nameof(output));
}
if (period <= 0)
{
throw new ArgumentException("Period must be greater than 0", nameof(period));
}
if (delta <= 0)
{
throw new ArgumentException("Delta must be positive", nameof(delta));
}
int len = actual.Length;
if (len == 0) return;
if (len == 0)
{
return;
}
// Pre-compute Pseudo-Huber errors using shared helper
const int StackAllocThreshold = 256;
@@ -109,4 +124,4 @@ public sealed class PseudoHuber : BiInputIndicatorBase
// Apply rolling mean
ErrorHelpers.ApplyRollingMean(errors, output, period);
}
}
}