Repository: commons-rng Updated Branches: refs/heads/multimodule 1068c58bd -> 862426a9f
CheckStyle warnings cleanup. Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/862426a9 Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/862426a9 Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/862426a9 Branch: refs/heads/multimodule Commit: 862426a9fce09055b0f9633a278e18fd919d7a00 Parents: 1068c58 Author: Gilles <[email protected]> Authored: Fri Nov 4 15:07:42 2016 +0100 Committer: Gilles <[email protected]> Committed: Fri Nov 4 15:07:42 2016 +0100 ---------------------------------------------------------------------- .../rng/examples/integration/ComputePi.java | 14 +++++--- .../integration/MonteCarloIntegration.java | 4 +-- .../rng/examples/stress/RandomStressTester.java | 36 ++++++++++++++------ 3 files changed, 36 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-rng/blob/862426a9/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/integration/ComputePi.java ---------------------------------------------------------------------- diff --git a/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/integration/ComputePi.java b/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/integration/ComputePi.java index 0b57f55..ed3c383 100644 --- a/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/integration/ComputePi.java +++ b/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/integration/ComputePi.java @@ -16,7 +16,6 @@ */ package org.apache.commons.rng.examples.integration; -import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.simple.RandomSource; /** @@ -45,15 +44,18 @@ public class ComputePi extends MonteCarloIntegration { } /** - * Arguments: - * <ul> + * Program entry point. + * + * @param args Arguments. + * The order is as follows: + * <ol> * <li> * Number of random 2-dimensional points to generate. * </li> * <li> * {@link RandomSource Random source identifier}. * </li> - * </ul> + * </ol> */ public static void main(String[] args) { if (args.length != 2) { @@ -66,8 +68,10 @@ public class ComputePi extends MonteCarloIntegration { final ComputePi piApp = new ComputePi(randomSource); final double piMC = piApp.compute(numPoints); + //CHECKSTYLE: stop all System.out.println("After generating " + (DIMENSION * numPoints) + " random numbers, the error on ð is " + Math.abs(piMC - Math.PI)); + //CHECKSTYLE: resume all } /** @@ -77,7 +81,7 @@ public class ComputePi extends MonteCarloIntegration { public double compute(long numPoints) { return 4 * integrate(numPoints); } - + /** {@inheritDoc} */ @Override protected boolean isInside(double ... rand) { http://git-wip-us.apache.org/repos/asf/commons-rng/blob/862426a9/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/integration/MonteCarloIntegration.java ---------------------------------------------------------------------- diff --git a/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/integration/MonteCarloIntegration.java b/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/integration/MonteCarloIntegration.java index 5e313b3..7631b2e 100644 --- a/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/integration/MonteCarloIntegration.java +++ b/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/integration/MonteCarloIntegration.java @@ -63,14 +63,14 @@ public abstract class MonteCarloIntegration { return result; } - + /** * Indicates whether the given points is inside the region whose * integral is computed. * * @param point Point whose coordinates are random numbers uniformly * distributed in the unit interval. - * @return {@code true} if the {@code point} is inside. + * @return {@code true} if the {@code point} is inside. */ protected abstract boolean isInside(double ... point); http://git-wip-us.apache.org/repos/asf/commons-rng/blob/862426a9/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/stress/RandomStressTester.java ---------------------------------------------------------------------- diff --git a/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/stress/RandomStressTester.java b/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/stress/RandomStressTester.java index da3a797..696f24f 100644 --- a/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/stress/RandomStressTester.java +++ b/commons-rng-examples/src/main/java/org/apache/commons/rng/examples/stress/RandomStressTester.java @@ -92,7 +92,7 @@ public class RandomStressTester { * * @param args Application's arguments. * The order is as follows: - * <ul> + * <ol> * <li>Output prefix: Filename prefix where the output of the analysis will * written to. The appended suffix is the index of the instance within the * list of generators to be tested.</li> @@ -104,9 +104,9 @@ public class RandomStressTester { * <li>Path to the executable: this is the analyzer software that reads 32-bits * integers from stdin.</li> * <li>All remaining arguments are passed to the executable.</li> - * </ul> + * </ol> */ - public static void main(String[] args) throws Exception { + public static void main(String[] args) { final String output = args[0]; final int numThreads = Integer.valueOf(args[1]); @@ -116,7 +116,12 @@ public class RandomStressTester { cmdLine.addAll(Arrays.asList(Arrays.copyOfRange(args, 3, args.length))); final RandomStressTester app = new RandomStressTester(cmdLine, output); - app.run(rngList, numThreads); + + try { + app.run(rngList, numThreads); + } catch (IOException e) { + throw new RuntimeException(e); + } } /** @@ -126,6 +131,7 @@ public class RandomStressTester { * @param numConcurrentTasks Number of concurrent tasks. * Twice as many threads will be started: one thread for the RNG and one * for the analyzer. + * @throws IOException if an error occurs when writing to the disk. */ private void run(Iterable<UniformRandomProvider> generators, int numConcurrentTasks) @@ -165,12 +171,16 @@ public class RandomStressTester { * @param name Name of the class that contains the generators to be * analyzed. * @return the list of generators. + * @throws IllegalStateException if an error occurs during instantiation. */ - private static Iterable<UniformRandomProvider> createGeneratorsList(String name) - throws ClassNotFoundException, - InstantiationException, - IllegalAccessException { - return (Iterable<UniformRandomProvider>) Class.forName(name).newInstance(); + private static Iterable<UniformRandomProvider> createGeneratorsList(String name) { + try { + return (Iterable<UniformRandomProvider>) Class.forName(name).newInstance(); + } catch (ClassNotFoundException| + InstantiationException| + IllegalAccessException e) { + throw new RuntimeException(e); + } } /** @@ -188,8 +198,8 @@ public class RandomStressTester { * @param random RNG to be tested. * @param report Report file. */ - public Task(UniformRandomProvider random, - File report) { + Task(UniformRandomProvider random, + File report) { rng = random; output = report; } @@ -232,6 +242,8 @@ public class RandomStressTester { * @param output File. * @param rng Generator being tested. * @param cmdLine + * @throws IOException if there was a problem opening or writing to + * the {@code output} file. */ private void printHeader(File output, UniformRandomProvider rng) @@ -264,6 +276,8 @@ public class RandomStressTester { /** * @param output File. * @param nanoTime Duration of the run. + * @throws IOException if there was a problem opening or writing to + * the {@code output} file. */ private void printFooter(File output, long nanoTime)
