brainevent.cscmv_dt2t#
- brainevent.cscmv_dt2t(y, w, indices, indptr, *, shape, transpose=False, backend=None)[source]#
Element-wise product of a vector and CSC weights, indexed by CSC structure.
For each non-zero entry
jin the CSC matrix at position(row, col), computesout[j] = w[j] * y[row](non-transposed) orout[j] = w[j] * y[col](transposed). The result has the same shape aswandindices(i.e., one value per structural non-zero).This is the CSC counterpart of
csrmv_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 tocsrmv_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) – Dense vector indexed by the CSC structure. Shape(shape[0],)whentranspose=Falseor(shape[1],)whentranspose=True.w (
Array|ndarray|Quantity|Number) – Per-synapse weight values in CSC data order. Shape(nse,), 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 – Per-synapse result vector. Shape
(nse,), same asw.- Return type:
Array|ndarray|Quantity|Number
See also
csrmv_dt2tThe CSR primitive this wraps.
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:csrmv_dt2t(y, w, indices, indptr, shape=shape[::-1], transpose=not transpose)
Examples
>>> import jax.numpy as jnp >>> from brainevent import cscmv_dt2t >>> # CSC of a (3, 2) matrix: indptr over the 2 columns. >>> y = jnp.array([1.0, 2.0, 3.0]) >>> w = jnp.array([0.5, 0.3, 0.7, 0.1]) >>> indices = jnp.array([0, 2, 1, 2], dtype=jnp.int32) >>> indptr = jnp.array([0, 2, 4], dtype=jnp.int32) >>> cscmv_dt2t(y, w, indices, indptr, shape=(3, 2))