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 (
Array|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 (
Array) – Integer index array of shape(num_pre, num_conn)specifying the post-synaptic (column) indices of each connection.spikes (
Array|Quantity) – Binary spike vector. Entries are treated as active whenTrue(boolean) or> 0(float).shape (
Tuple[int,int]) – Logical(num_pre, num_post)shape of the equivalent dense weight matrix.transpose (
bool) – IfFalse(default), computeW @ s(fixed post-synaptic connections). IfTrue, computeW^T @ s(fixed pre-synaptic connections, scatter mode).backend (
str|None) – Execution backend override ('numba','pallas','cuda_raw', orNonefor automatic selection).col_weights (
Quantity|Array|None) – Optional column-major weights for the same logical sparse matrix, used by the CUDAtranspose=Falsescatter path. Homogeneous weights must have size1; heterogeneous weights must have sizeNNZ.col_indices (
Array|None) – Optional column-major row-index array aligned withcol_weights. Shape is(NNZ,).col_indptr (
Array|None) – Optional column pointer array with shape(num_post + 1,).
- Returns:
Result vector. Shape is
(num_pre,)whentranspose=Falseor(num_post,)whentranspose=True.- Return type:
Array|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 float 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.]