pub struct BHVec10240 {
pub bits: [u64; 160],
}Fields§
§bits: [u64; 160]Implementations§
Source§impl BHVec10240
impl BHVec10240
pub const DIMENSION: usize = 10240
pub const WORDS: usize = 160
Sourcepub fn new_seeded(seed: u64) -> Self
pub fn new_seeded(seed: u64) -> Self
Create a deterministic random hypervector from a seed
Sourcepub fn from_hvec(v: &HVec10240) -> Self
pub fn from_hvec(v: &HVec10240) -> Self
Convert HVec10240 (bit-packed u128) to BHVec10240 (bit-packed u64) This is just a layout conversion.
Sourcepub fn to_hvec(&self) -> HVec10240
pub fn to_hvec(&self) -> HVec10240
Convert BHVec10240 (bit-packed u64) to HVec10240 (bit-packed u128)
Sourcepub fn cosine_similarity(&self, other: &Self) -> f32
pub fn cosine_similarity(&self, other: &Self) -> f32
Cosine similarity (approximated for binary as 1 - Hamming/Dimension/2) Similarity = 1.0 - (HammingDistance / 5120.0)
Sourcepub fn bundle(vectors: &[&Self]) -> Self
pub fn bundle(vectors: &[&Self]) -> Self
Bundle multiple hypervectors using bit-sliced addition.
Algorithmic Optimization: Replaces the O(D * N) bit-by-bit loop with a transposed bit-sliced addition approach. By processing all 160 words of each vector contiguously, we eliminate 160x redundant memory loads, achieving a massive locality speedup with 100% safe Rust.
Majority rule: a bit is set when count >= N/2 + 1 (equivalent to count > N/2).
N=2 is a fast path (bitwise AND). Accumulation capacity matches HVec via
crate::hyperdim_ops::BUNDLE_MAX_PLANES (64 planes).
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Deserialize from bytes
Trait Implementations§
Source§impl Clone for BHVec10240
impl Clone for BHVec10240
Source§fn clone(&self) -> BHVec10240
fn clone(&self) -> BHVec10240
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more