pub struct PhaseEncoder { /* private fields */ }Expand description
Encodes analog values as phase-locked spikes within a repeating oscillation cycle
Each input channel produces at most one positive spike per call, with the spike timestamp positioned relative to the current background phase according to the normalized input value. Higher values map to later phase bins
Timestamps are computed as current_phase + phase_offset, which keeps ordering
stable within a single encode call (higher-value channels get later timestamps)
Ordering across calls is not globally guaranteed, since phase_offset can exceed
the per-call phase advance. Cycle-relative phase is recoverable as
timestamp % cycle_steps.
§Examples
use axon_encoder::prelude::*;
let mut enc = PhaseEncoder::try_new(16, (0.0, 1.0))?;
let out = enc.encode(&[0.0, 1.0]);
assert_eq!(out.spikes.len(), 2);Implementations§
Source§impl PhaseEncoder
impl PhaseEncoder
Sourcepub fn try_new(
cycle_steps: u64,
range: (f32, f32),
) -> Result<Self, EncoderError>
pub fn try_new( cycle_steps: u64, range: (f32, f32), ) -> Result<Self, EncoderError>
Creates a new PhaseEncoder, returning an EncoderError for invalid configuration.
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 PhaseEncoder
impl Clone for PhaseEncoder
Source§fn clone(&self) -> PhaseEncoder
fn clone(&self) -> PhaseEncoder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more