RealHypervector¶
Continuous real-valued hypervector for MAP operations.
vsax.representations.RealHypervector
¶
Bases: AbstractHypervector
Continuous real-valued hypervector for MAP operations.
RealHypervector uses real numbers to represent hypervectors. This is commonly used with Multiply-Add-Permute (MAP) operations where element-wise multiplication and averaging are the primary operations.
The normalization operation performs L2 normalization, scaling the vector to unit length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vec
|
ndarray
|
Real-valued JAX array representing the hypervector. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If vec is complex-valued. |
Example
import jax.numpy as jnp vec = jnp.array([1.0, 2.0, 3.0]) hv = RealHypervector(vec) normalized = hv.normalize() assert jnp.allclose(jnp.linalg.norm(normalized.vec), 1.0)
Source code in vsax/representations/real_hv.py
Functions¶
__init__(vec)
¶
Initialize real hypervector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vec
|
ndarray
|
Real-valued JAX array. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If vec is complex-valued. |
Source code in vsax/representations/real_hv.py
normalize()
¶
L2 normalization to unit length.
Returns:
| Type | Description |
|---|---|
RealHypervector
|
New RealHypervector with L2 norm equal to 1.0. |
Example
import jax.numpy as jnp vec = jnp.array([3.0, 4.0]) hv = RealHypervector(vec) normalized = hv.normalize() assert jnp.allclose(jnp.linalg.norm(normalized.vec), 1.0) assert jnp.allclose(normalized.vec, jnp.array([0.6, 0.8]))