brainevent.binary_fcnmm

Contents

brainevent.binary_fcnmm#

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

Event-driven sparse matrix–matrix product with fixed connection number.

Computes Y = W @ M (or Y = W^T @ M when transpose=True) where W is a sparse weight matrix stored in fixed-connection-number format and M is a dense binary event matrix. Only the connections to active (spiking) entries contribute to the result.

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.

  • matrix (Array | Quantity) – Dense binary event matrix of shape (k, n) where k matches the appropriate sparse-matrix dimension.

  • shape (Tuple[int, int]) – Logical (num_pre, num_post) shape of the equivalent dense weight matrix.

  • transpose (bool) – If False, compute W @ M (fixed post-synaptic connections). If True, compute W^T @ M (fixed pre-synaptic connections, scatter mode).

  • backend (str | None) – Execution backend override.

Returns:

Result matrix of shape (num_pre, n) when transpose=False or (num_post, n) when transpose=True.

Return type:

Array | Quantity

See also

binary_fcnmv

Event-driven sparse matrix–vector product.

fcnmm

Float (non-event-driven) sparse matrix–matrix product.

Notes

The sparse weight matrix W of shape (num_pre, num_post) is stored in fixed-connection-number format where each row i has exactly n_conn non-zero entries at column positions indices[i, :].

The event-driven matrix-matrix product applies column by column. When transpose=False (gather mode), for each output element:

Y[i, j] = sum_{k=0}^{n_conn-1} weights[i, k] * 1_{M[indices[i, k], j] active}

where “active” means True for boolean entries or > 0 for float entries of M. For homogeneous weights (weights has shape (1,)):

Y[i, j] = w * sum_{k=0}^{n_conn-1} 1_{M[indices[i, k], j] active}

When transpose=True (scatter mode), the computation distributes active entries to their target rows:

Y[indices[i, k], j] += weights[i, k] * 1_{M[i, j] active} for all i, k, j

The event-driven formulation skips inactive entries of M, making the computation efficient when the event matrix is sparse.

Examples

>>> import jax.numpy as jnp
>>> from brainevent._fcn.binary import binary_fcnmm
>>>
>>> weights = jnp.ones(1, dtype=jnp.float32)
>>> indices = jnp.array([[0, 1], [1, 2]])
>>> matrix = jnp.array([[True, False],
...                     [False, True],
...                     [True, True]])
>>> y = binary_fcnmm(weights, indices, matrix, shape=(2, 3), transpose=False)
>>> print(y)
[[1. 1.]
 [1. 2.]]