Function risc0_zkp::core::ntt::bit_reverse
source · pub fn bit_reverse<T: Copy>(io: &mut [T])
Expand description
Bit-reverses the indices in an array of (1 << n) numbers. This permutes the values in the array so that a value which is previously in index i will now go in the index i’, given by reversing the bits of i.
§Example
For example, with the array given below of size n=4,
the indices are 0, 1, 2, 3
; bitwise, they’re 0, 01, 10, 11
.
Reversed, these give 0, 10, 01, 11
, permuting the second and third
values.
let mut some_values = [1, 2, 3, 4];
bit_reverse(&mut some_values);
assert_eq!(some_values, [1, 3, 2, 4]);