You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gilles Sadowski <gi...@gmail.com> on 2019/03/25 13:13:24 UTC
Re: [commons-rng] 01/04: RNG-82: Add XorShift1024StarPhi generator
Hi.
Nit-pick: Order of constructor arguments (see below).
Le lun. 25 mars 2019 à 13:08, <ah...@apache.org> a écrit :
>
> This is an automated email from the ASF dual-hosted git repository.
>
> aherbert pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/commons-rng.git
>
> commit cb6423ccfc742b209df5b9b181140bf9c15d6314
> Author: Alex Herbert <ah...@apache.org>
> AuthorDate: Wed Mar 6 22:06:27 2019 +0000
>
> RNG-82: Add XorShift1024StarPhi generator
> ---
> .../rng/core/source64/XorShift1024Star.java | 26 ++++++++++---
> .../rng/core/source64/XorShift1024StarPhi.java | 44 ++++++++++++++++++++++
> .../org/apache/commons/rng/core/ProvidersList.java | 3 +-
> ...4StarTest.java => XorShift1024StarPhiTest.java} | 37 ++++++++++++------
> .../rng/core/source64/XorShift1024StarTest.java | 11 ++++++
> .../apache/commons/rng/simple/RandomSource.java | 8 ++++
> .../rng/simple/internal/ProviderBuilder.java | 4 ++
> .../apache/commons/rng/simple/ProvidersList.java | 1 +
> 8 files changed, 116 insertions(+), 18 deletions(-)
>
> diff --git a/commons-rng-core/src/main/java/org/apache/commons/rng/core/source64/XorShift1024Star.java b/commons-rng-core/src/main/java/org/apache/commons/rng/core/source64/XorShift1024Star.java
> index 1d48896..c3557d0 100644
> --- a/commons-rng-core/src/main/java/org/apache/commons/rng/core/source64/XorShift1024Star.java
> +++ b/commons-rng-core/src/main/java/org/apache/commons/rng/core/source64/XorShift1024Star.java
> @@ -21,11 +21,9 @@ import java.util.Arrays;
> import org.apache.commons.rng.core.util.NumberFactory;
>
> /**
> - * A fast RNG.
> - *
> - * @see <a href="http://xorshift.di.unimi.it/xorshift1024star.c">
> - * Original source code</a>
> + * A fast RNG implementing the {@code XorShift1024*} algorithm.
> *
> + * @see <a href="http://xorshift.di.unimi.it/xorshift1024star.c">Original source code</a>
> * @see <a href="https://en.wikipedia.org/wiki/Xorshift">Xorshift (Wikipedia)</a>
> * @since 1.0
> */
> @@ -34,6 +32,8 @@ public class XorShift1024Star extends LongProvider {
> private static final int SEED_SIZE = 16;
> /** State. */
> private final long[] state = new long[SEED_SIZE];
> + /** The multiplier for the XorShift1024 algorithm. */
> + private final long multiplier;
> /** Index in "state" array. */
> private int index;
>
> @@ -44,8 +44,24 @@ public class XorShift1024Star extends LongProvider {
> * If the length is larger than 16, only the first 16 elements will
> * be used; if smaller, the remaining elements will be automatically
> * set.
> + * A seed containing all zeros will create a non-functional generator.
> */
> public XorShift1024Star(long[] seed) {
> + this(1181783497276652981L, seed);
> + }
> +
> + /**
> + * Creates a new instance.
> + *
> + * @param multiplier The multiplier for the XorShift1024 algorithm.
> + * @param seed Initial seed.
> + * If the length is larger than 16, only the first 16 elements will
> + * be used; if smaller, the remaining elements will be automatically
> + * set.
> + * A seed containing all zeros will create a non-functional generator.
> + */
> + protected XorShift1024Star(long multiplier, long[] seed) {
> + this.multiplier = multiplier;
> setSeedInternal(seed);
> }
Wouldn't it be more consistent to put the seed first?
[Cf. "TwoCmres" constructor.]
Gilles
> [...]
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [commons-rng] 01/04: RNG-82: Add XorShift1024StarPhi generator
Posted by Alex Herbert <al...@gmail.com>.
On 25/03/2019 13:13, Gilles Sadowski wrote:
> Hi.
>
> Nit-pick: Order of constructor arguments (see below).
> Wouldn't it be more consistent to put the seed first?
> [Cf. "TwoCmres" constructor.]
Yes. Sorry I will fix master.
Alex
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org