A seedable Owen-scrambled Sobol sequence based on the paper Practical Hash-based Owen Scrambling by Brent Burley, with an improved hash from Building a Better LK Hash, and a larger set of direction vectors due to Kuo et al.
This crate is geared towards use in practical graphics applications, and as such has some limitations:
These are all trade-offs made for better performance and smaller code size.
This crate also currently targets SIMD execution on the x86-64 architecture, which is why it always calculates 4 dimensions at a time. It will still compile and run just fine on any architecture, but will be notably slower due to not utilizing SIMD.
Expanding this crate to be more general, both in application and target architectures, is a goal for the future. However, efficient execution for graphics applications will always be the top priority.
Basic usage is pretty straightforward. The first parameter of sample_4d()
is the index of the sample you want, and the second parameter is the index of the set (of four) dimensions you want. The parameters are zero-indexed, and the outputs are in the interval [0, 1).
```rust // Print the first sixteen dimensions of sample 1. for d in 0..4 { let [w, x, y, z] = sample_4d(0, d, 0); println!("{} {} {} {}", w, x, y, z); }
// Print the first sixteen dimensions of sample 2. for d in 0..4 { let [w, x, y, z] = sample_4d(1, d, 0); println!("{} {} {} {}", w, x, y, z); } ```
If all you want is a single standard Owen-scrambled Sobol sequence, then this is all you need.
For more advanced usage, including how to use the third parameter and how to get around the 256-dimension limit, see the crate documentation.
The main code in this project is licensed under either of
at your option.
The Sobol direction numbers under direction_numbers/
and some of the code in build.rs
(demarcated by comments) is adapted from work by Stephen Joe and Frances Y. Kuo, and is under the 3-clause BSD license.
See licenses/JOE_KUO.txt
for details.
Contributions are absolutely welcome! Please keep in mind that this crate aims to be:
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you will be licensed as above (MIT/Apache dual-license), without any additional terms or conditions.