JITCMatrix#

class brainevent.JITCMatrix(*args, shape, buffers=None)#

Just-in-time Connectivity (JITC) matrix.

A base class for just-in-time connectivity matrices that inherits from the SparseMatrix class in the brainunit library. This class serves as an abstraction for sparse matrices that are generated or computed on demand rather than stored in full.

JITC matrices are particularly useful in neural network simulations where connectivity patterns might be large but follow specific patterns that can be efficiently computed rather than explicitly stored in memory.

Notes

This is a base class and should be subclassed for specific implementations of JITC matrices. All attributes from brainunit.sparse.SparseMatrix are inherited.

apply(fn)[source]#

Apply a function to matrix value parameters while keeping structure.

Parameters:

fn (callable) – Unary callable applied by subclasses to their value parameters.

Returns:

A new matrix-like object with transformed values.

Return type:

JITCMatrix

apply2(other, fn, *, reverse=False)[source]#

Apply a binary function with consistent sparse-matrix semantics.

Parameters:
  • other (Any) – Right-hand operand for normal operations, or left-hand operand when reverse=True.

  • fn (callable) – Binary function from operator or a compatible callable.

  • reverse (bool) – If False, compute fn(self, other) via _binary_op. If True, compute fn(other, self) via _binary_rop. Defaults to False.

Returns:

Result of the operation.

Return type:

JITCMatrix or Any

classmethod fromdense(dense, **kwargs)[source]#

Unsupported: JITC connectivity cannot be recovered from a dense matrix.

Raises:

UnsupportedOperationError – Always. The generating (prob, seed) cannot be inferred from a materialised matrix.

tocoo()[source]#

Convert to COO by materialising through tocsr().

Returns:

The same logical matrix in COO format. Eager-only (O(nnz)), inheriting the tracing restriction of tocsr().

Return type:

brainunit.sparse.COO

See also

tocsr

Direct count+fill materialisation to CSR.

tocsc

Convert to compressed sparse column format.

tocsc()[source]#

Convert to CSC by materialising through tocsr().

Returns:

The same logical matrix in CSC format. Eager-only (O(nnz)), inheriting the tracing restriction of tocsr().

Return type:

CSC

See also

tocsr

Direct count+fill materialisation to CSR.

tocoo

Convert to coordinate format.

update_on_post(*args, **kwargs)[source]#

Unsupported: JITC connectivity has no per-synapse plastic weight.

Raises:

UnsupportedOperationError – Always. Materialise first with mat.tocsr().update_on_post(...).

update_on_pre(*args, **kwargs)[source]#

Unsupported: JITC connectivity has no per-synapse plastic weight.

Raises:

UnsupportedOperationError – Always. Materialise first with mat.tocsr().update_on_pre(...).

yw_to_w(*args, **kwargs)[source]#

Unsupported: JITC weights are not per-synapse.

Raises:

UnsupportedOperationError – Always. Materialise first with mat.tocsr().yw_to_w(...).

yw_to_w_transposed(*args, **kwargs)[source]#

Unsupported: JITC weights are not per-synapse.

Raises:

UnsupportedOperationError – Always. Materialise first with mat.tocsr().yw_to_w_transposed(...).