Alex Herbert created RNG-189:
--------------------------------
Summary: Add interface ArbitrarilyJumpableGenerator
Key: RNG-189
URL: https://issues.apache.org/jira/browse/RNG-189
Project: Commons RNG
Issue Type: New Feature
Components: client-api
Reporter: Alex Herbert
Add an interface to allow a generator to jump an arbitrary distance in its
output period.
This would be the equivalent of the interface from JDK 17+ {{java.util.random}}
package:
[RandomGenerator.ArbitrarilyJumpableGenerator (Javadoc JDK
25)|https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/random/RandomGenerator.ArbitrarilyJumpableGenerator.html]
The jump distance in that interface is specified as a double to avoid the use
of BigInteger for large jump distances. The JDK interfaces specify copy, jump
and copyAndJump. However Commons RNG does not support easy copying of a
generator to avoid common pitfalls of outputting the same sequence in multiple
threads via a copy.
The simplest API would be similar to the Commons RNG Jumpable interface with
the addition of a distance argument:
{code:java}
public interface ArbitrarilyJumpableUniformRandomProvider extends
UniformRandomProvider {
ArbitrarilyJumpableUniformRandomProvider jump(double distance);
default Stream<UniformRandomProvider> jumps(double distance) {
// ...
}
default Stream<UniformRandomProvider> jumps(long streamSize, double
distance) {
// ...
}
}
{code}
Note that the return value of a generator from the jump method makes this
interface incompatible with the JDK's which returns void. However the existing
Commons RNG jumping interfaces, which predate the JDK 17 release, are also
incompatible. Any future update with minimum Java 17 support will have to
address compatibility.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)