Implement optimization for sobol sampler.
This significantly increases the sobol sampler's speed, especially for higher sample counts.
This commit is contained in:
parent
c9f24e2728
commit
ffc77ee1d5
|
@ -98,14 +98,12 @@ fn sobol_u32(dimension: u32, mut index: u32) -> u32 {
|
||||||
assert!((dimension as usize) < NUM_DIMENSIONS);
|
assert!((dimension as usize) < NUM_DIMENSIONS);
|
||||||
|
|
||||||
let mut result = 0;
|
let mut result = 0;
|
||||||
let mut i = (dimension as usize) * SIZE;
|
let mut i = dimension * SIZE as u32;
|
||||||
while index != 0 {
|
while index != 0 {
|
||||||
if (index & 1) != 0 {
|
let j = index.trailing_zeros();
|
||||||
result ^= MATRICES[i];
|
result ^= MATRICES[(i + j) as usize];
|
||||||
}
|
i += j + 1;
|
||||||
|
index >>= j + 1;
|
||||||
index >>= 1;
|
|
||||||
i += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
Loading…
Reference in New Issue
Block a user