Expand description
§FHRR Module
This module implements the FHRR (Fourier Holographic Reduced Representation) VSA.
An FHRR hypervector is represented as a vector of angles (in radians). Each angle corresponds
to a unit‐complex number, i.e. e^(i*theta). The FHRR type implements the VSA trait.
In this implementation:
- Generation: Each angle is sampled uniformly from [0, 2π).
- Bundling: Two hypervectors are bundled by converting each angle into its complex representation, summing the complex numbers, and then taking the argument (phase) of the result. If the sum is nearly zero, a tie-breaker is used.
- Binding: Two hypervectors are bound by adding their angles element‑wise modulo 2π.
- Cosine Similarity: Defined as the average cosine of the differences between corresponding angles.
- Hamming Distance: Defined as
(1 - cosine_similarity) / 2. - Conversion to Vec: Returns the cosine (i.e. the real part) of each angle.
- Conversion from Vec: Constructs an FHRR hypervector from a vector of cosine values by taking the arccosine (with values clamped to ([-1, 1])) and reducing modulo 2π.
Structs§
- FHRR
- An FHRR hypervector is represented as a vector of angles (in radians).
Each angle corresponds to a unit‐complex number
e^(i*theta).