[
https://issues.apache.org/jira/browse/RNG-180?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Alex Herbert updated RNG-180:
-----------------------------
Component/s: (was: core)
> New SplittableUniformRandomProvider interface
> ---------------------------------------------
>
> Key: RNG-180
> URL: https://issues.apache.org/jira/browse/RNG-180
> Project: Commons RNG
> Issue Type: New Feature
> Components: client-api
> Affects Versions: 1.5
> Reporter: Alex Herbert
> Assignee: Alex Herbert
> Priority: Major
> Fix For: 1.5
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> The minimum java version for RNG is now 1.8. Stream support has been added
> for the UniformRandomProvider and Sampler interfaces. These all operate using
> a sequential stream. To use a parallel stream requires the concept of
> splitting the source of randomness.
> I propose to add a Splittable interface. This can be modelled on the
> interface in the JDK 17 random package [SplittableGenerator
> (javadoc)|https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/random/RandomGenerator.SplittableGenerator.html]:
> {code:java}
> public interface SplittableUniformRandomProvider
> extends UniformRandomProvider {
> SplittableUniformRandomProvider split();
> SplittableUniformRandomProvider split(SplittableUniformRandomProvider
> source);
> Stream<SplittableUniformRandomProvider> splits();
> Stream<SplittableUniformRandomProvider>
> splits(SplittableUniformRandomProvider source);
> Stream<SplittableUniformRandomProvider> splits(long streamSize);
> Stream<SplittableUniformRandomProvider> splits(long streamSize,
> SplittableUniformRandomProvider source);
> {code}
> The JDK interface has both a split and split(source) method, and similar for
> the stream created by repeat splitting. The source is to provide the random
> bits to initialise the new instances. In most cases this will just be the
> current instance. However it provides a means to provide a small state
> splittable generator for the random source of bits and use a larger state
> generator to provide new instances from those bits, or vice versa. This
> allows more flexibility to control the source of random bits, and the
> instance type of the new split generators.
> Note: It is possible to implement the entire interface using default methods
> except:
> {code:java}
> SplittableUniformRandomProvider split(SplittableUniformRandomProvider
> source);
> {code}
> The stream can be created by recursively splitting the current instance via a
> custom Spliterator<SplittableUniformRandomProvider>.
> Also note that the stream methods in UniformRandomProvider can be overridden
> to support parallel streams. This requires for example a custom
> Spliterator.OfInt to split the generator for parallel generation.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)