MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / hamming_fast_matches_simple

Function hamming_fast_matches_simple

nodedb-vector/src/quantize/binary.rs:121–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

119
120 #[test]
121 fn hamming_fast_matches_simple() {
122 // 128 dimensions = 16 bytes = 2 u64 chunks.
123 let a_vec: Vec<f32> = (0..128)
124 .map(|i| if i % 3 == 0 { 1.0 } else { -1.0 })
125 .collect();
126 let b_vec: Vec<f32> = (0..128)
127 .map(|i| if i % 5 == 0 { 1.0 } else { -1.0 })
128 .collect();
129 let a = encode(&a_vec);
130 let b = encode(&b_vec);
131
132 let slow = hamming_distance(&a, &b);
133 let fast = hamming_distance_fast(&a, &b);
134 assert_eq!(slow, fast);
135 }
136
137 #[test]
138 fn high_dimensional_encoding() {

Callers

nothing calls this directly

Calls 4

hamming_distance_fastFunction · 0.85
collectMethod · 0.80
encodeFunction · 0.70
hamming_distanceFunction · 0.70

Tested by

no test coverage detected