mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 22:08:05 +00:00
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:
+1
-15
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user