pub struct SynapseStore {
pub row_ptr: Vec<u32>,
pub synapses: Vec<Synapse>,
}Expand description
Compressed Sparse Row synapse storage.
All outgoing synapses for neuron i are at indices row_ptr[i]..row_ptr[i+1]
in the synapses array. This gives cache-friendly iteration during spike
propagation — all targets of a spiking neuron are contiguous in memory.
Fields§
§row_ptr: Vec<u32>Index into synapses for each neuron. Length = n_neurons + 1.
row_ptr[i] = start index, row_ptr[i+1] = end index (exclusive).
synapses: Vec<Synapse>All synapses, grouped contiguously by source neuron.
Implementations§
Source§impl SynapseStore
impl SynapseStore
Sourcepub fn from_edges(n_neurons: u32, edges: Vec<(u32, Synapse)>) -> Self
pub fn from_edges(n_neurons: u32, edges: Vec<(u32, Synapse)>) -> Self
Build CSR from a list of (source_neuron, Synapse) pairs.
The pairs do NOT need to be sorted — this function sorts them internally.
Sourcepub fn outgoing(&self, neuron: u32) -> &[Synapse]
pub fn outgoing(&self, neuron: u32) -> &[Synapse]
Get outgoing synapses for a given source neuron.
Sourcepub fn outgoing_mut(&mut self, neuron: u32) -> &mut [Synapse]
pub fn outgoing_mut(&mut self, neuron: u32) -> &mut [Synapse]
Get mutable outgoing synapses for a given source neuron.
Sourcepub fn total_synapses(&self) -> usize
pub fn total_synapses(&self) -> usize
Total number of synapses across all neurons.
Sourcepub fn prune_dead(&mut self) -> usize
pub fn prune_dead(&mut self) -> usize
Remove dead synapses (maturity == 0x00) and rebuild CSR. Returns count of pruned synapses.
Sourcepub fn add_synapse(&mut self, source: u32, syn: Synapse)
pub fn add_synapse(&mut self, source: u32, syn: Synapse)
Add a synapse from source to the given target. Rebuilds the CSR row.
This is expensive — batch additions and rebuild when possible.