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])
| 65 | /// O(N log N) butterfly. Does not normalise by 1/√N (sign-only code |
| 66 | /// does not require normalisation). |
| 67 | fn 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 |
no test coverage detected