You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex D Herbert (Jira)" <ji...@apache.org> on 2019/09/23 19:16:00 UTC

[jira] [Created] (RNG-116) RandomSource to expose supported functionality and seed size

Alex D Herbert created RNG-116:
----------------------------------

             Summary: RandomSource to expose supported functionality and seed size
                 Key: RNG-116
                 URL: https://issues.apache.org/jira/browse/RNG-116
             Project: Commons RNG
          Issue Type: Improvement
          Components: simple
    Affects Versions: 1.3
            Reporter: Alex D Herbert
            Assignee: Alex D Herbert


h2. Interface support

The {{RandomSource}} can be used to created instances that may implement {{JumpableUniformRandomProvider}}. This requires casting the returned value from the {{create}} method. Add methods to expose the interfaces supported by the provider without instantiation.
{code:java}
public boolean isJumpable();
public boolean isLongJumpable();
{code}
This will allow:
{code:java}
RandomSource source = ...;
if (source.isJumpable()) {
    JumpableUniformRandomProvider rng =
        (JumpableUniformRandomProvider) RandomSource.create(source);
}
{code}
h2. Seed size

The internal components used to build the generators by RandomSource know the size of the seed required for the constructor. This can be exposed in a method:
{code:java}
public int getSeedByteSize();
{code}
This will allow:
{code:java}
RandomSource source = ...;
SecureRandom sr = new SecureRandom();
UniformRandomProvider rng = RandomSource.create(source,
    sr.generateSeed(source.getSeedByteSize()));
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)