brainevent.cscmm_dt2t#
- brainevent.cscmm_dt2t(y, w, indices, indptr, *, shape, transpose=False, backend=None)[source]#
Batched element-wise product of dense vectors and CSC weights, indexed by CSC structure.
Batched generalization of
cscmv_dt2t(): for each batch elementband non-zero entryjin the CSC matrix at position(row, col), computesout[b, j] = w[b, j] * y[b, row](non-transposed) orout[b, j] = w[b, j] * y[b, col](transposed). Bothwandycarry a shared leading batch axis, and the result has the same shape asw(one value per batch element and per structural non-zero).This is the CSC counterpart of
csrmm_dt2t(). Because the CSC arrays of a matrixWof shape(m, k)are, array-for-array, the CSR arrays ofW.Tof shape(k, m), this function simply forwards tocsrmm_dt2t()with the shape reversed and thetransposeflag flipped. No data permutation is required, so it inherits the differentiability, unit handling, and backend dispatch of the underlying CSR primitive.The function supports physical units via
brainunit.- Parameters:
y (
Array|ndarray|Quantity|Number) – Batch of dense vectors indexed by the CSC structure. Shape(n_batch, shape[0])whentranspose=Falseor(n_batch, shape[1])whentranspose=True.w (
Array|ndarray|Quantity|Number) – Batch of per-synapse values in CSC data order. Shape(n_batch, nse); the trailing axis must match the shape ofindices.indices (
Array|ndarray) – Row indices of the CSC matrix. Shape(nse,)with integer dtype.indptr (
Array|ndarray) – Column index pointer array. Shape(shape[1] + 1,)with integer dtype.shape (tuple of int) – Two-element tuple
(m, k)giving the logical shape of the CSC matrix.transpose (
bool) – IfTrue, indexyby column indices instead of row indices. Default isFalse.backend (
str|None) – Compute backend. Default isNone(auto-select).
- Returns:
out – Batched per-synapse result. Shape
(n_batch, nse), same asw.- Return type:
Array|ndarray|Quantity|Number
See also
csrmm_dt2tThe CSR primitive this wraps.
cscmv_dt2tUnbatched (single-vector) variant of this operator.
Notes
A matrix
Wof shape(m, k)stored in CSC order has the samedata/indices/indptrarrays asW.Tstored in CSR order with shape(k, m). Under that view, indexingyby the CSC row (transpose=False) corresponds to indexing the CSR column axis, and indexing by the CSC column (transpose=True) corresponds to the CSR row axis. Hence the call delegates to:csrmm_dt2t(y, w, indices, indptr, shape=shape[::-1], transpose=not transpose)
Examples
>>> import jax.numpy as jnp >>> from brainevent import cscmm_dt2t >>> # CSC of a (3, 2) matrix: indptr over the 2 columns. >>> y = jnp.array([[1.0, 2.0, 3.0], [10.0, 20.0, 30.0]]) # (n_batch=2, m=3) >>> w = jnp.array([[0.5, 0.3, 0.7, 0.1], ... [1.0, 2.0, 3.0, 4.0]]) # (n_batch=2, nse=4) >>> indices = jnp.array([0, 2, 1, 2], dtype=jnp.int32) >>> indptr = jnp.array([0, 2, 4], dtype=jnp.int32) >>> cscmm_dt2t(y, w, indices, indptr, shape=(3, 2))