brainevent.binary_fcnmv#
- brainevent.binary_fcnmv = <NameScope(brainevent.binary_fcnmv)>#
Event-driven sparse matrix–vector product with fixed connection number.
Computes
y = W @ s(ory = W^T @ swhentranspose=True) whereWis a sparse weight matrix stored in fixed-connection-number format andsis a binary spike vector. Only the connections to spiking neurons contribute to the result, making this operation event-driven.- Parameters:
weights (jax.Array or u.Quantity) – Non-zero weight values. Shape is
(1,)for homogeneous weights or(num_pre, num_conn)for heterogeneous weights. Must have a floating-point dtype.indices (jax.Array) – Integer index array of shape
(num_pre, num_conn)specifying the post-synaptic (column) indices of each connection.spikes (jax.Array or u.Quantity) – Binary spike vector. Entries are treated as active when
True(boolean) or!= 0(numeric; negative values and NaN are active).shape (tuple[int, int]) – Logical
(num_pre, num_post)shape of the equivalent dense weight matrix.transpose (bool, optional) – If
False(default), computeW @ s(fixed post-synaptic connections). IfTrue, computeW^T @ s(fixed pre-synaptic connections, scatter mode).backend (str or None, optional) – Execution backend override (
'numba','pallas','cuda_raw', orNonefor automatic selection).weighted (bool, optional) – If
True, multiply each weight by the event value instead of its activity mask (WeightedArraysemantics); zero events are still skipped. Defaults toFalse.
- Returns:
Result vector. Shape is
(num_pre,)whentranspose=Falseor(num_post,)whentranspose=True.- Return type:
jax.Array or u.Quantity
See also
binary_fcnmmEvent-driven sparse matrix–matrix product.
fcnmvFloat (non-event-driven) sparse matrix–vector product.
Notes
The sparse weight matrix
Wof shape(num_pre, num_post)is stored in fixed-connection-number format where each rowihas exactlyn_connnon-zero entries at column positionsindices[i, :].The event-driven matrix-vector product computes (when
transpose=False):y[i] = sum_{k=0}^{n_conn-1} weights[i, k] * 1_{spikes[indices[i, k]] active}where “active” means
Truefor boolean spikes or!= 0for numeric spikes. For homogeneous weights (weightshas shape(1,)):y[i] = w * sum_{k=0}^{n_conn-1} 1_{spikes[indices[i, k]] active}When
transpose=True, the scatter-mode product computes:y[indices[i, k]] += weights[i, k] * 1_{spikes[i] active}for alli, kThe event-driven formulation skips inactive neurons entirely, making the computation efficient when the spike vector is sparse.
Examples
>>> import jax.numpy as jnp >>> from brainevent._fcn.binary import binary_fcnmv >>> >>> weights = jnp.ones(1, dtype=jnp.float32) # homogeneous >>> indices = jnp.array([[0, 1], [1, 2]]) # (2, 2) >>> spikes = jnp.array([True, False, True]) >>> y = binary_fcnmv(weights, indices, spikes, shape=(2, 3)) >>> print(y) [1. 1.]