Skip to main content

SynapseStore

Struct SynapseStore 

Source
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

Source

pub fn empty(n_neurons: u32) -> Self

Create empty store for n neurons (no connections).

Source

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.

Source

pub fn outgoing(&self, neuron: u32) -> &[Synapse]

Get outgoing synapses for a given source neuron.

Source

pub fn outgoing_mut(&mut self, neuron: u32) -> &mut [Synapse]

Get mutable outgoing synapses for a given source neuron.

Source

pub fn total_synapses(&self) -> usize

Total number of synapses across all neurons.

Source

pub fn n_neurons(&self) -> u32

Number of neurons this store covers.

Source

pub fn prune_dead(&mut self) -> usize

Remove dead synapses (maturity == 0x00) and rebuild CSR. Returns count of pruned synapses.

Source

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.

Source

pub fn extend(&mut self, count: usize)

Extend the store to accommodate additional neurons (with no synapses).

Used when dynamically spawning neurons from templates.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.