Skip to main content

FieldVector

Struct FieldVector 

Source
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

Source

pub fn new(dims: usize) -> Self

Create a new zero-initialized vector.

Source

pub fn from_signals(signals: Vec<Signal>) -> Self

Create from raw Signal slice.

Source

pub fn dims(&self) -> usize

Get dimensions.

Source

pub fn get(&self, idx: usize) -> Signal

Get Signal at index.

Source

pub fn set(&mut self, idx: usize, signal: Signal)

Set Signal at index.

Source

pub fn get_current(&self, idx: usize) -> i32

Get the full effective value: polarity × magnitude × multiplier (±65,025).

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn add(&mut self, other: &FieldVector)

Add another vector (saturating at ±65,025).

Source

pub fn add_to_range(&mut self, signals: &[Signal], range: Range<usize>)

Add Signals to a range (saturating at ±65,025).

Source

pub fn set_range(&mut self, signals: &[Signal], range: Range<usize>)

Set Signals in a range.

Source

pub fn get_range(&self, range: Range<usize>) -> Vec<Signal>

Get Signals from a range.

Source

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).

Source

pub fn range_active(&self, range: Range<usize>, threshold: u64) -> bool

Check if range is active (energy above threshold).

Source

pub fn is_zero(&self) -> bool

Check if all signals are zero.

Source

pub fn non_zero_count(&self) -> usize

Count non-zero signals.

Source

pub fn max_magnitude(&self) -> u16

Get maximum effective magnitude.

Source

pub fn scale(&mut self, factor: u8)

Scale all values by factor (u8 where 255 = 1.0).

Source

pub fn as_slice(&self) -> &[Signal]

Get slice reference for direct access.

Source

pub fn as_mut_slice(&mut self) -> &mut [Signal]

Get mutable slice reference.

Trait Implementations§

Source§

impl Clone for FieldVector

Source§

fn clone(&self) -> FieldVector

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FieldVector

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FieldVector

Source§

fn default() -> Self

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.