brainevent.binary_jitumv#
- brainevent.binary_jitumv = <NameScope(brainevent.binary_jitumv)>#
Event-driven 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 binary event vector. Only non-zero (event) entries in
vectorcontribute to the output, making this operation efficient for spike-based neural network simulations.The sparse matrix
Aof shape(m, n)is never materialized. Each entryA[i, j]is drawn fromUniform(w_low, w_high)with probabilityprob, seeded byseed.- 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) asw_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 event vector. Can be boolean or floating-point; non-zero entries are treated as active events. Length must match the appropriate matrix dimension (niftranspose=False,miftranspose=True).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, computeA.T @ vectorinstead ofA @ 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(iftranspose=False) orn(iftranspose=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
binary_jitummEvent-driven matrix-matrix variant.
jitumvFloat (non-event) matrix-vector variant.
Notes
The connectivity matrix
Aof shape(m, n)follows the model:A[i, j] = U[i, j] * B[i, j]where
U[i, j] ~ Uniform(w_low, w_high)andB[i, j] ~ Bernoulli(prob)are independent, both determined byseed.The event-driven matrix-vector product computes:
result[i] = sum_{j : vector[j] is active} A[i, j]where “active” means
Truefor boolean arrays or> 0for float arrays. Only positions wherevector[j]is active contribute, making this efficient when the event vector is sparse. The full expansion is:result[i] = sum_{j} U[i, j] * B[i, j] * 1_{vector[j] active}When
transpose=True, the operation becomesresult = A^T @ vector.Examples
>>> import jax.numpy as jnp >>> from brainevent._jit_uniform.binary import binary_jitumv >>> events = jnp.array([True, False, True, True, False]) >>> result = binary_jitumv( ... 0.1, 0.5, 0.2, events, seed=42, ... shape=(3, 5), transpose=False, corder=True, ... ) >>> result.shape (3,)