mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-29 02:07:42 +00:00
74b49d2bb4
- Introduced TBar struct for efficient OHLCV data representation. - Implemented TBarSeries class for high-performance collection of TBar instances using Structure of Arrays (SoA) layout. - Added TSeries class for time-series data management with zero-copy access. - Created TValue struct for time-value pairs with implicit conversions. - Defined IFeed interface for consistent data feed implementations. - Developed CsvFeed class for loading historical OHLCV data from CSV files. - Implemented GBM class for generating synthetic financial data using Geometric Brownian Motion. - Added Quantower project files for Averages indicator with necessary dependencies and configurations. - Included extensive usage examples and notebooks for TBar, TBarSeries, TSeries, TValue, and feed implementations.
1.6 KiB
1.6 KiB
SimdExtensions Class
SimdExtensions provides high-performance, SIMD-accelerated extension methods for ReadOnlySpan<double>. It leverages .NET's Vector<T> to achieve 4-8x speedups on supported hardware (AVX2, AVX-512) while automatically falling back to scalar implementations on older hardware.
Key Features
- Hardware Acceleration: Uses CPU vector registers to process multiple elements in parallel.
- Automatic Fallback: Gracefully handles non-SIMD hardware or small arrays.
- Zero-Allocation: Operates directly on spans without creating new arrays.
- Aggressive Inlining: Methods are marked for inlining to minimize call overhead.
Available Methods
| Method | Description |
|---|---|
SumSIMD() |
Calculates the sum of elements. |
MinSIMD() |
Finds the minimum value. |
MaxSIMD() |
Finds the maximum value. |
MinMaxSIMD() |
Finds both min and max in a single pass (more efficient than separate calls). |
AverageSIMD() |
Calculates the arithmetic mean. |
VarianceSIMD() |
Calculates the sample variance. |
StdDevSIMD() |
Calculates the sample standard deviation. |
Performance
On modern CPUs (e.g., Intel Core i7/i9, AMD Ryzen), these methods typically outperform standard LINQ or scalar loops by a factor of 4 to 8 for large arrays.
Usage
using QuanTAlib;
double[] data = { 1.0, 2.0, 3.0, 4.0, 5.0, ... };
ReadOnlySpan<double> span = data;
// Calculate sum
double sum = span.SumSIMD();
// Calculate min and max in one pass
var (min, max) = span.MinMaxSIMD();
// Calculate standard deviation
double stdDev = span.StdDevSIMD();