brainevent.binary_fcnmm#
- brainevent.binary_fcnmm = <NameScope(brainevent.binary_fcnmm)>#
Event-driven sparse matrix–matrix product with fixed connection number.
Computes
Y = W @ M(orY = W^T @ Mwhentranspose=True) whereWis a sparse weight matrix stored in fixed-connection-number format andMis 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)wherekmatches the appropriate sparse-matrix dimension.shape (
Tuple[int,int]) – Logical(num_pre, num_post)shape of the equivalent dense weight matrix.transpose (
bool) – IfFalse, computeW @ M(fixed post-synaptic connections). IfTrue, computeW^T @ M(fixed pre-synaptic connections, scatter mode).
- Returns:
Result matrix of shape
(num_pre, n)whentranspose=Falseor(num_post, n)whentranspose=True.- Return type:
Array|Quantity
See also
binary_fcnmvEvent-driven sparse matrix–vector product.
fcnmmFloat (non-event-driven) sparse matrix–matrix 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-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
Truefor boolean entries or> 0for float entries ofM. For homogeneous weights (weightshas 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 alli, k, jThe 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.]]