Skip to main content

parallel_batch_matvec

Function parallel_batch_matvec 

Source
pub fn parallel_batch_matvec(
    py: Python<'_>,
    matrices: Vec<Vec<f64>>,
    vectors: Vec<Vec<f64>>,
    n_rows: usize,
    n_cols: usize,
) -> PyResult<Vec<Vec<f64>>>
Expand description

Perform a batch of matrix-vector multiplications in parallel.

Each pair (matrices[i], vectors[i]) represents a multiplication A * v where A is stored in row-major order with shape (n_rows, n_cols) and v is a vector of length n_cols.

The GIL is released during Rayon computation.

§Arguments

  • matrices – list of flat row-major matrices, each with n_rows * n_cols elements.
  • vectors – list of vectors, each with n_cols elements.
  • n_rows – number of rows in each matrix.
  • n_cols – number of columns in each matrix (= length of each vector).

§Errors

Returns ValueError if:

  • matrices and vectors have different lengths.
  • Any matrix does not have exactly n_rows * n_cols elements.
  • Any vector does not have exactly n_cols elements.