Return-Path:
X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io
Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io
Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183])
by cust-asf2.ponee.io (Postfix) with ESMTP id EFEBB200B6A
for ; Mon, 8 Aug 2016 00:51:38 +0200 (CEST)
Received: by cust-asf.ponee.io (Postfix)
id EE6BD160AB1; Sun, 7 Aug 2016 22:51:38 +0000 (UTC)
Delivered-To: archive-asf-public@cust-asf.ponee.io
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by cust-asf.ponee.io (Postfix) with SMTP id A36E0160AB4
for ; Mon, 8 Aug 2016 00:51:36 +0200 (CEST)
Received: (qmail 33435 invoked by uid 500); 7 Aug 2016 22:51:28 -0000
Mailing-List: contact commits-help@commons.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@commons.apache.org
Delivered-To: mailing list commits@commons.apache.org
Received: (qmail 31898 invoked by uid 99); 7 Aug 2016 22:51:27 -0000
Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23)
by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Aug 2016 22:51:27 +0000
Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33)
id 34B4BEEE19; Sun, 7 Aug 2016 22:51:27 +0000 (UTC)
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: erans@apache.org
To: commits@commons.apache.org
Date: Sun, 07 Aug 2016 22:52:00 -0000
Message-Id:
In-Reply-To: <5f23c358c2c84946b137272f3ba73400@git.apache.org>
References: <5f23c358c2c84946b137272f3ba73400@git.apache.org>
X-Mailer: ASF-Git Admin Mailer
Subject: [35/39] commons-rng git commit: Initial commit.
archived-at: Sun, 07 Aug 2016 22:51:39 -0000
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/source64/XorShift1024Star.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source64/XorShift1024Star.java b/src/main/java/org/apache/commons/rng/internal/source64/XorShift1024Star.java
new file mode 100644
index 0000000..2e20f2b
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/source64/XorShift1024Star.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.rng.internal.source64;
+
+import java.util.Arrays;
+import org.apache.commons.rng.internal.util.NumberFactory;
+
+/**
+ * A fast RNG.
+ *
+ * @see
+ * Original source code
+ *
+ * @since 4.0
+ */
+public class XorShift1024Star extends LongProvider {
+ /** Size of the state vector. */
+ private static final int SEED_SIZE = 16;
+ /** State. */
+ private final long[] state = new long[SEED_SIZE];
+ /** Index in "state" array. */
+ private int index;
+
+ /**
+ * Creates a new instance.
+ *
+ * @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.
+ */
+ public XorShift1024Star(long[] seed) {
+ setSeedInternal(seed);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected byte[] getStateInternal() {
+ final long[] s = Arrays.copyOf(state, SEED_SIZE + 1);
+ s[SEED_SIZE] = index;
+
+ return NumberFactory.makeByteArray(s);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void setStateInternal(byte[] s) {
+ checkStateSize(s, (SEED_SIZE + 1) * 8);
+
+ final long[] tmp = NumberFactory.makeLongArray(s);
+
+ System.arraycopy(tmp, 0, state, 0, SEED_SIZE);
+ index = (int) tmp[SEED_SIZE];
+ }
+
+ /**
+ * Seeds the RNG.
+ *
+ * @param seed Seed.
+ */
+ private void setSeedInternal(long[] seed) {
+ // Reset the whole state of this RNG (i.e. "state" and "index").
+ // Seeding procedure is not part of the reference code.
+
+ System.arraycopy(seed, 0, state, 0, Math.min(seed.length, state.length));
+
+ if (seed.length < SEED_SIZE) {
+ for (int i = seed.length; i < SEED_SIZE; i++) {
+ state[i] = 26021969L * i;
+ }
+ for (int i = SEED_SIZE - 1; i > seed.length; i--) {
+ state[i] ^= state[SEED_SIZE - i - 1];
+ }
+
+ state[seed.length] = 0x8000000000000000L; // Ensuring non-zero initial array.
+ }
+
+ index = 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public long next() {
+ final long s0 = state[index];
+ long s1 = state[index = (index + 1) & 15];
+ s1 ^= s1 << 31; // a
+ state[index] = s1 ^ s0 ^ (s1 >>> 11) ^ (s0 >>> 30); // b,c
+ return state[index] * 1181783497276652981L;
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/source64/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source64/package-info.java b/src/main/java/org/apache/commons/rng/internal/source64/package-info.java
new file mode 100644
index 0000000..41639f3
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/source64/package-info.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ * Concrete algorithms for {@code long}-based sources of randomness
+ *
+ *
+ *
+ * For internal use only: Direct access to classes in this package
+ * is discouraged, as they could be modified without notice.
+ *
+ *
+ * Notes for developers
+ *
+ *
+ * -
+ * A source of randomness must inherit from
+ * {@link org.apache.commons.rng.internal.source64.LongProvider}
+ *
+ * -
+ * The "provider" must specify one way for setting the seed.
+ * For a given seed, the generated sequence must always be the same.
+ *
+ * -
+ * The "provider" must implement methods {@code getStateInternal} and
+ * {@code setStateInternal} in order to save and restore the state of an
+ * instance (cf. {@link org.apache.commons.rng.internal.BaseProvider}).
+ *
+ * -
+ * When a new class is implemented here, user-access to it must be provided
+ * through associated {@link org.apache.commons.rng.RandomSource
+ * factory methods}.
+ *
+ *
+ */
+
+package org.apache.commons.rng.internal.source64;
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/Int2Long.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/Int2Long.java b/src/main/java/org/apache/commons/rng/internal/util/Int2Long.java
new file mode 100644
index 0000000..5e71dd5
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/Int2Long.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+/**
+ * Converts a {@code Integer} to an {@code Long}.
+ *
+ * @since 4.0
+ */
+public class Int2Long implements SeedConverter {
+ /** {@inheritDoc} */
+ @Override
+ public Long convert(Integer seed) {
+ final int s = seed;
+ return NumberFactory.makeLong(s, ~s);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/IntArray2Int.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/IntArray2Int.java b/src/main/java/org/apache/commons/rng/internal/util/IntArray2Int.java
new file mode 100644
index 0000000..805d10d
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/IntArray2Int.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+/**
+ * Creates a single value by "xor" of all the values in the input array.
+ *
+ * @since 4.0
+ */
+public class IntArray2Int implements SeedConverter {
+ /** {@inheritDoc} */
+ @Override
+ public Integer convert(int[] seed) {
+ int out = 0;
+ for (int i = 0; i < seed.length; i++) {
+ out ^= seed[i];
+ }
+
+ return out;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/IntArray2LongArray.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/IntArray2LongArray.java b/src/main/java/org/apache/commons/rng/internal/util/IntArray2LongArray.java
new file mode 100644
index 0000000..f504ed8
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/IntArray2LongArray.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+/**
+ * Creates a {@code long[]} from an {@code int[]}.
+ *
+ * @since 4.0
+ */
+public class IntArray2LongArray implements SeedConverter {
+ /** {@inheritDoc} */
+ @Override
+ public long[] convert(int[] seed) {
+ final int outSize = (seed.length + 1) / 2;
+ final long[] out = new long[outSize];
+ for (int i = 0; i < outSize; i++) {
+ final int lo = seed[i];
+ final int hi = outSize + i < seed.length ? seed[outSize + i] : 0;
+ out[i] = NumberFactory.makeLong(hi, lo) ;
+ }
+
+ return out;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/Long2Int.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/Long2Int.java b/src/main/java/org/apache/commons/rng/internal/util/Long2Int.java
new file mode 100644
index 0000000..91b336c
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/Long2Int.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+/**
+ * Converts a {@code Long} to an {@code Integer}.
+ *
+ * @since 4.0
+ */
+public class Long2Int implements SeedConverter {
+ /** {@inheritDoc} */
+ @Override
+ public Integer convert(Long seed) {
+ return NumberFactory.makeInt(seed);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/Long2IntArray.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/Long2IntArray.java b/src/main/java/org/apache/commons/rng/internal/util/Long2IntArray.java
new file mode 100644
index 0000000..59c9d94
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/Long2IntArray.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+import org.apache.commons.rng.internal.source64.SplitMix64;
+
+/**
+ * Uses a {@code long} value to seed a {@link SplitMix64} RNG and
+ * create a {@code int[]} with the requested number of random
+ * values.
+ *
+ * @since 4.0
+ */
+public class Long2IntArray implements SeedConverter {
+ /** Size of the output array. */
+ private final int size;
+
+ /**
+ * @param size Size of the output array.
+ */
+ public Long2IntArray(int size) {
+ this.size = size;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int[] convert(Long seed) {
+ return SeedFactory.createIntArray(size, new SplitMix64(seed));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "(size=" + size + ")";
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/Long2LongArray.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/Long2LongArray.java b/src/main/java/org/apache/commons/rng/internal/util/Long2LongArray.java
new file mode 100644
index 0000000..1e1a33c
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/Long2LongArray.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+import org.apache.commons.rng.internal.source64.SplitMix64;
+
+/**
+ * Uses a {@code Long} value to seed a {@link SplitMix64} RNG and
+ * create a {@code long[]} with the requested number of random
+ * values.
+ *
+ * @since 4.0
+ */
+public class Long2LongArray implements SeedConverter {
+ /** Size of the output array. */
+ private final int size;
+
+ /**
+ * @param size Size of the output array.
+ */
+ public Long2LongArray(int size) {
+ this.size = size;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public long[] convert(Long seed) {
+ final long[] out = new long[size];
+ final SplitMix64 rng = new SplitMix64(seed);
+ for (int i = 0; i < size; i++) {
+ out[i] = rng.nextLong();
+ }
+
+ return out;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "(size: " + size + ")";
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/LongArray2IntArray.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/LongArray2IntArray.java b/src/main/java/org/apache/commons/rng/internal/util/LongArray2IntArray.java
new file mode 100644
index 0000000..6902177
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/LongArray2IntArray.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+/**
+ * Creates an {@code int[]} from a {@code long[]}.
+ *
+ * @since 4.0
+ */
+public class LongArray2IntArray implements SeedConverter {
+ /** {@inheritDoc} */
+ @Override
+ public int[] convert(long[] seed) {
+ final int[] out = new int[seed.length * 2];
+ for (int i = 0; i < seed.length; i++) {
+ final long current = seed[i];
+ out[i] = NumberFactory.extractLo(current);
+ out[seed.length + i] = NumberFactory.extractHi(current);
+ }
+
+ return out;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/LongArray2Long.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/LongArray2Long.java b/src/main/java/org/apache/commons/rng/internal/util/LongArray2Long.java
new file mode 100644
index 0000000..c0b4987
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/LongArray2Long.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+/**
+ * Creates a single value by "xor" of all the values in the input array.
+ *
+ * @since 4.0
+ */
+public class LongArray2Long implements SeedConverter {
+ /** {@inheritDoc} */
+ @Override
+ public Long convert(long[] seed) {
+ long out = 0;
+ for (int i = 0; i < seed.length; i++) {
+ out ^= seed[i];
+ }
+
+ return out;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/LongMixInt.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/LongMixInt.java b/src/main/java/org/apache/commons/rng/internal/util/LongMixInt.java
new file mode 100644
index 0000000..31679c0
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/LongMixInt.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+import org.apache.commons.rng.internal.source64.SplitMix64;
+
+/**
+ * Uses a {@code long} value to seed a {@link SplitMix64} RNG and
+ * create an {@code int[]} with the requested number of random
+ * values.
+ *
+ * @since 4.0
+ */
+public class LongMixInt implements SeedConverter {
+ /** Size of the output array. */
+ private final int size;
+
+ /**
+ * @param size Size of the output array.
+ */
+ public LongMixInt(int size) {
+ this.size = size;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int[] convert(Long seed) {
+ return SeedFactory.createIntArray(size, new SplitMix64(seed));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "(size=" + size + ")";
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/LongMixLong.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/LongMixLong.java b/src/main/java/org/apache/commons/rng/internal/util/LongMixLong.java
new file mode 100644
index 0000000..95568c0
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/LongMixLong.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+import org.apache.commons.rng.internal.source64.SplitMix64;
+
+/**
+ * Uses a {@code long} value to seed a {@link SplitMix64} RNG and
+ * create a {@code long[]} with the requested number of random
+ * values.
+ *
+ * @since 4.0
+ */
+public class LongMixLong implements SeedConverter {
+ /** Size of the output array. */
+ private final int size;
+
+ /**
+ * @param size Size of the output array.
+ */
+ public LongMixLong(int size) {
+ this.size = size;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public long[] convert(Long seed) {
+ final long[] out = new long[size];
+ final SplitMix64 rng = new SplitMix64(seed);
+ for (int i = 0; i < size; i++) {
+ out[i] = rng.nextLong();
+ }
+
+ return out;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "(size: " + size + ")";
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/NoOpConverter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/NoOpConverter.java b/src/main/java/org/apache/commons/rng/internal/util/NoOpConverter.java
new file mode 100644
index 0000000..1979fa6
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/NoOpConverter.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+
+/**
+ * Dummy converter that simply passes on its input.
+ * It can be useful to avoid "unchecked" compiler warnings.
+ *
+ * @param Seed type.
+ *
+ * @since 4.0
+ */
+public class NoOpConverter implements SeedConverter {
+ /** {@inheritDoc} */
+ @Override
+ public SEED convert(SEED seed) {
+ return seed;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return "Pass-through";
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java b/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
new file mode 100644
index 0000000..b350c63
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
@@ -0,0 +1,331 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+import java.util.Arrays;
+
+/**
+ * Utility for creating number types from one or two {@code int} values
+ * or one {@code long} value, or a sequence of bytes.
+ */
+public final class NumberFactory {
+ /** See {@link #makeDouble(long)} */
+ private static final long DOUBLE_HIGH_BITS = 0x3ffL << 52;
+ /** See {@link #makeFloat(int)} */
+ private static final float FLOAT_MULTIPLIER = 0x1.0p-23f;
+ /** See {@link #makeDouble(int, int)} */
+ private static final double DOUBLE_MULTIPLIER = 0x1.0p-52d;
+ /** Lowest byte mask. */
+ private static final long LONG_LOWEST_BYTE_MASK = 0xffL;
+ /** Number of bytes in a {@code long} */
+ private static final int LONG_SIZE = 8;
+ /** Lowest byte mask. */
+ private static final int INT_LOWEST_BYTE_MASK = 0xff;
+ /** Number of bytes in a {@code int} */
+ private static final int INT_SIZE = 4;
+
+ /**
+ * Class contains only static methods.
+ */
+ private NumberFactory() {}
+
+ /**
+ * @param v Number.
+ * @return a boolean.
+ */
+ public static boolean makeBoolean(int v) {
+ return (v >>> 31) != 0;
+ }
+
+ /**
+ * @param v Number.
+ * @return a boolean.
+ */
+ public static boolean makeBoolean(long v) {
+ return (v >>> 63) != 0;
+ }
+
+ /**
+ * @param v Number.
+ * @return a {@code double} value in the interval {@code [0, 1]}.
+ */
+ public static double makeDouble(long v) {
+ // http://xorshift.di.unimi.it
+ return Double.longBitsToDouble(DOUBLE_HIGH_BITS | v >>> 12) - 1d;
+ }
+
+ /**
+ * @param v Number (high order bits).
+ * @param w Number (low order bits).
+ * @return a {@code double} value in the interval {@code [0, 1]}.
+ */
+ public static double makeDouble(int v,
+ int w) {
+ final long high = ((long) (v >>> 6)) << 26;
+ final int low = w >>> 6;
+ return (high | low) * DOUBLE_MULTIPLIER;
+ }
+
+ /**
+ * @param v Number.
+ * @return a {@code float} value in the interval {@code [0, 1]}.
+ */
+ public static float makeFloat(int v) {
+ return (v >>> 9) * FLOAT_MULTIPLIER;
+ }
+
+ /**
+ * @param v Number (high order bits).
+ * @param w Number (low order bits).
+ * @return a {@code long} value.
+ */
+ public static long makeLong(int v,
+ int w) {
+ return (((long) v) << 32) | (w & 0xffffffffL);
+ }
+
+ /**
+ * Creates an {@code int} from a {@code long}.
+ *
+ * @param v Number.
+ * @return an {@code int} value made from the "xor" of the
+ * {@link #extractHi(long) high order bits} and
+ * {@link #extractLo(long) low order bits} of {@code v}.
+ */
+ public static int makeInt(long v) {
+ return extractHi(v) ^ extractLo(v);
+ }
+
+ /**
+ * Creates an {@code int} from a {@code long}, using the high order bits.
+ *
+ * The returned value is such that if
+ *
+ * vL = extractLo(v);
+ * vH = extractHi(v);
+ *
+ * then {@code v} is equal to {@link #makeLong(int,int) makeLong(vH, vL)}.
+ *
+ *
+ * @param v Number.
+ * @return an {@code int} value made from the most significant bits
+ * of {@code v}.
+ */
+ public static int extractHi(long v) {
+ return (int) (v >>> 32);
+ }
+
+ /**
+ * Creates an {@code int} from a {@code long}, using the low order bits.
+ *
+ * The returned value is such that if
+ *
+ * vL = extractLo(v);
+ * vH = extractHi(v);
+ *
+ * then {@code v} is equal to {@link #makeLong(int,int) makeLong(vH, vL)}.
+ *
+ *
+ * @param v Number.
+ * @return an {@code int} value made from the least significant bits
+ * of {@code v}.
+ */
+ public static int extractLo(long v) {
+ return (int) v;
+ }
+
+ /**
+ * Splits a {@code long} into 8 bytes.
+ *
+ * @param v Value.
+ * @return the bytes that compose the given value (least-significant
+ * byte first).
+ */
+ public static byte[] makeByteArray(long v) {
+ final byte[] b = new byte[LONG_SIZE];
+
+ for (int i = 0; i < LONG_SIZE; i++) {
+ final int shift = i * 8;
+ b[i] = (byte) ((v >>> shift) & LONG_LOWEST_BYTE_MASK);
+ }
+
+ return b;
+ }
+
+ /**
+ * Creates a {@code long} from 8 bytes.
+ *
+ * @param input Input.
+ * @return the value that correspond to the given bytes assuming
+ * that the is ordered in increasing byte significance (i.e. the
+ * first byte in the array is the least-siginficant).
+ * @throws IllegalArgumentException if {@code input.length != 8}.
+ */
+ public static long makeLong(byte[] input) {
+ checkSize(LONG_SIZE, input.length);
+
+ long v = 0;
+ for (int i = 0; i < LONG_SIZE; i++) {
+ final int shift = i * 8;
+ v |= (((long) input[i]) & LONG_LOWEST_BYTE_MASK) << shift;
+ }
+
+ return v;
+ }
+
+ /**
+ * Splits an array of {@code long} values into a sequence of bytes.
+ * This method calls {@link #makeByteArray(long)} for each element of
+ * the {@code input}.
+ *
+ * @param input Input.
+ * @return an array of bytes.
+ */
+ public static byte[] makeByteArray(long[] input) {
+ final int size = input.length * LONG_SIZE;
+ final byte[] b = new byte[size];
+
+ for (int i = 0; i < input.length; i++) {
+ final byte[] current = makeByteArray(input[i]);
+ System.arraycopy(current, 0, b, i * LONG_SIZE, LONG_SIZE);
+ }
+
+ return b;
+ }
+
+ /**
+ * Creates an array of {@code long} values from a sequence of bytes.
+ * This method calls {@link #makeLong(byte[])} for each subsequence
+ * of 8 bytes.
+ *
+ * @param input Input.
+ * @return an array of {@code long}.
+ * @throws IllegalArgumentException if {@code input.length} is not
+ * a multiple of 8.
+ */
+ public static long[] makeLongArray(byte[] input) {
+ final int size = input.length;
+ final int num = size / LONG_SIZE;
+ checkSize(num * LONG_SIZE, size);
+
+ final long[] output = new long[num];
+ for (int i = 0; i < num; i++) {
+ final int from = i * LONG_SIZE;
+ final byte[] current = Arrays.copyOfRange(input, from, from + LONG_SIZE);
+ output[i] = makeLong(current);
+ }
+
+ return output;
+ }
+
+ /**
+ * Splits an {@code int} into 4 bytes.
+ *
+ * @param v Value.
+ * @return the bytes that compose the given value (least-significant
+ * byte first).
+ */
+ public static byte[] makeByteArray(int v) {
+ final byte[] b = new byte[INT_SIZE];
+
+ for (int i = 0; i < INT_SIZE; i++) {
+ final int shift = i * 8;
+ b[i] = (byte) ((v >>> shift) & INT_LOWEST_BYTE_MASK);
+ }
+
+ return b;
+ }
+
+ /**
+ * Creates an {@code int} from 4 bytes.
+ *
+ * @param input Input.
+ * @return the value that correspond to the given bytes assuming
+ * that the is ordered in increasing byte significance (i.e. the
+ * first byte in the array is the least-siginficant).
+ * @throws IllegalArgumentException if {@code input.length != 4}.
+ */
+ public static int makeInt(byte[] input) {
+ checkSize(INT_SIZE, input.length);
+
+ int v = 0;
+ for (int i = 0; i < INT_SIZE; i++) {
+ final int shift = i * 8;
+ v |= (((int) input[i]) & INT_LOWEST_BYTE_MASK) << shift;
+ }
+
+ return v;
+ }
+
+ /**
+ * Splits an array of {@code int} values into a sequence of bytes.
+ * This method calls {@link #makeByteArray(int)} for each element of
+ * the {@code input}.
+ *
+ * @param input Input.
+ * @return an array of bytes.
+ */
+ public static byte[] makeByteArray(int[] input) {
+ final int size = input.length * INT_SIZE;
+ final byte[] b = new byte[size];
+
+ for (int i = 0; i < input.length; i++) {
+ final byte[] current = makeByteArray(input[i]);
+ System.arraycopy(current, 0, b, i * INT_SIZE, INT_SIZE);
+ }
+
+ return b;
+ }
+
+ /**
+ * Creates an array of {@code int} values from a sequence of bytes.
+ * This method calls {@link #makeInt(byte[])} for each subsequence
+ * of 4 bytes.
+ *
+ * @param input Input. Length must be a multiple of 4.
+ * @return an array of {@code int}.
+ * @throws IllegalArgumentException if {@code input.length} is not
+ * a multiple of 4.
+ */
+ public static int[] makeIntArray(byte[] input) {
+ final int size = input.length;
+ final int num = size / INT_SIZE;
+ checkSize(num * INT_SIZE, size);
+
+ final int[] output = new int[num];
+ for (int i = 0; i < num; i++) {
+ final int from = i * INT_SIZE;
+ final byte[] current = Arrays.copyOfRange(input, from, from + INT_SIZE);
+ output[i] = makeInt(current);
+ }
+
+ return output;
+ }
+
+ /**
+ * @param expected Expected value.
+ * @param actual Actual value.
+ * @throw IllegalArgumentException if {@code expected != actual}.
+ */
+ private static void checkSize(int expected,
+ int actual) {
+ if (expected != actual) {
+ throw new IllegalArgumentException("Array size: Expected " + expected +
+ " but was " + actual);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/SeedConverter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/SeedConverter.java b/src/main/java/org/apache/commons/rng/internal/util/SeedConverter.java
new file mode 100644
index 0000000..e884b16
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/SeedConverter.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+/**
+ * Seed converter.
+ *
+ * @param Input seed type.
+ * @param Output seed type.
+ *
+ * @since 4.0
+ */
+public interface SeedConverter {
+ /**
+ * Converts seed from input type to output type.
+ *
+ * @param seed Original seed value.
+ * @return the converted seed value.
+ */
+ OUT convert(IN seed);
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/SeedConverterComposer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/SeedConverterComposer.java b/src/main/java/org/apache/commons/rng/internal/util/SeedConverterComposer.java
new file mode 100644
index 0000000..7c463b8
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/SeedConverterComposer.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+/**
+ * Composes two {@link SeedConverter converters}.
+ *
+ * @param Input seed type.
+ * @param Transitional seed type.
+ * @param Output seed type.
+ *
+ * @since 4.0
+ */
+public class SeedConverterComposer implements SeedConverter {
+ /** First conversion. */
+ private SeedConverter first;
+ /** Second conversion. */
+ private SeedConverter second;
+
+ /**
+ * @param first First conversion.
+ * @param second second conversion.
+ */
+ public SeedConverterComposer(SeedConverter first,
+ SeedConverter second) {
+ this.first = first;
+ this.second = second;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OUT convert(IN seed) {
+ final TRANS trans = first.convert(seed);
+ return second.convert(trans);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + " (" + second + " o " + first + ")";
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/SeedFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/SeedFactory.java b/src/main/java/org/apache/commons/rng/internal/util/SeedFactory.java
new file mode 100644
index 0000000..e02712c
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/SeedFactory.java
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.internal.util;
+
+import org.apache.commons.rng.internal.source32.RandomIntSource;
+import org.apache.commons.rng.internal.source32.Well44497b;
+import org.apache.commons.rng.internal.source64.RandomLongSource;
+import org.apache.commons.rng.internal.source64.SplitMix64;
+
+/**
+ * Utilities related to seeding.
+ *
+ *
+ * This class provides methods to generate random seeds (single values
+ * or arrays of values, of {@code int} or {@code long} types) that can
+ * be passed to the {@link org.apache.commons.rng.RandomSource
+ * methods that create a generator instance}.
+ *
+ * Although the seed-generating methods defined in this class will likely
+ * return different values for all calls, there is no guarantee that the
+ * produced seed will result always in a "good" sequence of numbers (even
+ * if the generator initialized with that seed is good).
+ *
+ * There is no guarantee that sequences will not overlap.
+ *
+ *
+ * @since 4.0
+ */
+public class SeedFactory {
+ /** Generator with a long period. */
+ private static final RandomIntSource SEED_GENERATOR;
+
+ static {
+ // Another RNG for initializing the "SEED_GENERATOR".
+ final long t = System.currentTimeMillis();
+ final int h = System.identityHashCode(Runtime.getRuntime());
+ final SplitMix64 rng = new SplitMix64(t ^ NumberFactory.makeLong(h, ~h));
+
+ final int blockCount = 1391; // Size of the state array of "Well44497b".
+ SEED_GENERATOR = new Well44497b(createIntArray(blockCount, rng));
+ }
+
+ /**
+ * Class contains only static methods.
+ */
+ private SeedFactory() {}
+
+ /**
+ * Creates a number for use as a seed.
+ *
+ * @return a random number.
+ */
+ public static int createInt() {
+ return createInt(SEED_GENERATOR, System.identityHashCode(new Object()));
+ }
+
+ /**
+ * Creates a number for use as a seed.
+ *
+ * @return a random number.
+ */
+ public static long createLong() {
+ return createLong(SEED_GENERATOR, System.identityHashCode(new Object()));
+ }
+
+ /**
+ * Creates an array of numbers for use as a seed.
+ *
+ * @param n Size of the array to create.
+ * @return an array of {@code n} random numbers.
+ */
+ public static int[] createIntArray(int n) {
+ return createIntArray(n, SEED_GENERATOR, new Object());
+ }
+
+ /**
+ * Creates an array of numbers for use as a seed.
+ *
+ * @param n Size of the array to create.
+ * @return an array of {@code n} random numbers.
+ */
+ public static long[] createLongArray(int n) {
+ return createLongArray(n, SEED_GENERATOR, new Object());
+ }
+
+ /**
+ * Creates an array of numbers for use as a seed.
+ *
+ * @param n Size of the array to create.
+ * @param source Source of randomness.
+ * @return an array of {@code n} random numbers drawn from the
+ * {@code source}.
+ */
+ static long[] createLongArray(int n,
+ RandomIntSource source) {
+ return createLongArray(n, source, null);
+ }
+
+ /**
+ * Creates an array of numbers for use as a seed.
+ *
+ * @param n Size of the array to create.
+ * @param source Source of randomness.
+ * @return an array of {@code n} random numbers drawn from the
+ * {@code source}.
+ */
+ static int[] createIntArray(int n,
+ RandomLongSource source) {
+ return createIntArray(n, source, null);
+ }
+
+ /**
+ * Creates an array of numbers for use as a seed.
+ *
+ * @param n Size of the array to create.
+ * @param source Source of randomness.
+ * @return an array of {@code n} random numbers drawn from the
+ * {@code source}.
+ */
+ static int[] createIntArray(int n,
+ RandomIntSource source) {
+ return createIntArray(n, source, null);
+ }
+
+ /**
+ * Creates an array of numbers for use as a seed.
+ *
+ * @param n Size of the array to create.
+ * @param source Source of randomness.
+ * @param h Arbitrary object whose {@link System#identityHashCode(Object)
+ * hash code} will be combined with the next number drawn from
+ * the {@code source}.
+ * @return an array of {@code n} random numbers.
+ */
+ private static long[] createLongArray(int n,
+ RandomIntSource source,
+ Object h) {
+ final long[] array = new long[n];
+
+ final int hash = System.identityHashCode(h);
+ for (int i = 0; i < n; i++) {
+ array[i] = createLong(source, hash);
+ }
+
+ return array;
+ }
+
+ /**
+ * Creates an array of numbers for use as a seed.
+ *
+ * @param n Size of the array to create.
+ * @param source Source of randomness.
+ * @param h Arbitrary object whose {@link System#identityHashCode(Object)
+ * hash code} will be combined with the next number drawn from
+ * the {@code source}.
+ * @return an array of {@code n} random numbers.
+ */
+ private static int[] createIntArray(int n,
+ RandomLongSource source,
+ Object h) {
+ final int[] array = new int[n];
+
+ final int hash = System.identityHashCode(h);
+ for (int i = 0; i < n; i += 2) {
+ final long v = createLong(source, hash);
+
+ array[i] = NumberFactory.extractHi(v);
+
+ if (i + 1 < n) {
+ array[i + 1] = NumberFactory.extractLo(v);
+ }
+ }
+
+ return array;
+ }
+
+ /**
+ * Creates an array of numbers for use as a seed.
+ *
+ * @param n Size of the array to create.
+ * @param source Source of randomness.
+ * @param h Arbitrary object whose {@link System#identityHashCode(Object)
+ * hash code} will be combined with the next number drawn from
+ * the {@code source}.
+ * @return an array of {@code n} random numbers.
+ */
+ private static int[] createIntArray(int n,
+ RandomIntSource source,
+ Object h) {
+ final int[] array = new int[n];
+
+ final int hash = System.identityHashCode(h);
+ for (int i = 0; i < n; i++) {
+ array[i] = createInt(source, hash);
+ }
+
+ return array;
+ }
+
+ /**
+ * Creates a random number by performing an "xor" between the
+ * next value in the sequence of the {@code source} and the
+ * given {@code number}.
+ *
+ * @param source Source of randomness.
+ * @param number Arbitrary number.
+ * @return a random number.
+ */
+ private static long createLong(RandomLongSource source,
+ int number) {
+ synchronized (source) {
+ return source.next() ^ NumberFactory.makeLong(number, number);
+ }
+ }
+
+ /**
+ * Creates a random number by performing an "xor" between the
+ * the next value in the sequence of the {@code source} and the
+ * given {@code number}.
+ *
+ * @param source Source of randomness.
+ * @param number Arbitrary number.
+ * @return a random number.
+ */
+ private static long createLong(RandomIntSource source,
+ int number) {
+ synchronized (source) {
+ return NumberFactory.makeLong(source.next() ^ number,
+ source.next() ^ number);
+ }
+ }
+
+ /**
+ * Creates a random number by performing an "xor" between the
+ * next value in the sequence of the {@code source} and the
+ * given {@code number}.
+ *
+ * @param source Source of randomness.
+ * @param number Arbitrary number.
+ * @return a random number.
+ */
+ private static int createInt(RandomIntSource source,
+ int number) {
+ synchronized (source) {
+ return source.next() ^ number;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/internal/util/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/package-info.java b/src/main/java/org/apache/commons/rng/internal/util/package-info.java
new file mode 100644
index 0000000..662dd2e
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/internal/util/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Utilities for seed conversion.
+ */
+
+package org.apache.commons.rng.internal.util;
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/main/java/org/apache/commons/rng/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/package-info.java b/src/main/java/org/apache/commons/rng/package-info.java
new file mode 100644
index 0000000..7218099
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/package-info.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Randomness Providers
+ *
+ *
+ * This package contains the public API for generating sequences of
+ * pseudo-random numbers that are uniformly distributed in a
+ * specified range.
+ *
+ * All implemented generators can be instantiated through
+ * {@link org.apache.commons.rng.RandomSource factory methods}.
+ * The low-level classes, that define how the randomness is produced,
+ * are implemented in package {@link org.apache.commons.rng.internal}
+ * and its sub-packages, but should not be used directly.
+ *
+ * The generators are not thread-safe: Parallel applications must
+ * use different generator instances in different threads.
+ *
+ *
+ *
+ * In the case of pseudo-random generators, the source of randomness is
+ * usually a set of numbers whose bits representation are scrambled in such
+ * a way as to produce a random-looking sequence.
+ *
+ * The main property of the sequence is that the numbers must be uniformly
+ * distributed within their allowed range.
+ *
+ * Classes in this package do not provide any further processing of the
+ * number generation such as to match other types of distribution.
+ *
+ *
+ *
+ * Which source of randomness to choose may depend on which properties
+ * are more important.
+ * Considerations can include speed of generation, memory usage, period
+ * size, equidistribution, correlation, etc.
+ *
+ * For some of the generators, interesting properties (of the reference
+ * implementations) are proven in scientific papers.
+ * Some generators can also suffer from potential weaknesses.
+ *
+ *
+ *
+ * For simple sampling, any of the generators implemented in this library
+ * may be sufficient.
+ *
+ * For Monte-Carlo simulations that require generating high-dimensional
+ * vectors), equidistribution and non-correlation are crucial.
+ * The Mersenne Twister and Well generators have
+ * equidistribution properties proven according to their bits pool size
+ * which is directly related to their period (all of them have maximal
+ * period, i.e. a generator with size {@code n} pool has a period
+ * 2n-1
).
+ * They also have equidistribution properties for 32 bits blocks up to
+ * {@code s/32} dimension where {@code s} is their pool size.
+ *
+ * For example, {@code Well19937c} is equidistributed up to dimension 623
+ * (i.e. 19937 divided by 32).
+ * It means that a Monte-Carlo simulation generating vectors of {@code n}
+ * (32-bits integer) variables at each iteration has some guarantee on the
+ * properties of its components as long as {@code n < 623}.
+ * Note that if the variables are of type {@code double}, the limit is
+ * divided by two (since 64 bits are needed to create a {@code double}).
+ *
+ * Reference to the relevant publications are listed in the specific
+ * documentation of each class.
+ *
+ *
+ *
+ * Memory usage can vary a lot between providers.
+ * The state of {@code MersenneTwister} is composed of 624 integers,
+ * using about 2.5 kB.
+ * The Well generators use 6 integer arrays, the length of each
+ * being equal to the pool size; thus, for example, {@code Well44497b}
+ * uses about 33 kB.
+ *
+ */
+
+package org.apache.commons.rng;
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/site/apt/userguide/rng.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/userguide/rng.apt b/src/site/apt/userguide/rng.apt
new file mode 100644
index 0000000..a5da792
--- /dev/null
+++ b/src/site/apt/userguide/rng.apt
@@ -0,0 +1,244 @@
+~~
+~~ Licensed to the Apache Software Foundation (ASF) under one or more
+~~ contributor license agreements. See the NOTICE file distributed with
+~~ this work for additional information regarding copyright ownership.
+~~ The ASF licenses this file to You under the Apache License, Version 2.0
+~~ (the "License"); you may not use this file except in compliance with
+~~ the License. You may obtain a copy of the License at
+~~
+~~ http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing, software
+~~ distributed under the License is distributed on an "AS IS" BASIS,
+~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~~ See the License for the specific language governing permissions and
+~~ limitations under the License.
+~~
+
+ -----------------------------
+ The Commons Rng User Guide
+ -----------------------------
+
+1. Usage overview
+
+ The <<>> package contains the random number generation functionality.
+ Please refer to the {{{../apidocs/index.html}Javadoc}} for details.
+
+
+2. Library layout
+
+
+3. Performance
+
+ This section reports benchmarks of the RNG implementations.
+ All runs were performed on a platform with the following characteristics:
+
+ * CPU: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
+
+ * Java runtime: 1.7.0_95-b00
+
+ * JVM: OpenJDK 64-Bit Server VM 24.95-b01
+
+ []
+
+ The following tables indicates the performance for generating
+
+ * a sequence of 32-bits integers (a.k.a. Java type <<>>)
+
+ * a sequence of 64-bits integers (a.k.a. Java type <<>>)
+
+ * a sequence of 64-bits floating point numbers (a.k.a. Java type <<>>)
+
+ []
+
+ The first column is the RNG identifier (see {{{../apidocs/org/apache/commons/rng/RandomSource.html}RandomSource}}).
+
+ Two independent benchmarking tools were used:
+
+ * Commons Math <<>>
+
+ * {{{http://openjdk.java.net/projects/code-tools/jmh/}JMH}}
+
+ []
+
+ The results of those tools are reported in second and third columns, respectively, where
+ the value is the ratio of the performance of the implementation with respect to the
+ corresponding performance of the JDK's <<>> class.
+ In these tables, is .
+
+
+
+ ** Generating <<>> values
+
+
+*---------------------------------*------------------------+--------------+
+|| RNG identifier || Ratio (PerfTestUtils) || Ratio (JMH) |
+*---------------------------------*------------------------+--------------+
+| JDK | 1.21 | 1.000 |
+*---------------------------------*------------------------+--------------+
+| MT | 1.19 | 0.639 |
+*---------------------------------*------------------------+--------------+
+| WELL_512_A | 1.33 | 0.740 |
+*---------------------------------*------------------------+--------------+
+| WELL_1024_A | 1.38 | 0.795 |
+*---------------------------------*------------------------+--------------+
+| WELL_19937_A | 1.47 | 1.039 |
+*---------------------------------*------------------------+--------------+
+| WELL_19937_C | 1.54 | 1.102 |
+*---------------------------------*------------------------+--------------+
+| WELL_44497_A | 1.53 | 1.187 |
+*---------------------------------*------------------------+--------------+
+| WELL_44497_B | 1.59 | 1.114 |
+*---------------------------------*------------------------+--------------+
+| ISAAC | 1.30 | 0.610 |
+*---------------------------------*------------------------+--------------+
+| MT_64 | 1.31 | 0.734 |
+*---------------------------------*------------------------+--------------+
+| SPLIT_MIX_64 | 1.00 | 0.361 |
+*---------------------------------*------------------------+--------------+
+| XOR_SHIFT_1024_S | 1.09 | 0.450 |
+*---------------------------------*------------------------+--------------+
+| TWO_CMRES | 1.14 | 0.464 |
+*---------------------------------*------------------------+--------------+
+
+
+
+ ** Generating <<>> values
+
+
+*---------------------------------*------------------------+--------------+
+|| RNG identifier || Ratio (PerfTestUtils) || Ratio (JMH) |
+*---------------------------------*------------------------+--------------+
+| JDK | 1.40 | 1.002 |
+*---------------------------------*------------------------+--------------+
+| MT | 0.85 | 0.569 |
+*---------------------------------*------------------------+--------------+
+| WELL_512_A | 1.05 | 0.798 |
+*---------------------------------*------------------------+--------------+
+| WELL_1024_A | 1.08 | 0.873 |
+*---------------------------------*------------------------+--------------+
+| WELL_19937_A | 1.21 | 0.968 |
+*---------------------------------*------------------------+--------------+
+| WELL_19937_C | 1.27 | 1.020 |
+*---------------------------------*------------------------+--------------+
+| WELL_44497_A | 1.26 | 1.103 |
+*---------------------------------*------------------------+--------------+
+| WELL_44497_B | 1.31 | 1.043 |
+*---------------------------------*------------------------+--------------+
+| ISAAC | 0.96 | 0.515 |
+*---------------------------------*------------------------+--------------+
+| MT_64 | 0.67 | 0.343 |
+*---------------------------------*------------------------+--------------+
+| SPLIT_MIX_64 | 0.55 | 0.175 |
+*---------------------------------*------------------------+--------------+
+| XOR_SHIFT_1024_S | 0.59 | 0.207 |
+*---------------------------------*------------------------+--------------+
+| TWO_CMRES | 0.61 | 0.223 |
+*---------------------------------*------------------------+--------------+
+
+
+
+ ** Generating <<>> values
+
+
+*---------------------------------*------------------------+--------------+
+|| RNG identifier || Ratio (PerfTestUtils) || Ratio (JMH) |
+*---------------------------------*------------------------+--------------+
+| JDK | 1.15 | 1.001 |
+*---------------------------------*------------------------+--------------+
+| MT | 0.86 | 0.614 |
+*---------------------------------*------------------------+--------------+
+| WELL_512_A | 1.08 | 0.839 |
+*---------------------------------*------------------------+--------------+
+| WELL_1024_A | 1.11 | 0.899 |
+*---------------------------------*------------------------+--------------+
+| WELL_19937_A | 1.23 | 0.984 |
+*---------------------------------*------------------------+--------------+
+| WELL_19937_C | 1.29 | 1.069 |
+*---------------------------------*------------------------+--------------+
+| WELL_44497_A | 1.28 | 1.125 |
+*---------------------------------*------------------------+--------------+
+| WELL_44497_B | 1.33 | 1.093 |
+*---------------------------------*------------------------+--------------+
+| ISAAC | 0.98 | 0.583 |
+*---------------------------------*------------------------+--------------+
+| MT_64 | 0.66 | 0.391 |
+*---------------------------------*------------------------+--------------+
+| SPLIT_MIX_64 | 0.57 | 0.226 |
+*---------------------------------*------------------------+--------------+
+| XOR_SHIFT_1024_S | 0.59 | 0.262 |
+*---------------------------------*------------------------+--------------+
+| TWO_CMRES | 0.60 | 0.284 |
+*---------------------------------*------------------------+--------------+
+
+
+4. Quality
+
+ This section reports results of performing "stress tests" that aim at detecting failures
+ of an implementation to produce sequences of numbers that follow a uniform distribution.
+
+ Two different test suites were used:
+
+ * {{{http://www.phy.duke.edu/~rgb/General/dieharder.php}Dieharder}}
+
+ * {{{http://simul.iro.umontreal.ca/testu01/tu01.html}TestU01}}
+
+ []
+
+ The first column is the RNG identifier (see {{{../apidocs/org/apache/commons/rng/RandomSource.html}RandomSource}}).
+ The second and third columns contain the number of tests which and
+ respectively reported as below the accepted threshold for considering the sequence as
+ uniformly random; hence, in this table, is .
+
+ For each the two test suites, two runs were performed (using random seeds): Click on one
+ of the numbers of the comma-separated list in order to see the text report of the
+ corresponding run.
+ Note: For , a failure on the "Diehard Sums Test" can be {{{http://www.phy.duke.edu/~rgb/General/dieharder.php}ignored}}.
+
+
+*---------------------------------*----------------*---------------------*
+|| RNG identifier || Dieharder || TestU01 (BigCrush) |
+*----------------*----------------*----------------*---------------------*
+| JDK | {{{../txt/userguide/rng/stress/dh/run_1/dh_1}13}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_1}11}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_1}77}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_1}74}} |
+*---------------------------------*----------------*----------------*
+| MT | {{{../txt/userguide/rng/stress/dh/run_1/dh_2}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_2}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_2}2}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_2}2}} |
+*---------------------------------*----------------*----------------*
+| WELL_512_A | {{{../txt/userguide/rng/stress/dh/run_1/dh_3}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_3}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_3}6}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_3}7}} |
+*---------------------------------*----------------*----------------*
+| WELL_1024_A | {{{../txt/userguide/rng/stress/dh/run_1/dh_4}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_4}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_4}5}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_4}4}} |
+*---------------------------------*----------------*----------------*
+| WELL_19937_A | {{{../txt/userguide/rng/stress/dh/run_1/dh_5}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_5}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_5}3}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_5}3}} |
+*---------------------------------*----------------*----------------*
+| WELL_19937_C | {{{../txt/userguide/rng/stress/dh/run_1/dh_6}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_6}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_6}3}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_6}2}} |
+*---------------------------------*----------------*----------------*
+| WELL_44497_A | {{{../txt/userguide/rng/stress/dh/run_1/dh_7}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_7}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_7}2}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_7}2}} |
+*---------------------------------*----------------*----------------*
+| WELL_44497_B | {{{../txt/userguide/rng/stress/dh/run_1/dh_8}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_8}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_8}3}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_8}2}} |
+*---------------------------------*----------------*----------------*
+| ISAAC | {{{../txt/userguide/rng/stress/dh/run_1/dh_9}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_9}1}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_9}1}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_9}0}} |
+*---------------------------------*----------------*----------------*
+| MT_64 | {{{../txt/userguide/rng/stress/dh/run_1/dh_10}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_10}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_10}2}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_10}2}} |
+*---------------------------------*----------------*----------------*
+| SPLIT_MIX_64 | {{{../txt/userguide/rng/stress/dh/run_1/dh_11}1}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_11}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_11}0}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_11}0}} |
+*---------------------------------*----------------*----------------*
+| XOR_SHIFT_1024_S | {{{../txt/userguide/rng/stress/dh/run_1/dh_12}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_12}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_12}2}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_12}0}} |
+*---------------------------------*----------------*----------------*
+| TWO_CMRES | {{{../txt/userguide/rng/stress/dh/run_1/dh_13}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_13}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_13}1}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_13}0}} |
+*---------------------------------*----------------*----------------*
+
+
+5. Dependencies
+
+ Commons Rng requires JDK 1.5+ and has no runtime dependencies.
+
+6. License
+
+ Commons Rng is distributed under the terms of the
+ {{{http://www.apache.org/licenses/LICENSE-2.0}Apache License, Version 2.0}}.
+
+ This product includes software developed by other third parties and
+ distributed under licenses terms compatible with Apache License, Version 2.0.
+ All the licenses of such third parties products are available in the distribution
+ in the LICENSE.txt file. Some products require additional attribution, these
+ attributions can be found in the NOTICE.txt file. These files are available
+ both in the source packages and in the binaries distribution jar files.
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/site/resources/images/commons_rng.png
----------------------------------------------------------------------
diff --git a/src/site/resources/images/commons_rng.png b/src/site/resources/images/commons_rng.png
new file mode 100644
index 0000000..1005119
Binary files /dev/null and b/src/site/resources/images/commons_rng.png differ
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/src/site/resources/profile.jacoco b/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..a12755f
--- /dev/null
+++ b/src/site/resources/profile.jacoco
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+#
+# Empty file used to automatically trigger JaCoCo profile from commons parent pom
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/site/resources/style/project.css
----------------------------------------------------------------------
diff --git a/src/site/resources/style/project.css b/src/site/resources/style/project.css
new file mode 100644
index 0000000..bd137e4
--- /dev/null
+++ b/src/site/resources/style/project.css
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@import url("http://commons.apache.org/style/commons-maven.css");
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c0495bf2/src/site/resources/txt/userguide/stress/dh/run_1/dh_1
----------------------------------------------------------------------
diff --git a/src/site/resources/txt/userguide/stress/dh/run_1/dh_1 b/src/site/resources/txt/userguide/stress/dh/run_1/dh_1
new file mode 100644
index 0000000..224d2a0
--- /dev/null
+++ b/src/site/resources/txt/userguide/stress/dh/run_1/dh_1
@@ -0,0 +1,146 @@
+#
+# RNG: org.apache.commons.math4.rng.internal.source32.JDKRandom
+#
+# Java: 1.8.0_66
+# Runtime: 1.8.0_66-b17
+# JVM: Java HotSpot(TM) 64-Bit Server VM 25.66-b17
+# OS: Linux 3.16.0-4-amd64 amd64
+#
+# Analyzer: /usr/bin/dieharder -a -g 200 -Y 1 -k 2
+#
+#=============================================================================#
+# dieharder version 3.31.1 Copyright 2003 Robert G. Brown #
+#=============================================================================#
+ rng_name |rands/second| Seed |
+stdin_input_raw| 8.46e+06 |3234096741|
+#=============================================================================#
+ test_name |ntup| tsamples |psamples| p-value |Assessment
+#=============================================================================#
+ diehard_birthdays| 0| 100| 100|0.03946185| PASSED
+ diehard_operm5| 0| 1000000| 100|0.01629539| PASSED
+ diehard_rank_32x32| 0| 40000| 100|0.98579998| PASSED
+ diehard_rank_6x8| 0| 100000| 100|0.53483219| PASSED
+ diehard_bitstream| 0| 2097152| 100|0.99560702| WEAK
+ diehard_bitstream| 0| 2097152| 200|0.47019123| PASSED
+ diehard_opso| 0| 2097152| 100|0.58743463| PASSED
+ diehard_oqso| 0| 2097152| 100|0.00000000| FAILED
+ diehard_dna| 0| 2097152| 100|0.00000000| FAILED
+diehard_count_1s_str| 0| 256000| 100|0.90699558| PASSED
+diehard_count_1s_byt| 0| 256000| 100|0.97545849| PASSED
+ diehard_parking_lot| 0| 12000| 100|0.01296474| PASSED
+ diehard_2dsphere| 2| 8000| 100|0.51391418| PASSED
+ diehard_3dsphere| 3| 4000| 100|0.18584250| PASSED
+ diehard_squeeze| 0| 100000| 100|0.00726652| PASSED
+ diehard_sums| 0| 100| 100|0.40869228| PASSED
+ diehard_runs| 0| 100000| 100|0.05169565| PASSED
+ diehard_runs| 0| 100000| 100|0.98866390| PASSED
+ diehard_craps| 0| 200000| 100|0.35494552| PASSED
+ diehard_craps| 0| 200000| 100|0.47365191| PASSED
+ marsaglia_tsang_gcd| 0| 10000000| 100|0.14780252| PASSED
+ marsaglia_tsang_gcd| 0| 10000000| 100|0.29338446| PASSED
+ sts_monobit| 1| 100000| 100|0.97888201| PASSED
+ sts_runs| 2| 100000| 100|0.74655596| PASSED
+ sts_serial| 1| 100000| 100|0.41897552| PASSED
+ sts_serial| 2| 100000| 100|0.38034056| PASSED
+ sts_serial| 3| 100000| 100|0.99170185| PASSED
+ sts_serial| 3| 100000| 100|0.76457270| PASSED
+ sts_serial| 4| 100000| 100|0.80172413| PASSED
+ sts_serial| 4| 100000| 100|0.52177712| PASSED
+ sts_serial| 5| 100000| 100|0.99297019| PASSED
+ sts_serial| 5| 100000| 100|0.59183271| PASSED
+ sts_serial| 6| 100000| 100|0.94001454| PASSED
+ sts_serial| 6| 100000| 100|0.39218216| PASSED
+ sts_serial| 7| 100000| 100|0.69888838| PASSED
+ sts_serial| 7| 100000| 100|0.16541368| PASSED
+ sts_serial| 8| 100000| 100|0.47131229| PASSED
+ sts_serial| 8| 100000| 100|0.09817778| PASSED
+ sts_serial| 9| 100000| 100|0.42261781| PASSED
+ sts_serial| 9| 100000| 100|0.05344107| PASSED
+ sts_serial| 10| 100000| 100|0.77804588| PASSED
+ sts_serial| 10| 100000| 100|0.57799732| PASSED
+ sts_serial| 11| 100000| 100|0.01016312| PASSED
+ sts_serial| 11| 100000| 100|0.06073112| PASSED
+ sts_serial| 12| 100000| 100|0.65917138| PASSED
+ sts_serial| 12| 100000| 100|0.63230695| PASSED
+ sts_serial| 13| 100000| 100|0.84190399| PASSED
+ sts_serial| 13| 100000| 100|0.85277783| PASSED
+ sts_serial| 14| 100000| 100|0.49213152| PASSED
+ sts_serial| 14| 100000| 100|0.30112917| PASSED
+ sts_serial| 15| 100000| 100|0.14544079| PASSED
+ sts_serial| 15| 100000| 100|0.94737293| PASSED
+ sts_serial| 16| 100000| 100|0.39262889| PASSED
+ sts_serial| 16| 100000| 100|0.84185055| PASSED
+ rgb_bitdist| 1| 100000| 100|0.54063417| PASSED
+ rgb_bitdist| 2| 100000| 100|0.09286365| PASSED
+ rgb_bitdist| 3| 100000| 100|0.27436056| PASSED
+ rgb_bitdist| 4| 100000| 100|0.10595606| PASSED
+ rgb_bitdist| 5| 100000| 100|0.72828807| PASSED
+ rgb_bitdist| 6| 100000| 100|0.78439941| PASSED
+ rgb_bitdist| 7| 100000| 100|0.54939794| PASSED
+ rgb_bitdist| 8| 100000| 100|0.49285600| PASSED
+ rgb_bitdist| 9| 100000| 100|0.55836635| PASSED
+ rgb_bitdist| 10| 100000| 100|0.09735886| PASSED
+ rgb_bitdist| 11| 100000| 100|0.99987371| WEAK
+ rgb_bitdist| 11| 100000| 200|0.72189984| PASSED
+ rgb_bitdist| 12| 100000| 100|0.16961094| PASSED
+rgb_minimum_distance| 2| 10000| 1000|0.20393701| PASSED
+rgb_minimum_distance| 3| 10000| 1000|0.00000002| FAILED
+rgb_minimum_distance| 4| 10000| 1000|0.00000000| FAILED
+rgb_minimum_distance| 5| 10000| 1000|0.00000000| FAILED
+ rgb_permutations| 2| 100000| 100|0.57021718| PASSED
+ rgb_permutations| 3| 100000| 100|0.62537216| PASSED
+ rgb_permutations| 4| 100000| 100|0.34391663| PASSED
+ rgb_permutations| 5| 100000| 100|0.51106315| PASSED
+ rgb_lagged_sum| 0| 1000000| 100|0.75921017| PASSED
+ rgb_lagged_sum| 1| 1000000| 100|0.11901881| PASSED
+ rgb_lagged_sum| 2| 1000000| 100|0.98766090| PASSED
+ rgb_lagged_sum| 3| 1000000| 100|0.59129144| PASSED
+ rgb_lagged_sum| 4| 1000000| 100|0.42126930| PASSED
+ rgb_lagged_sum| 5| 1000000| 100|0.28570675| PASSED
+ rgb_lagged_sum| 6| 1000000| 100|0.61879754| PASSED
+ rgb_lagged_sum| 7| 1000000| 100|0.44777033| PASSED
+ rgb_lagged_sum| 8| 1000000| 100|0.95714236| PASSED
+ rgb_lagged_sum| 9| 1000000| 100|0.55158775| PASSED
+ rgb_lagged_sum| 10| 1000000| 100|0.99968320| WEAK
+ rgb_lagged_sum| 10| 1000000| 200|0.94120047| PASSED
+ rgb_lagged_sum| 11| 1000000| 100|0.00001553| WEAK
+ rgb_lagged_sum| 11| 1000000| 200|0.00000000| FAILED
+ rgb_lagged_sum| 12| 1000000| 100|0.88935254| PASSED
+ rgb_lagged_sum| 13| 1000000| 100|0.76358163| PASSED
+ rgb_lagged_sum| 14| 1000000| 100|0.93169219| PASSED
+ rgb_lagged_sum| 15| 1000000| 100|0.00000000| FAILED
+ rgb_lagged_sum| 16| 1000000| 100|0.97118631| PASSED
+ rgb_lagged_sum| 17| 1000000| 100|0.94598742| PASSED
+ rgb_lagged_sum| 18| 1000000| 100|0.59454816| PASSED
+ rgb_lagged_sum| 19| 1000000| 100|0.00027545| WEAK
+ rgb_lagged_sum| 19| 1000000| 200|0.00000001| FAILED
+ rgb_lagged_sum| 20| 1000000| 100|0.87996908| PASSED
+ rgb_lagged_sum| 21| 1000000| 100|0.76558265| PASSED
+ rgb_lagged_sum| 22| 1000000| 100|0.35273627| PASSED
+ rgb_lagged_sum| 23| 1000000| 100|0.00007767| WEAK
+ rgb_lagged_sum| 23| 1000000| 200|0.00000000| FAILED
+ rgb_lagged_sum| 24| 1000000| 100|0.48030158| PASSED
+ rgb_lagged_sum| 25| 1000000| 100|0.98040339| PASSED
+ rgb_lagged_sum| 26| 1000000| 100|0.58094512| PASSED
+ rgb_lagged_sum| 27| 1000000| 100|0.26354148| PASSED
+ rgb_lagged_sum| 28| 1000000| 100|0.02516105| PASSED
+ rgb_lagged_sum| 29| 1000000| 100|0.19290606| PASSED
+ rgb_lagged_sum| 30| 1000000| 100|0.98500384| PASSED
+ rgb_lagged_sum| 31| 1000000| 100|0.00000000| FAILED
+ rgb_lagged_sum| 32| 1000000| 100|0.73025626| PASSED
+ rgb_kstest_test| 0| 10000| 1000|0.02497988| PASSED
+ dab_bytedistrib| 0| 51200000| 1|1.00000000| FAILED
+ dab_dct| 256| 50000| 1|0.92579052| PASSED
+Preparing to run test 207. ntuple = 0
+ dab_filltree| 32| 15000000| 1|0.00000240| WEAK
+ dab_filltree| 32| 15000000| 1|0.00309996| WEAK
+ dab_filltree| 32| 15000000| 101|0.00000000| FAILED
+ dab_filltree| 32| 15000000| 101|0.00000000| FAILED
+Preparing to run test 208. ntuple = 0
+ dab_filltree2| 0| 5000000| 1|0.24726392| PASSED
+ dab_filltree2| 1| 5000000| 1|0.74594891| PASSED
+Preparing to run test 209. ntuple = 0
+ dab_monobit2| 12| 65000000| 1|0.66141319| PASSED
+#
+# Test duration: 165.6195733010167 minutes
+#