Skip to main content

SynapseArray

Struct SynapseArray 

Source
pub struct SynapseArray<const N: usize> {
    pub count: usize,
    pub source_neurons: [u32; N],
    pub target_neurons: [u32; N],
    pub weights: [u8; N],
    pub postsynaptic_potentials: [u8; N],
    pub types: [u8; N],
    pub valid_mask: [bool; N],
}
Expand description

Fixed-size synapse array for embedded systems

All data is stack-allocated with compile-time size limits. No heap allocations, perfect for no_std environments.

Fields§

§count: usize

Current number of synapses

§source_neurons: [u32; N]

Source neuron IDs

§target_neurons: [u32; N]

Target neuron IDs

§weights: [u8; N]

Synaptic weights (0-255)

§postsynaptic_potentials: [u8; N]

Postsynaptic potentials (0-255)

§types: [u8; N]

Synapse types (0=excitatory, 1=inhibitory)

§valid_mask: [bool; N]

Valid synapse mask

Implementations§

Source§

impl<const N: usize> SynapseArray<N>

Source

pub const fn new() -> SynapseArray<N>

Create a new fixed-size synapse array

Source§

impl<const N: usize> SynapseArray<N>

Source

pub fn add_synapse_simple( &mut self, source: u32, target: u32, weight: u8, psp: u8, synapse_type: SynapseType, ) -> bool

Add a synapse (simplified for backward compatibility)

Returns true if successful, false if array is full.

Source

pub fn propagate<const MAX_NEURONS: usize>( &self, fired_mask: &[bool; MAX_NEURONS], contributions: &mut [f32; MAX_NEURONS], )

Propagate activity from fired neurons (single-threaded)

Uses platform-agnostic core functions internally.

§Arguments
  • fired_mask - Which neurons fired (indexed by neuron ID)
  • contributions - Output: accumulated contributions per target neuron (caller-allocated)
Source

pub const fn memory_footprint() -> usize

Get memory footprint in bytes

Trait Implementations§

Source§

impl<const N: usize> Default for SynapseArray<N>

Source§

fn default() -> SynapseArray<N>

Returns the “default value” for a type. Read more
Source§

impl<const N: usize> SynapseStorage for SynapseArray<N>

Source§

fn source_neurons(&self) -> &[u32]

Source neuron IDs slice
Source§

fn target_neurons(&self) -> &[u32]

Target neuron IDs slice
Source§

fn weights(&self) -> &[u8]

Synaptic weights slice (0-255, stored as u8)
Source§

fn postsynaptic_potentials(&self) -> &[u8]

Postsynaptic potentials slice (0-255)
Source§

fn types(&self) -> &[u8]

Synapse types slice (0=excitatory, 1=inhibitory)
Source§

fn valid_mask(&self) -> &[bool]

Valid synapse mask
Source§

fn weights_mut(&mut self) -> &mut [u8]

Mutable weights slice
Source§

fn postsynaptic_potentials_mut(&mut self) -> &mut [u8]

Mutable postsynaptic potentials slice
Source§

fn valid_mask_mut(&mut self) -> &mut [bool]

Mutable valid mask
Source§

fn count(&self) -> usize

Number of synapses currently stored
Source§

fn capacity(&self) -> usize

Maximum capacity
Source§

fn add_synapse( &mut self, source: u32, target: u32, weight: u8, psp: u8, synapse_type: u8, ) -> Result<usize, RuntimeError>

Add a single synapse
Source§

fn remove_synapse(&mut self, idx: usize) -> Result<(), RuntimeError>

Remove a single synapse by index
Source§

fn remove_synapses_from_sources( &mut self, source_neurons: &[u32], ) -> Result<usize, RuntimeError>

Remove all synapses from specific source neurons
Source§

fn remove_synapses_between( &mut self, source: u32, target: u32, ) -> Result<usize, RuntimeError>

Remove synapses between specific source and target
Source§

fn update_weight( &mut self, idx: usize, new_weight: u8, ) -> Result<(), RuntimeError>

Update weight of a synapse
Source§

fn valid_count(&self) -> usize

Get count of valid (non-deleted) synapses

Auto Trait Implementations§

§

impl<const N: usize> Freeze for SynapseArray<N>

§

impl<const N: usize> RefUnwindSafe for SynapseArray<N>

§

impl<const N: usize> Send for SynapseArray<N>

§

impl<const N: usize> Sync for SynapseArray<N>

§

impl<const N: usize> Unpin for SynapseArray<N>

§

impl<const N: usize> UnwindSafe for SynapseArray<N>

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.