Skip to main content

Hypervector

Trait Hypervector 

Source
pub trait Hypervector:
    Debug
    + Clone
    + Copy
    + PartialEq
    + Eq
    + Hash
    + Send
    + Sync
    + Serialize
    + for<'de> Deserialize<'de> {
    const DIMENSION: usize;
    const FORMAT_NAME: &'static str;

    // Required methods
    fn zero() -> Self;
    fn random() -> Self;
    fn new_seeded(seed: u64) -> Self;
    fn bundle(vectors: &[&Self]) -> Result<Self>;
    fn bind(&self, other: &Self) -> Self;
    fn cosine_similarity(&self, other: &Self) -> f32;
    fn hamming_distance(&self, other: &Self) -> u32;
    fn permute(&self, shift: usize) -> Self;
    fn to_bytes(&self) -> Vec<u8> ;
    fn from_bytes(bytes: &[u8]) -> Result<Self>;
}
Expand description

Common interface for hypervectors

Required Associated Constants§

Required Methods§

Source

fn zero() -> Self

Source

fn random() -> Self

Source

fn new_seeded(seed: u64) -> Self

Source

fn bundle(vectors: &[&Self]) -> Result<Self>

Source

fn bind(&self, other: &Self) -> Self

Source

fn cosine_similarity(&self, other: &Self) -> f32

Source

fn hamming_distance(&self, other: &Self) -> u32

Source

fn permute(&self, shift: usize) -> Self

Source

fn to_bytes(&self) -> Vec<u8>

Source

fn from_bytes(bytes: &[u8]) -> Result<Self>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Hypervector for BHVec10240

Source§

const DIMENSION: usize = 10240

Source§

const FORMAT_NAME: &'static str = "binary"

Source§

impl Hypervector for HVec10240

Source§

const DIMENSION: usize = 10240

Source§

const FORMAT_NAME: &'static str = "f32"