pub struct LatencyEncoder { /* private fields */ }Expand description
Encodes analog values into latency-coded spike times
Each input channel produces exactly one positive spike whose timestamp is
determined by the input strength within the configured range. Stronger
inputs fire earlier. Values below the range minimum map to the latest
possible spike at max_latency, and values above the range maximum map to
timestamp 0.
§Examples
use axon_encoder::prelude::*;
let mut enc = LatencyEncoder::try_new(10, (0.0, 1.0))?;
let out = enc.encode(&[1.0, 0.0]); // strong → early, weak → late
assert_eq!(out.spikes.len(), 2);
assert!(out.spikes[0].timestamp <= out.spikes[1].timestamp);Implementations§
Source§impl LatencyEncoder
impl LatencyEncoder
Sourcepub fn try_new(
max_latency: u64,
range: (f32, f32),
) -> Result<Self, EncoderError>
pub fn try_new( max_latency: u64, range: (f32, f32), ) -> Result<Self, EncoderError>
Creates a new LatencyEncoder, returning an EncoderError for invalid configuration.
max_latency == 0 is accepted and maps every input to timestamp 0.
Sourcepub fn encode_with_modulators(
&mut self,
input: &[f32],
modulators: &NeuroModulators,
gain_curves: &NeuromodulatorGainCurves,
) -> EncodedOutput
pub fn encode_with_modulators( &mut self, input: &[f32], modulators: &NeuroModulators, gain_curves: &NeuromodulatorGainCurves, ) -> EncodedOutput
Encodes input using neuromodulator-driven gain curves.
Inherent wrapper so callers need not import ModulatedEncoder.
Sourcepub fn encode_step_with_modulators(
&mut self,
input: &[f32],
modulators: &NeuroModulators,
gain_curves: &NeuromodulatorGainCurves,
) -> EncodedOutput
pub fn encode_step_with_modulators( &mut self, input: &[f32], modulators: &NeuroModulators, gain_curves: &NeuromodulatorGainCurves, ) -> EncodedOutput
Step-wise variant of encode_with_modulators.
Trait Implementations§
Source§impl Clone for LatencyEncoder
impl Clone for LatencyEncoder
Source§fn clone(&self) -> LatencyEncoder
fn clone(&self) -> LatencyEncoder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LatencyEncoder
impl Debug for LatencyEncoder
Source§impl Encoder for LatencyEncoder
impl Encoder for LatencyEncoder
Source§fn encode(&mut self, input: &[f32]) -> EncodedOutput
fn encode(&mut self, input: &[f32]) -> EncodedOutput
Encodes a slice of analog values into spike events (batch mode).
Source§fn encode_step(&mut self, input: &[f32]) -> EncodedOutput
fn encode_step(&mut self, input: &[f32]) -> EncodedOutput
Encodes a single step incrementally (streaming mode). Read more
Source§impl ModulatedEncoder for LatencyEncoder
impl ModulatedEncoder for LatencyEncoder
Source§fn encode_with_gains(
&mut self,
input: &[f32],
gains: EncodingGains,
) -> EncodedOutput
fn encode_with_gains( &mut self, input: &[f32], gains: EncodingGains, ) -> EncodedOutput
Encodes input using already evaluated encoding gains. Read more
Source§fn encode_step_with_gains(
&mut self,
input: &[f32],
gains: EncodingGains,
) -> EncodedOutput
fn encode_step_with_gains( &mut self, input: &[f32], gains: EncodingGains, ) -> EncodedOutput
Encodes one streaming step using already evaluated encoding gains. Read more
Source§fn encode_with_modulators(
&mut self,
input: &[f32],
modulators: &NeuroModulators,
gain_curves: &NeuromodulatorGainCurves,
) -> EncodedOutput
fn encode_with_modulators( &mut self, input: &[f32], modulators: &NeuroModulators, gain_curves: &NeuromodulatorGainCurves, ) -> EncodedOutput
Encodes input using neuromodulator-driven gain curves.
Source§fn encode_step_with_modulators(
&mut self,
input: &[f32],
modulators: &NeuroModulators,
gain_curves: &NeuromodulatorGainCurves,
) -> EncodedOutput
fn encode_step_with_modulators( &mut self, input: &[f32], modulators: &NeuroModulators, gain_curves: &NeuromodulatorGainCurves, ) -> EncodedOutput
Encodes one streaming step using neuromodulator-driven gain curves.
Source§impl PartialEq for LatencyEncoder
impl PartialEq for LatencyEncoder
impl StructuralPartialEq for LatencyEncoder
Auto Trait Implementations§
impl Freeze for LatencyEncoder
impl RefUnwindSafe for LatencyEncoder
impl Send for LatencyEncoder
impl Sync for LatencyEncoder
impl Unpin for LatencyEncoder
impl UnsafeUnpin for LatencyEncoder
impl UnwindSafe for LatencyEncoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more