--- jsr166/src/test/loops/IntegrateGamma.java 2010/09/20 20:42:37 1.2 +++ jsr166/src/test/loops/IntegrateGamma.java 2015/01/15 18:42:39 1.10 @@ -1,20 +1,18 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ import java.util.concurrent.*; /** * Adapted from FJTask version. - * Sample program using Guassian Quadrature for numerical integration. + * Sample program using Gaussian Quadrature for numerical integration. * Inspired by a * Filaments * demo program. - * */ - public class IntegrateGamma { /** for time conversion */ static final long NPS = (1000L * 1000 * 1000); @@ -38,7 +36,7 @@ public class IntegrateGamma { return; } - ForkJoinPool g = procs == 0? new ForkJoinPool() : + ForkJoinPool g = (procs == 0) ? new ForkJoinPool() : new ForkJoinPool(procs); System.out.println("Integrating from " + start + " to " + end + " exponent: " + exp + " parallelism " + g.getParallelism()); @@ -66,20 +64,20 @@ public class IntegrateGamma { classes declared as static within Integrate */ - /** A function to be integrated **/ + /** A function to be integrated */ static interface Function { double compute(double x); } /** * Sample from filaments demo. - * Computes (2*n-1)*(x^(2*n-1)) for all odd values - **/ + * Computes (2*n-1)*(x^(2*n-1)) for all odd values. + */ static class SampleFunction implements Function { final int n; SampleFunction(int n) { this.n = n; } - public double compute(double x) { + public double compute(double x) { double power = x; double xsq = x * x; double val = power; @@ -93,7 +91,6 @@ public class IntegrateGamma { } } - static class Integrator { final Function f; // The function to integrate final double errorTolerance; @@ -116,7 +113,6 @@ public class IntegrateGamma { return q.area; } - /** * FJTask to recursively perform the quadrature. * Algorithm: @@ -124,7 +120,7 @@ public class IntegrateGamma { * and from the center point to the upper bound. If this * differs from the value from lower to upper by more than * the error tolerance, recurse on each half. - **/ + */ final class Quad extends RecursiveAction { final double left; // lower bound final double right; // upper bound @@ -171,5 +167,3 @@ public class IntegrateGamma { } } - -