ComplexHypervector¶
Phase-based complex-valued hypervector for FHRR operations.
vsax.representations.ComplexHypervector
¶
Bases: AbstractHypervector
Phase-based complex-valued hypervector for FHRR.
ComplexHypervector uses complex numbers to represent hypervectors, where the phase component encodes information. This is particularly useful for Fourier Holographic Reduced Representation (FHRR) operations.
The normalization operation sets all elements to unit magnitude, preserving only the phase information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vec
|
ndarray
|
Complex-valued JAX array representing the hypervector. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If vec is not a complex array. |
Example
import jax.numpy as jnp vec = jnp.exp(1j * jnp.array([0.5, 1.0, 1.5])) hv = ComplexHypervector(vec) normalized = hv.normalize() assert jnp.allclose(jnp.abs(normalized.vec), 1.0)
Source code in vsax/representations/complex_hv.py
Attributes¶
phase
property
¶
Extract phase component of the complex hypervector.
Returns:
| Type | Description |
|---|---|
ndarray
|
Real-valued array of phase angles in radians, in the range [-π, π]. |
Example
import jax.numpy as jnp vec = jnp.exp(1j * jnp.array([0.0, jnp.pi/2, jnp.pi])) hv = ComplexHypervector(vec) phases = hv.phase assert phases.shape == vec.shape
magnitude
property
¶
Extract magnitude component of the complex hypervector.
Returns:
| Type | Description |
|---|---|
ndarray
|
Real-valued array of magnitudes. |
Example
import jax.numpy as jnp vec = jnp.array([3+4j, 5+12j]) hv = ComplexHypervector(vec) mags = hv.magnitude assert jnp.allclose(mags, jnp.array([5.0, 13.0]))
Functions¶
__init__(vec)
¶
Initialize complex hypervector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vec
|
ndarray
|
Complex-valued JAX array. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If vec is not complex-valued. |
Source code in vsax/representations/complex_hv.py
normalize()
¶
Normalize to unit magnitude (phase-only representation).
Returns:
| Type | Description |
|---|---|
ComplexHypervector
|
New ComplexHypervector with all elements having magnitude 1.0, |
ComplexHypervector
|
preserving the phase angles. |
Example
import jax.numpy as jnp vec = jnp.array([3+4j, 5+12j]) hv = ComplexHypervector(vec) normalized = hv.normalize() magnitudes = jnp.abs(normalized.vec) assert jnp.allclose(magnitudes, 1.0)