imneme / pcg-cpp

PCG — C++ Implementation
Apache License 2.0
735 stars 98 forks source link

Add sample for reversing the PCG family #77

Open adam4130 opened 2 years ago

adam4130 commented 2 years ago

We have an application with an adjoint Monte Carlo simulation that requires a reversible PRNG. We implemented a reversal of your PCG family and thought it useful to include in your samples.

imneme commented 2 years ago

You can also make PCG go backwards using advance. I just wanted to check that you were aware of this…

adam4130 commented 2 years ago

Yes we did initially use advance but ended up wanting equivalent cost forward and backward.

mfbalin commented 1 year ago

And also, when you want to go backward with advance, let's say n steps, the cost becomes O(64) instead of O(log n). I noticed that going backward was costlier than going forward when using pcg. I think multiplicative inverse trick like this should make it into the library somehow, would increase its usability.

ELoevbak commented 1 year ago

For the sake of context and motivation for this PR, I am posting a link to our preprint where we use this functionality: https://arxiv.org/abs/2302.02778