Expand description
§Batch Type Conversions
This module provides optimized batch type conversions using SIMD and vectorization for better performance when converting large arrays of data.
§Features
- SIMD-accelerated batch conversions for numeric types
- Parallel processing for large datasets
- Optimized memory access patterns
- Support for ndarray integration
- Error reporting for individual elements
§Usage
use scirs2_core::batch_conversions::{BatchConverter, BatchConversionConfig};
use ::ndarray::Array1;
// Convert a large array of f64 to f32 with SIMD optimization
let data: Vec<f64> = (0..1000).map(|i| i as f64 * 0.1).collect();
let config = BatchConversionConfig::default().with_simd(true);
let converter = BatchConverter::new(config);
let result: Vec<f32> = converter.convert_slice(&data).expect("Operation failed");
assert_eq!(result.len(), data.len());
// Convert with error handling for individual elements
let large_data: Vec<f64> = vec![1e10, 2.5, f64::NAN, 3.7];
let (converted, errors) = converter.convert_slice_witherrors::<f64, f32>(&large_data);
assert_eq!(converted.len(), 2); // Only 2.5 and 3.7 convert successfully
assert_eq!(errors.len(), 2); // NAN and overflow errorsModules§
- ndarray_
integration - Integration with ndarray for batch conversions
- utils
- Utility functions for common batch conversions
Structs§
- Batch
Conversion Config - Configuration for batch conversions
- Batch
Conversion Result - Result of batch conversion with partial success
- Batch
Converter - High-performance batch converter for numeric types
- Element
Conversion Error - Error information for a single element in batch conversion