pub struct MBAT {
pub data: Vec<i8>,
}Expand description
MBAT (Matrix Binding of Additive Terms) implementation using bipolar vectors.
Internally, an MBAT hypervector is stored as a Vec<i8> where each element is either -1 or +1.
Fields§
§data: Vec<i8>The underlying bipolar vector.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for MBAT
impl<'de> Deserialize<'de> for MBAT
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>,
Source§impl VSA for MBAT
impl VSA for MBAT
Source§fn generate(dim: usize, rng: &mut impl Rng) -> Self
fn generate(dim: usize, rng: &mut impl Rng) -> Self
Generate a random MBAT hypervector of the specified dimension.
Each element is randomly set to either +1 or -1 with equal probability.
§Arguments
dim- The dimensionality of the hypervector.rng- A mutable reference to a random number generator.
Source§fn bundle(
&self,
other: &Self,
tie_breaker: TieBreaker,
rng: &mut impl Rng,
) -> Self
fn bundle( &self, other: &Self, tie_breaker: TieBreaker, rng: &mut impl Rng, ) -> Self
Bundle (superpose) two MBAT hypervectors.
Bundling is performed element-wise by computing the sum of corresponding elements and then applying the sign function. In the event of a tie (i.e. when the sum is zero), the provided tie-breaker is used to determine the output.
§Arguments
other- The hypervector to bundle with.tie_breaker- The rule to resolve ties.rng- A mutable reference to a random number generator.
Source§fn bind(&self, other: &Self) -> Self
fn bind(&self, other: &Self) -> Self
Bind two MBAT hypervectors.
Binding is implemented as the element-wise product.
§Arguments
other- The hypervector to bind with.
Source§fn cosine_similarity(&self, other: &Self) -> f32
fn cosine_similarity(&self, other: &Self) -> f32
Compute the cosine similarity between two MBAT hypervectors.
For bipolar vectors, cosine similarity is computed as the dot product of the vectors divided by the dimension.
§Arguments
other- The hypervector to compare with.
Source§fn hamming_distance(&self, other: &Self) -> f32
fn hamming_distance(&self, other: &Self) -> f32
Compute the normalized Hamming distance between two MBAT hypervectors.
The normalized Hamming distance is defined as the fraction of positions where the two vectors differ.
§Arguments
other- The hypervector to compare with.
Source§fn to_vec(&self) -> Vec<f32>
fn to_vec(&self) -> Vec<f32>
Convert the MBAT hypervector into a plain vector of f32 values.
Each element is converted from i8 to f32.