pub struct HyperVec {
pub config: DimensionalConfig,
pub dimensions: BTreeMap<usize, Tryte>,
}Expand description
A hyperdimensional vector with configurable dimensional depth
Fields§
§config: DimensionalConfigConfiguration for this vector
dimensions: BTreeMap<usize, Tryte>Sparse storage: dimension index -> tryte value Only non-zero dimensions are stored
Implementations§
Source§impl HyperVec
impl HyperVec
Sourcepub fn new(config: DimensionalConfig) -> Self
pub fn new(config: DimensionalConfig) -> Self
Create a new zero vector
Sourcepub fn from_dense(config: DimensionalConfig, values: &[i64]) -> Self
pub fn from_dense(config: DimensionalConfig, values: &[i64]) -> Self
Create from dense representation
Sourcepub fn bundle(&self, other: &HyperVec) -> HyperVec
pub fn bundle(&self, other: &HyperVec) -> HyperVec
Bundle operation (⊕): Superposition via majority voting
Algebraic properties:
- Associative: (A ⊕ B) ⊕ C = A ⊕ (B ⊕ C)
- Commutative: A ⊕ B = B ⊕ A
- Preserves similarity to inputs
Sourcepub fn bind(&self, other: &HyperVec) -> HyperVec
pub fn bind(&self, other: &HyperVec) -> HyperVec
Bind operation (⊙): Composition via trit-wise multiplication
Algebraic properties:
- Self-inverse: A ⊙ A ≈ I (identity, up to sparsity)
- Distributes over bundle: A ⊙ (B ⊕ C) = (A ⊙ B) ⊕ (A ⊙ C)
- Creates quasi-orthogonal result
Sourcepub fn permute(&self, shift: usize) -> HyperVec
pub fn permute(&self, shift: usize) -> HyperVec
Permute operation (ρ): Cyclic index shift for sequence encoding
Algebraic properties:
- ρ^n(A) cycles through orthogonal representations
- Preserves sparsity and magnitude
- Enables positional encoding
Sourcepub fn inverse_permute(&self, shift: usize) -> HyperVec
pub fn inverse_permute(&self, shift: usize) -> HyperVec
Inverse permute (ρ⁻¹): Reverse cyclic shift
Sourcepub fn cosine(&self, other: &HyperVec) -> f64
pub fn cosine(&self, other: &HyperVec) -> f64
Cosine similarity: Normalized dot product
Returns value in [-1, 1]:
- 1.0: Identical vectors
- 0.0: Orthogonal vectors
- -1.0: Opposite vectors
Sourcepub fn thin(&self, target_nnz: usize) -> HyperVec
pub fn thin(&self, target_nnz: usize) -> HyperVec
Thin to target sparsity (Context-Dependent Thinning)
Reduces vector density while preserving signal structure
Sourcepub fn expand_precision(&mut self, dim: usize, new_depth: u8)
pub fn expand_precision(&mut self, dim: usize, new_depth: u8)
Expand precision at specific dimension (adaptive depth)
Sourcepub fn unpack(config: DimensionalConfig, bytes: &[u8]) -> Option<Self>
pub fn unpack(config: DimensionalConfig, bytes: &[u8]) -> Option<Self>
Unpack from bytes
Trait Implementations§
Source§impl<'de> Deserialize<'de> for HyperVec
impl<'de> Deserialize<'de> for HyperVec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for HyperVec
impl RefUnwindSafe for HyperVec
impl Send for HyperVec
impl Sync for HyperVec
impl Unpin for HyperVec
impl UnwindSafe for HyperVec
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more