fix(hdc): Correct HYPERVECTOR_U64_LEN to 157 for 10,000 bit storage

The previous value of 156 only provided 9,984 bits (156*64),
causing index out of bounds in bundle operations. Now correctly
allocates 157 words (10,048 bits) to fit all 10,000 bits.
This commit is contained in:
Claude 2025-12-28 04:14:47 +00:00
parent 6e40b06e51
commit e190c4789e

View file

@ -16,8 +16,8 @@ pub use memory::HdcMemory;
/// Number of bits in a hypervector (10,000)
pub const HYPERVECTOR_BITS: usize = 10_000;
/// Number of u64 words needed to store HYPERVECTOR_BITS (156 = ceil(10000/64))
pub const HYPERVECTOR_U64_LEN: usize = 156;
/// Number of u64 words needed to store HYPERVECTOR_BITS (157 = ceil(10000/64))
pub const HYPERVECTOR_U64_LEN: usize = 157;
#[cfg(test)]
mod tests {
@ -25,7 +25,7 @@ mod tests {
#[test]
fn test_constants() {
assert_eq!(HYPERVECTOR_U64_LEN, 156);
assert_eq!(HYPERVECTOR_U64_LEN, 157);
assert_eq!(HYPERVECTOR_BITS, 10_000);
assert!(HYPERVECTOR_U64_LEN * 64 >= HYPERVECTOR_BITS);
}