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

Function wht_inplace

nodedb-codec/src/vector_quant/rabitq.rs:67–84  ·  view source on GitHub ↗

In-place Walsh-Hadamard Transform of a power-of-2 length slice. O(N log N) butterfly. Does not normalise by 1/√N (sign-only code does not require normalisation).

(buf: &mut [f32])

Source from the content-addressed store, hash-verified

65/// O(N log N) butterfly. Does not normalise by 1/√N (sign-only code
66/// does not require normalisation).
67fn wht_inplace(buf: &mut [f32]) {
68 let n = buf.len();
69 debug_assert!(n.is_power_of_two());
70 let mut step = 1usize;
71 while step < n {
72 let mut i = 0usize;
73 while i < n {
74 for j in i..i + step {
75 let a = buf[j];
76 let b = buf[j + step];
77 buf[j] = a + b;
78 buf[j + step] = a - b;
79 }
80 i += step * 2;
81 }
82 step *= 2;
83 }
84}
85
86// ── Sign-pack / unpack helpers ───────────────────────────────────────────────
87

Callers 2

apply_rotationMethod · 0.85
encode_innerMethod · 0.85

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected