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

Function random_vec

nodedb-codec/src/vector_quant/rabitq.rs:377–386  ·  view source on GitHub ↗
(seed: u64, dim: usize)

Source from the content-addressed store, hash-verified

375 use super::*;
376
377 fn random_vec(seed: u64, dim: usize) -> Vec<f32> {
378 let mut s = seed | 1;
379 (0..dim)
380 .map(|_| {
381 let v = xorshift64(&mut s);
382 // Map to [-1, 1]
383 (v as f32 / u64::MAX as f32) * 2.0 - 1.0
384 })
385 .collect()
386 }
387
388 #[test]
389 fn to_bytes_from_bytes_roundtrip() {

Calls 2

xorshift64Function · 0.85
collectMethod · 0.80