pub struct FieldVector { /* private fields */ }Expand description
Signal-based vector for temporal fields.
Each element is a Signal (polarity: i8, magnitude: u8, multiplier: u8). Total size: 3 bytes per element.
Arithmetic operations use the full effective value: polarity × magnitude × multiplier
(range ±65,025). Results are decomposed back into (p, m, k) via Signal::from_current.
Implementations§
Source§impl FieldVector
impl FieldVector
Sourcepub fn from_signals(signals: Vec<Signal>) -> Self
pub fn from_signals(signals: Vec<Signal>) -> Self
Create from raw Signal slice.
Sourcepub fn get_current(&self, idx: usize) -> i32
pub fn get_current(&self, idx: usize) -> i32
Get the full effective value: polarity × magnitude × multiplier (±65,025).
Sourcepub fn set_current(&mut self, idx: usize, value: i32)
pub fn set_current(&mut self, idx: usize, value: i32)
Set from a signed i32 value using the full p×m×k range (±65,025).
Sourcepub fn get_i16(&self, idx: usize) -> i16
pub fn get_i16(&self, idx: usize) -> i16
Get as signed i16 (polarity × magnitude only, ignores multiplier).
Deprecated in favor of [get_current] which uses the full range.
Retained for backward compatibility with code that needs the narrow range.
Sourcepub fn set_i16(&mut self, idx: usize, value: i16)
pub fn set_i16(&mut self, idx: usize, value: i16)
Set from signed i16 value (clamped to ±255, multiplier=1).
Deprecated in favor of [set_current] which uses the full range.
Retained for backward compatibility.
Sourcepub fn decay(&mut self, retention: u8)
pub fn decay(&mut self, retention: u8)
Decay all values toward zero. retention: u8 where 255 = 1.0 (no decay), 230 ≈ 0.90
Decays the effective value (p×m×k), then re-encodes into Signal. This preserves the full dynamic range during decay.
Sourcepub fn add(&mut self, other: &FieldVector)
pub fn add(&mut self, other: &FieldVector)
Add another vector (saturating at ±65,025).
Sourcepub fn add_to_range(&mut self, signals: &[Signal], range: Range<usize>)
pub fn add_to_range(&mut self, signals: &[Signal], range: Range<usize>)
Add Signals to a range (saturating at ±65,025).
Sourcepub fn range_energy(&self, range: Range<usize>) -> u64
pub fn range_energy(&self, range: Range<usize>) -> u64
Compute energy (sum of squared effective magnitudes) in a range. Returns u64 to prevent overflow (max per element: 65025² ≈ 4.2B).
Sourcepub fn range_active(&self, range: Range<usize>, threshold: u64) -> bool
pub fn range_active(&self, range: Range<usize>, threshold: u64) -> bool
Check if range is active (energy above threshold).
Sourcepub fn non_zero_count(&self) -> usize
pub fn non_zero_count(&self) -> usize
Count non-zero signals.
Sourcepub fn max_magnitude(&self) -> u16
pub fn max_magnitude(&self) -> u16
Get maximum effective magnitude.
Sourcepub fn as_mut_slice(&mut self) -> &mut [Signal]
pub fn as_mut_slice(&mut self) -> &mut [Signal]
Get mutable slice reference.
Trait Implementations§
Source§impl Clone for FieldVector
impl Clone for FieldVector
Source§fn clone(&self) -> FieldVector
fn clone(&self) -> FieldVector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more