pub fn random_array_parallel<T>(
shape: (usize, usize),
density: f64,
seed: Option<u64>,
format: &str,
parallel_threshold: usize,
) -> SparseResult<Box<dyn SparseArray<T>>>
Expand description
Creates a large sparse random array using parallel processing
This function uses parallel construction for improved performance when creating large sparse arrays with many non-zero elements.
§Arguments
shape
- Shape of the array (rows, cols)density
- Density of non-zero elements (0.0 to 1.0)seed
- Optional random seed for reproducibilityformat
- Format of the output array (“csr” or “coo”)parallel_threshold
- Minimum number of elements to use parallel construction
§Returns
A sparse array with randomly distributed non-zero elements
§Examples
use scirs2_sparse::construct::random_array_parallel;
// Create a large random sparse array
let large_random = random_array_parallel::<f64>((1000, 1000), 0.01, Some(42), "csr", 10000).unwrap();
assert_eq!(large_random.shape(), (1000, 1000));
assert!(large_random.nnz() > 5000); // Approximately 10000 non-zeros expected