random_array_parallel

Function random_array_parallel 

Source
pub fn random_array_parallel<T>(
    shape: (usize, usize),
    density: f64,
    seed: Option<u64>,
    format: &str,
    parallel_threshold: usize,
) -> SparseResult<Box<dyn SparseArray<T>>>
where T: Float + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T> + Debug + Copy + Send + Sync + 'static,
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 reproducibility
  • format - 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