fix: add validation for empty span in MinScalar and MaxScalar methods; ensure valid OHLC values in GBM calculations

This commit is contained in:
Miha Kralj
2025-12-13 22:51:26 -08:00
parent 7168866098
commit fd3065e7b9
3 changed files with 33 additions and 16 deletions
+6
View File
@@ -37,6 +37,9 @@ public static class SimdExtensions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static double MinScalar(ReadOnlySpan<double> span)
{
if (span.Length == 0)
throw new ArgumentException("Span must not be empty", nameof(span));
double min = span[0];
for (int i = 1; i < span.Length; i++)
{
@@ -49,6 +52,9 @@ public static class SimdExtensions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static double MaxScalar(ReadOnlySpan<double> span)
{
if (span.Length == 0)
throw new ArgumentException("Span must not be empty", nameof(span));
double max = span[0];
for (int i = 1; i < span.Length; i++)
{