Refactor and optimize TBar, TBarSeries, and TSeries notebooks; remove obsolete code

- Enhanced Alma class by simplifying the CalculateWeightedSum method and removing unnecessary comments.
- Removed SIMD-related methods from Conv class, replacing them with optimized DotProduct calls.
- Updated Sma and Wma classes to use source.ContainsNonFinite() for non-finite value checks, improving readability and performance.
This commit is contained in:
Miha Kralj
2025-12-10 15:03:58 -05:00
parent b26d5d7751
commit 47884bddab
9 changed files with 371 additions and 668 deletions
+1 -15
View File
@@ -225,7 +225,7 @@ public sealed class Sma : ITValuePublisher
// Try SIMD path for large, clean datasets
// Requirements: AVX2 support, large enough dataset, no NaN values
const int SimdThreshold = 256;
if (Avx2.IsSupported && len >= SimdThreshold && !HasNonFiniteValues(source))
if (Avx2.IsSupported && len >= SimdThreshold && !source.ContainsNonFinite())
{
CalculateSimdCore(source, output, period);
return;
@@ -367,20 +367,6 @@ public sealed class Sma : ITValuePublisher
}
}
/// <summary>
/// Checks if span contains any non-finite values (NaN or Infinity).
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool HasNonFiniteValues(ReadOnlySpan<double> span)
{
for (int idx = 0; idx < span.Length; idx++)
{
if (!double.IsFinite(span[idx]))
return true;
}
return false;
}
/// <summary>
/// Resets the SMA state.
/// </summary>