brainevent.jitumv

Contents

brainevent.jitumv#

brainevent.jitumv = <NameScope(brainevent.jitumv)>#

Float matrix-vector product with a JIT uniform connectivity matrix.

Computes the product of a just-in-time generated sparse matrix with uniformly distributed weights and a dense vector. Unlike the binary variant, this function uses the full floating-point values of the vector elements.

The sparse matrix A of shape (m, n) is never materialized. Each entry A[i, j] is drawn from Uniform(w_low, w_high) with probability prob, seeded by seed.

Parameters:
  • w_low (Array | ndarray | Quantity | Number) – Lower bound of the uniform weight distribution. Scalar value, optionally with physical units (brainunit.Quantity).

  • w_high (Array | ndarray | Quantity | Number) – Upper bound of the uniform weight distribution. Must have the same dimension (units) as w_low.

  • prob (float) – Connection probability in [0, 1]. Determines the fraction of non-zero entries in each row/column of the connectivity matrix.

  • vector (Array | ndarray | Quantity | Number) – Input dense vector. Length must match the appropriate matrix dimension (n if transpose=False, m if transpose=True). Optionally with physical units.

  • seed (int | None) – Random seed for reproducible connectivity patterns. If None, a random seed is generated at compile time.

  • shape (Tuple[int, int]) – Shape (m, n) of the logical connectivity matrix.

  • transpose (bool) – If True, compute A.T @ vector instead of A @ vector. Default is False.

  • corder (bool) – Memory layout order for the connectivity generation. True for C-order (row-major), False for Fortran-order (column-major). Default is True.

  • backend (str | None) – Computation backend. One of 'numba' or 'pallas'. If None, the default backend is used.

Returns:

Result vector of length m (if transpose=False) or n (if transpose=True). Carries the product of units from the weight and the vector if either has physical units.

Return type:

Array | ndarray | Quantity | Number

See also

jitumm

Matrix-matrix variant.

binary_jitumv

Event-driven (binary) variant.

Notes

The connectivity matrix A of shape (m, n) follows the model:

A[i, j] = U[i, j] * B[i, j]

where U[i, j] ~ Uniform(w_low, w_high) and B[i, j] ~ Bernoulli(prob) are independent, both determined by seed.

The float matrix-vector product computes:

result[i] = sum_{j=0}^{n-1} A[i, j] * vector[j]

Unlike the binary variant (binary_jitumv()), this uses the full floating-point values of vector rather than treating them as binary events.

When transpose=True, the operation becomes result = A^T @ vector:

result[j] = sum_{i=0}^{m-1} A[i, j] * vector[i]

Examples

>>> import jax.numpy as jnp
>>> from brainevent._jit_uniform.float import jitumv
>>> vec = jnp.ones(5)
>>> result = jitumv(0.1, 0.5, 0.2, vec, seed=42, shape=(3, 5))
>>> result.shape
(3,)