commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [20/32] [math] MATH-1366
Date Sun, 29 May 2016 21:01:45 GMT
MATH-1366

Obsolete class removed (replaced by method "asUniformRandomProvider" in "RandomUtils").


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/34eba813
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/34eba813
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/34eba813

Branch: refs/heads/develop
Commit: 34eba8132225fcdae317a26dd178901bf9fd437f
Parents: 47c41fe
Author: Gilles <erans@apache.org>
Authored: Fri May 20 14:32:30 2016 +0200
Committer: Gilles <erans@apache.org>
Committed: Fri May 20 14:32:30 2016 +0200

----------------------------------------------------------------------
 .../math4/random/RandomGeneratorFactory.java    | 133 -------------------
 1 file changed, 133 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/34eba813/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java b/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java
deleted file mode 100644
index 287b7ad..0000000
--- a/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.math4.random;
-
-import java.util.Random;
-
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
-
-/**
- * Utilities for creating {@link RandomGenerator} instances.
- *
- * @since 3.3
- */
-public class RandomGeneratorFactory {
-    /**
-     * Class contains only static methods.
-     */
-    private RandomGeneratorFactory() {}
-
-    /**
-     * Creates a {@link RandomGenerator} instance that wraps a
-     * {@link Random} instance.
-     *
-     * @param rng JDK {@link Random} instance that will generate the
-     * the random data.
-     * @return the given RNG, wrapped in a {@link RandomGenerator}.
-     */
-    public static RandomGenerator createRandomGenerator(final Random rng) {
-        return new RandomGenerator() {
-            /** {@inheritDoc} */
-            @Override
-            public void setSeed(int seed) {
-                rng.setSeed((long) seed);
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public void setSeed(int[] seed) {
-                rng.setSeed(convertToLong(seed));
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public void setSeed(long seed) {
-                rng.setSeed(seed);
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public void nextBytes(byte[] bytes) {
-                rng.nextBytes(bytes);
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public int nextInt() {
-                return rng.nextInt();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public int nextInt(int n) {
-                if (n <= 0) {
-                    throw new NotStrictlyPositiveException(n);
-                }
-                return rng.nextInt(n);
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public long nextLong() {
-                return rng.nextLong();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public boolean nextBoolean() {
-                return rng.nextBoolean();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public float nextFloat() {
-                return rng.nextFloat();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public double nextDouble() {
-                return rng.nextDouble();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public double nextGaussian() {
-                return rng.nextGaussian();
-            }
-        };
-    }
-
-    /**
-     * Converts seed from one representation to another.
-     *
-     * @param seed Original seed.
-     * @return the converted seed.
-     */
-    public static long convertToLong(int[] seed) {
-        // The following number is the largest prime that fits
-        // in 32 bits (i.e. 2^32 - 5).
-        final long prime = 4294967291l;
-
-        long combined = 0l;
-        for (int s : seed) {
-            combined = combined * prime + s;
-        }
-
-        return combined;
-    }
-}


Mime
View raw message