diff --git a/checkstyle.xml b/checkstyle.xml index 31ad5789e..718e105ec 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -1,8 +1,6 @@ - + @@ -18,6 +16,16 @@ + + + + + + + + + + diff --git a/src/java/org/apache/commons/math/analysis/RootFinding.java b/src/java/org/apache/commons/math/analysis/RootFinding.java index f32ccafdf..cd05fc785 100644 --- a/src/java/org/apache/commons/math/analysis/RootFinding.java +++ b/src/java/org/apache/commons/math/analysis/RootFinding.java @@ -58,12 +58,9 @@ import org.apache.commons.math.MathException; /** * Utility class comprised of root finding techniques. * - * @version $Revision: 1.3 $ $Date: 2003/07/09 20:02:43 $ + * @version $Revision: 1.4 $ $Date: 2003/09/07 03:12:56 $ */ public class RootFinding { - /** Maximum allowed numerical error. */ - private static final double EPSILON = 10e-9; - /** * Default constructor. Prohibit construction. */ diff --git a/src/java/org/apache/commons/math/analysis/SplineInterpolator.java b/src/java/org/apache/commons/math/analysis/SplineInterpolator.java index 5b9f19ba9..00d73e158 100644 --- a/src/java/org/apache/commons/math/analysis/SplineInterpolator.java +++ b/src/java/org/apache/commons/math/analysis/SplineInterpolator.java @@ -56,10 +56,11 @@ package org.apache.commons.math.analysis; /** * Computes a natural spline interpolation for the data set. * - * @version $Revision: 1.3 $ $Date: 2003/07/30 21:58:10 $ + * @version $Revision: 1.4 $ $Date: 2003/09/07 03:12:56 $ * */ public class SplineInterpolator implements UnivariateRealInterpolator { + /** the natural spline coefficients. */ private double[][] c = null; /** @@ -67,8 +68,6 @@ public class SplineInterpolator implements UnivariateRealInterpolator { * @param xval the arguments for the interpolation points * @param yval the values for the interpolation points * @return a function which interpolates the data set - * @throws MathException if arguments violate assumptions made by the - * interpolationg algorithm */ public UnivariateRealFunction interpolate(double[] xval, double[] yval) { if (xval.length != yval.length) { diff --git a/src/java/org/apache/commons/math/analysis/UnivariateRealSolverFactory.java b/src/java/org/apache/commons/math/analysis/UnivariateRealSolverFactory.java index c21c18ba2..e5ed120ef 100644 --- a/src/java/org/apache/commons/math/analysis/UnivariateRealSolverFactory.java +++ b/src/java/org/apache/commons/math/analysis/UnivariateRealSolverFactory.java @@ -61,7 +61,7 @@ package org.apache.commons.math.analysis; * (this may be controversial, because the configuration data * may also be used for the default solver used by the static * solve() method). - * @version $Revision: 1.4 $ $Date: 2003/07/30 21:58:10 $ + * @version $Revision: 1.5 $ $Date: 2003/09/07 03:12:56 $ */ public abstract class UnivariateRealSolverFactory { /** @@ -71,8 +71,8 @@ public abstract class UnivariateRealSolverFactory { } /** + * Create a new factory. * @return a new factory. - * @todo add comment * @todo for now, return the only concrete factory. Later, allow for a * plugable implementation, possibly using SPI and commons-discovery. */ diff --git a/src/java/org/apache/commons/math/analysis/UnivariateRealSolverUtil.java b/src/java/org/apache/commons/math/analysis/UnivariateRealSolverUtil.java index 2ae337975..3223007ab 100644 --- a/src/java/org/apache/commons/math/analysis/UnivariateRealSolverUtil.java +++ b/src/java/org/apache/commons/math/analysis/UnivariateRealSolverUtil.java @@ -56,8 +56,8 @@ package org.apache.commons.math.analysis; import org.apache.commons.math.MathException; /** - * @version $Revision: 1.1 $ $Date: 2003/07/30 22:06:37 $ - * @todo add comment + * Utility routines for {@link UnivariateRealSolver} objects. + * @version $Revision: 1.2 $ $Date: 2003/09/07 03:12:56 $ */ public class UnivariateRealSolverUtil { /** diff --git a/src/java/org/apache/commons/math/random/EmpiricalDistribution.java b/src/java/org/apache/commons/math/random/EmpiricalDistribution.java index a01c57f9a..28632dbcf 100644 --- a/src/java/org/apache/commons/math/random/EmpiricalDistribution.java +++ b/src/java/org/apache/commons/math/random/EmpiricalDistribution.java @@ -80,7 +80,7 @@ import org.apache.commons.math.stat.Univariate; * build grouped frequnecy histograms representing the input data or to * generate random values "like" those in the input file -- i.e., the values * generated will follow the distribution of the values in the file. - * @version $Revision: 1.3 $ $Date: 2003/07/09 20:02:59 $ + * @version $Revision: 1.4 $ $Date: 2003/09/07 03:12:56 $ */ public interface EmpiricalDistribution { @@ -102,6 +102,7 @@ public interface EmpiricalDistribution { * Generates a random value from this distribution

* Preconditions:

+ * @return the random value. * @throws IllegalStateException if the distribution has not been loaded */ double getNextValue() throws IllegalStateException; @@ -111,9 +112,10 @@ public interface EmpiricalDistribution { *

Returns a Univariate describing this distribution

* Preconditions: + * @return the sample statistics * @throws IllegalStateException if the distribution has not been loaded */ - Univariate getSampleStats(); + Univariate getSampleStats() throws IllegalStateException; /** * Loads a saved distribution from a file. diff --git a/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java b/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java index 883c60ffd..431f848e4 100644 --- a/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java +++ b/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java @@ -89,7 +89,7 @@ import org.apache.commons.math.stat.UnivariateImpl; * entry per line. *

* - * @version $Revision: 1.3 $ $Date: 2003/07/09 20:02:59 $ + * @version $Revision: 1.4 $ $Date: 2003/09/07 03:12:56 $ */ public class EmpiricalDistributionImpl implements Serializable,EmpiricalDistribution { @@ -217,7 +217,11 @@ public class EmpiricalDistributionImpl implements Serializable,EmpiricalDistribu loaded = true; } - /** Generates a random value from this distribution */ + /** + * Generates a random value from this distribution + * @return the random value. + * @throws IllegalStateException if the distribution has not been loaded + */ public double getNextValue() throws IllegalStateException { if (!loaded) { diff --git a/src/java/org/apache/commons/math/random/RandomDataImpl.java b/src/java/org/apache/commons/math/random/RandomDataImpl.java index 83199d2f6..29d045472 100644 --- a/src/java/org/apache/commons/math/random/RandomDataImpl.java +++ b/src/java/org/apache/commons/math/random/RandomDataImpl.java @@ -104,7 +104,7 @@ import java.util.Collection; * (so secure sequences started with calls to reseedSecure(long) won't be * identical). * - * @version $Revision: 1.2 $ $Date: 2003/07/07 23:19:21 $ + * @version $Revision: 1.3 $ $Date: 2003/09/07 03:12:56 $ */ public class RandomDataImpl implements RandomData { @@ -127,6 +127,8 @@ public class RandomDataImpl implements RandomData { * len/2+1 binary bytes are generated using the underlying Random *
  • * Each binary byte is translated into 2 hex digits
  • + * @param len the desired string length. + * @return the random string. */ public String nextHexString(int len) { if (len <= 0) { @@ -162,7 +164,14 @@ public class RandomDataImpl implements RandomData { } return outBuffer.toString().substring(0, len); } - + + /** + * Generate a random int value uniformly distributed between + * lower and upper, inclusive. + * @param lower the lower bound. + * @param upper the upper bound. + * @return the random integer. + */ public int nextInt(int lower, int upper) { if (lower >= upper) { throw new IllegalArgumentException @@ -172,6 +181,13 @@ public class RandomDataImpl implements RandomData { return lower + (int) (rand.nextDouble() * (upper - lower + 1)); } + /** + * Generate a random long value uniformly distributed between + * lower and upper, inclusive. + * @param lower the lower bound. + * @param upper the upper bound. + * @return the random integer. + */ public long nextLong(long lower, long upper) { if (lower >= upper) { throw new IllegalArgumentException @@ -194,6 +210,8 @@ public class RandomDataImpl implements RandomData { *

    * TODO: find external reference or provide justification for the claim * that this yields a cryptographically secure sequence of hex strings. + * @param len the desired string length. + * @return the random string. */ public String nextSecureHexString(int len) { if (len <= 0) { @@ -243,6 +261,14 @@ public class RandomDataImpl implements RandomData { return outBuffer.toString().substring(0, len); } + /** + * Generate a random int value uniformly distributed between + * lower and upper, inclusive. This algorithm + * using a secure random number generator for its engine. + * @param lower the lower bound. + * @param upper the upper bound. + * @return the random integer. + */ public int nextSecureInt(int lower, int upper) { if (lower >= upper) { throw new IllegalArgumentException @@ -252,6 +278,14 @@ public class RandomDataImpl implements RandomData { return lower + (int) (sec.nextDouble() * (upper - lower + 1)); } + /** + * Generate a random long value uniformly distributed between + * lower and upper, inclusive. This algorithm + * using a secure random number generator for its engine. + * @param lower the lower bound. + * @param upper the upper bound. + * @return the random integer. + */ public long nextSecureLong(long lower, long upper) { if (lower >= upper) { throw new IllegalArgumentException @@ -267,16 +301,17 @@ public class RandomDataImpl implements RandomData { * described * * here - * + * @param mean mean of the Poisson distribution. + * @return the random Poisson value. */ public long nextPoisson(double mean) { + if (mean <= 0) { + throw new IllegalArgumentException("Poisson mean must be > 0"); + } double p = Math.exp(-mean); long n = 0; double r = 1.0d; Random rand = getRan(); - if (mean <= 0) { - throw new IllegalArgumentException("Poisson mean must be > 0"); - } while (true) { double rnd = rand.nextDouble(); r = r * rnd; @@ -288,6 +323,15 @@ public class RandomDataImpl implements RandomData { } } + /** + * Generate a random value from a Normal distribution. This algorithm + * generates random values for the general Normal distribution with the + * given mean, mu and the given standard deviation, + * sigma. + * @param mu the mean of the distribution. + * @param sigma the standard deviation of the distribution. + * @return the random Normal value. + */ public double nextGaussian(double mu, double sigma) { if (sigma <= 0) { throw new IllegalArgumentException("Gaussian std dev must be > 0"); @@ -300,6 +344,8 @@ public class RandomDataImpl implements RandomData { * Algorithm Description: Uses the * * Inversion Method to generate exponential from uniform deviates. + * @param mean the mean of the distribution. + * @return the random Exponential value. */ public double nextExponential(double mean) { if (mean < 0.0) { @@ -320,6 +366,9 @@ public class RandomDataImpl implements RandomData { * random double if Random.nextDouble() returns 0). * This is necessary to provide a symmetric output interval * (both endpoints excluded). + * @param lower the lower bound. + * @param upper the upper bound. + * @return the random value. */ public double nextUniform(double lower, double upper) { if (lower >= upper) { @@ -327,11 +376,14 @@ public class RandomDataImpl implements RandomData { ("lower bound must be <= upper bound"); } Random rand = getRan(); - double result = lower + rand.nextDouble() * (upper - lower); - while (result == lower) { - result = lower + rand.nextDouble() * (upper - lower); + + // insure nextDouble() isn't 0.0 + double u = rand.nextDouble(); + while(u <= 0.0){ + u = rand.nextDouble(); } - return result; + + return lower + u * (upper - lower); } /** @@ -442,7 +494,9 @@ public class RandomDataImpl implements RandomData { * Uses a 2-cycle permutation shuffle, as described * * here - * + * @param n the population size. + * @param k the number to choose. + * @return the random permutation. */ public int[] nextPermutation(int n, int k) { if (k > n) { @@ -472,6 +526,9 @@ public class RandomDataImpl implements RandomData { * This technique is described, and proven to generate random samples, * * here + * @param c Collection to sample from. + * @param k sample size. + * @return the random sample. */ public Object[] nextSample(Collection c, int k) { int len = c.size(); diff --git a/src/java/org/apache/commons/math/stat/BeanListUnivariateImpl.java b/src/java/org/apache/commons/math/stat/BeanListUnivariateImpl.java index 12dc50fea..916258638 100644 --- a/src/java/org/apache/commons/math/stat/BeanListUnivariateImpl.java +++ b/src/java/org/apache/commons/math/stat/BeanListUnivariateImpl.java @@ -62,7 +62,7 @@ import org.apache.commons.math.util.BeanTransformer; * univariate statistics for a List of Java Beans by property. This * implementation uses beanutils' PropertyUtils to get a simple, nested, * indexed, mapped, or combined property from an element of a List. - * @version $Revision: 1.4 $ $Date: 2003/08/09 04:03:41 $ + * @version $Revision: 1.5 $ $Date: 2003/09/07 03:12:56 $ */ public class BeanListUnivariateImpl extends ListUnivariateImpl { @@ -113,11 +113,11 @@ public class BeanListUnivariateImpl extends ListUnivariateImpl { */ public void addValue(double v) { String msg = - "The BeanListUnivariateImpl does not accept values " - + "through the addValue method. Because elements of this list " - + "are JavaBeans, one must be sure to set the 'propertyName' " - + "property and add new Beans to the underlying list via the " - + "addBean(Object bean) method"; + "The BeanListUnivariateImpl does not accept values " + + "through the addValue method. Because elements of this list " + + "are JavaBeans, one must be sure to set the 'propertyName' " + + "property and add new Beans to the underlying list via the " + + "addBean(Object bean) method"; throw new UnsupportedOperationException(msg); } diff --git a/src/java/org/apache/commons/math/stat/ListUnivariateImpl.java b/src/java/org/apache/commons/math/stat/ListUnivariateImpl.java index 631c30f74..4870f258f 100644 --- a/src/java/org/apache/commons/math/stat/ListUnivariateImpl.java +++ b/src/java/org/apache/commons/math/stat/ListUnivariateImpl.java @@ -60,7 +60,7 @@ import org.apache.commons.math.util.DefaultTransformer; import org.apache.commons.math.util.NumberTransformer; /** - * @version $Revision: 1.4 $ $Date: 2003/07/15 03:45:10 $ + * @version $Revision: 1.5 $ $Date: 2003/09/07 03:12:56 $ */ public class ListUnivariateImpl extends AbstractStoreUnivariate @@ -88,6 +88,7 @@ public class ListUnivariateImpl /** * Construct a ListUnivariate with a specific List. * @param list The list that will back this Univariate + * @param transformer the number transformer used to convert the list items. */ public ListUnivariateImpl(List list, NumberTransformer transformer) { super(); @@ -107,8 +108,9 @@ public class ListUnivariateImpl // take into account only the last n elements of the list // as definied by windowSize - if (windowSize != Univariate.INFINITE_WINDOW - && windowSize < list.size()) { + if (windowSize != Univariate.INFINITE_WINDOW && + windowSize < list.size()) + { length = list.size() - Math.max(0, list.size() - windowSize); } @@ -130,8 +132,9 @@ public class ListUnivariateImpl int calcIndex = index; - if (windowSize != Univariate.INFINITE_WINDOW - && windowSize < list.size()) { + if (windowSize != Univariate.INFINITE_WINDOW && + windowSize < list.size()) + { calcIndex = (list.size() - windowSize) + index; } @@ -198,14 +201,16 @@ public class ListUnivariateImpl } /** - * @return + * Access the number transformer. + * @return the number transformer. */ public NumberTransformer getTransformer() { return transformer; } /** - * @param transformer + * Modify the number transformer. + * @param transformer the new number transformer. */ public void setTransformer(NumberTransformer transformer) { this.transformer = transformer; diff --git a/src/java/org/apache/commons/math/stat/StatUtils.java b/src/java/org/apache/commons/math/stat/StatUtils.java index 2f322740a..80bfce45d 100644 --- a/src/java/org/apache/commons/math/stat/StatUtils.java +++ b/src/java/org/apache/commons/math/stat/StatUtils.java @@ -57,7 +57,7 @@ package org.apache.commons.math.stat; * StatUtils provides easy static implementations of common double[] based * statistical methods. These return a single result value or in some cases, as * identified in the javadoc for each method, Double.NaN. - * @version $Revision: 1.15 $ $Date: 2003/08/09 04:03:41 $ + * @version $Revision: 1.16 $ $Date: 2003/09/07 03:12:56 $ */ public final class StatUtils { @@ -255,8 +255,8 @@ public final class StatUtils { accum2 += (values[i] - mean); } variance = - (accum - (Math.pow(accum2, 2) / ((double) length))) - / (double) (length - 1); + (accum - (Math.pow(accum2, 2) / ((double) length))) / + (double) (length - 1); } return variance; } diff --git a/src/java/org/apache/commons/math/stat/StoreUnivariateImpl.java b/src/java/org/apache/commons/math/stat/StoreUnivariateImpl.java index 173a0c6b2..8c0439371 100644 --- a/src/java/org/apache/commons/math/stat/StoreUnivariateImpl.java +++ b/src/java/org/apache/commons/math/stat/StoreUnivariateImpl.java @@ -57,7 +57,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatistic; import org.apache.commons.math.util.ContractableDoubleArray; /** - * @version $Revision: 1.5 $ $Date: 2003/07/15 03:45:10 $ + * @version $Revision: 1.6 $ $Date: 2003/09/07 03:12:56 $ */ public class StoreUnivariateImpl extends AbstractStoreUnivariate { @@ -113,8 +113,8 @@ public class StoreUnivariateImpl extends AbstractStoreUnivariate { eDA.addElement(v); } else { String msg = - "A window Univariate had more element than " - + "the windowSize. This is an inconsistent state."; + "A window Univariate had more element than " + + "the windowSize. This is an inconsistent state."; throw new RuntimeException(msg); } } else { diff --git a/src/java/org/apache/commons/math/stat/univariate/moment/FourthMoment.java b/src/java/org/apache/commons/math/stat/univariate/moment/FourthMoment.java index 3536d3cc4..687301352 100644 --- a/src/java/org/apache/commons/math/stat/univariate/moment/FourthMoment.java +++ b/src/java/org/apache/commons/math/stat/univariate/moment/FourthMoment.java @@ -58,7 +58,7 @@ package org.apache.commons.math.stat.univariate.moment; * * recursive strategy * . Both incremental and evaluation strategies currently use this approach. - * @version $Revision: 1.7 $ $Date: 2003/08/09 04:03:40 $ + * @version $Revision: 1.8 $ $Date: 2003/09/07 03:12:56 $ */ public class FourthMoment extends ThirdMoment { @@ -91,11 +91,8 @@ public class FourthMoment extends ThirdMoment { n3 = (double) (n - 3); - m4 = - m4 - - (4.0 * v * prevM3) - + (6.0 * v2 * prevM2) - + ((n0 * n0) - 3 * n1) * (v2 * v2 * n1 * n0); + m4 = m4 - (4.0 * v * prevM3) + (6.0 * v2 * prevM2) + + ((n0 * n0) - 3 * n1) * (v2 * v2 * n1 * n0); } /** diff --git a/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java b/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java index afc5469b3..7bacd72ea 100644 --- a/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java +++ b/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java @@ -62,7 +62,7 @@ import org .AbstractStorelessUnivariateStatistic; /** - * @version $Revision: 1.7 $ $Date: 2003/08/09 04:03:40 $ + * @version $Revision: 1.8 $ $Date: 2003/09/07 03:12:56 $ */ public class Kurtosis extends AbstractStorelessUnivariateStatistic { @@ -119,13 +119,9 @@ public class Kurtosis extends AbstractStorelessUnivariateStatistic { kurtosis = 0.0; } else { kurtosis = - (moment.n0 * (moment.n0 + 1) * moment.m4 - - 3 * moment.m2 * moment.m2 * moment.n1) - / (moment.n1 - * moment.n2 - * moment.n3 - * variance - * variance); + (moment.n0 * (moment.n0 + 1) * moment.m4 - + 3 * moment.m2 * moment.m2 * moment.n1) / + (moment.n1 * moment.n2 * moment.n3 * variance * variance); } n = moment.n; } @@ -193,8 +189,8 @@ public class Kurtosis extends AbstractStorelessUnivariateStatistic { double stdDev = Math.sqrt( - (accum - (Math.pow(accum2, 2) / ((double) length))) - / (double) (length - 1)); + (accum - (Math.pow(accum2, 2) / ((double) length))) / + (double) (length - 1)); // Sum the ^4 of the distance from the mean divided by the // standard deviation diff --git a/src/java/org/apache/commons/math/stat/univariate/moment/Skewness.java b/src/java/org/apache/commons/math/stat/univariate/moment/Skewness.java index 1e9a9e903..6db815d8f 100644 --- a/src/java/org/apache/commons/math/stat/univariate/moment/Skewness.java +++ b/src/java/org/apache/commons/math/stat/univariate/moment/Skewness.java @@ -63,7 +63,7 @@ import org /** * - * @version $Revision: 1.7 $ $Date: 2003/08/09 04:03:40 $ + * @version $Revision: 1.8 $ $Date: 2003/09/07 03:12:56 $ */ public class Skewness extends AbstractStorelessUnivariateStatistic { @@ -119,12 +119,8 @@ public class Skewness extends AbstractStorelessUnivariateStatistic { if (moment.n <= 2 || variance < 10E-20) { skewness = 0.0; } else { - skewness = - (moment.n0 * moment.m3) - / (moment.n1 - * moment.n2 - * Math.sqrt(variance) - * variance); + skewness = (moment.n0 * moment.m3) / + (moment.n1 * moment.n2 * Math.sqrt(variance) * variance); } n = moment.n; } @@ -191,8 +187,8 @@ public class Skewness extends AbstractStorelessUnivariateStatistic { } double stdDev = Math.sqrt( - (accum - (Math.pow(accum2, 2) / ((double) length))) - / (double) (length - 1)); + (accum - (Math.pow(accum2, 2) / ((double) length))) / + (double) (length - 1)); // Calculate the skew as the sum the cubes of the distance // from the mean divided by the standard deviation. diff --git a/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java b/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java index d661eecaf..50bd88654 100644 --- a/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java +++ b/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java @@ -57,7 +57,7 @@ import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatis /** * - * @version $Revision: 1.8 $ $Date: 2003/08/09 04:03:40 $ + * @version $Revision: 1.9 $ $Date: 2003/09/07 03:12:56 $ */ public class Variance extends AbstractStorelessUnivariateStatistic { @@ -177,9 +177,8 @@ public class Variance extends AbstractStorelessUnivariateStatistic { accum += Math.pow((values[i] - m), 2.0); accum2 += (values[i] - m); } - var = - (accum - (Math.pow(accum2, 2) / ((double) length))) - / (double) (length - 1); + var = (accum - (Math.pow(accum2, 2) / ((double) length))) / + (double) (length - 1); } } return var; diff --git a/src/java/org/apache/commons/math/util/ContinuedFraction.java b/src/java/org/apache/commons/math/util/ContinuedFraction.java index e1a2d69a6..bb8201c88 100644 --- a/src/java/org/apache/commons/math/util/ContinuedFraction.java +++ b/src/java/org/apache/commons/math/util/ContinuedFraction.java @@ -64,7 +64,7 @@ import org.apache.commons.math.analysis.ConvergenceException; *

  • * Continued Fraction
  • * - * @version $Revision: 1.3 $ $Date: 2003/07/09 20:04:12 $ + * @version $Revision: 1.4 $ $Date: 2003/09/07 03:12:56 $ */ public abstract class ContinuedFraction { /** Maximum allowed numerical error. */ @@ -189,8 +189,9 @@ public abstract class ContinuedFraction { f[1][1] = (a[1][0] * an[0][1]) + (a[1][1] * an[1][1]); // determine if we're close enough - if (Math.abs((f[0][0] * f[1][1]) - (f[1][0] * f[0][1])) - < Math.abs(epsilon * f[1][0] * f[1][1])) { + if (Math.abs((f[0][0] * f[1][1]) - (f[1][0] * f[0][1])) < + Math.abs(epsilon * f[1][0] * f[1][1])) + { ret = f[0][0] / f[1][0]; } else { if (n >= maxIterations) { diff --git a/src/java/org/apache/commons/math/util/ContractableDoubleArray.java b/src/java/org/apache/commons/math/util/ContractableDoubleArray.java index d54f68bf0..35dcb2275 100644 --- a/src/java/org/apache/commons/math/util/ContractableDoubleArray.java +++ b/src/java/org/apache/commons/math/util/ContractableDoubleArray.java @@ -88,7 +88,7 @@ import java.io.Serializable; * internal storage array is swapped. *

    * - * @version $Revision: 1.3 $ $Date: 2003/07/09 20:04:12 $ + * @version $Revision: 1.4 $ $Date: 2003/09/07 03:12:56 $ */ public class ContractableDoubleArray extends ExpandableDoubleArray @@ -292,27 +292,27 @@ public class ContractableDoubleArray if (contractionCritera < expansionFactor) { String msg = - "Contraction criteria can never be smaller than " - + "the expansion factor. This would lead to a never " - + "ending loop of expansion and contraction as a newly " - + "expanded internal storage array would immediately " - + "satisfy the criteria for contraction"; + "Contraction criteria can never be smaller than " + + "the expansion factor. This would lead to a never " + + "ending loop of expansion and contraction as a newly " + + "expanded internal storage array would immediately " + + "satisfy the criteria for contraction"; throw new IllegalArgumentException(msg); } if (contractionCriteria <= 1.0) { String msg = - "The contraction criteria must be a number larger " - + "than one. If the contractionCriteria is less than or " - + "equal to one an endless loop of contraction and " - + "expansion would ensue as an internalArray.length " - + "== numElements would satisfy the contraction criteria"; + "The contraction criteria must be a number larger " + + "than one. If the contractionCriteria is less than or " + + "equal to one an endless loop of contraction and " + + "expansion would ensue as an internalArray.length " + + "== numElements would satisfy the contraction criteria"; throw new IllegalArgumentException(msg); } if (expansionFactor < 1.0) { String msg = - "The expansion factor must be a number greater " + "than 1.0"; + "The expansion factor must be a number greater than 1.0"; throw new IllegalArgumentException(msg); } } diff --git a/src/java/org/apache/commons/math/util/ExpandableDoubleArray.java b/src/java/org/apache/commons/math/util/ExpandableDoubleArray.java index b7b90a10f..57a0cecfa 100644 --- a/src/java/org/apache/commons/math/util/ExpandableDoubleArray.java +++ b/src/java/org/apache/commons/math/util/ExpandableDoubleArray.java @@ -88,7 +88,7 @@ import java.io.Serializable; * expand the array 10 times - first from 2 -> 4. then 4 -> 8, 8 -> 16, * and so on until we reach 4096 which is sufficient to hold 3546 elements. *

    - * @version $Revision: 1.4 $ $Date: 2003/07/09 20:04:12 $ + * @version $Revision: 1.5 $ $Date: 2003/09/07 03:12:56 $ */ public class ExpandableDoubleArray implements Serializable, DoubleArray { @@ -199,9 +199,8 @@ public class ExpandableDoubleArray implements Serializable, DoubleArray { this.initialCapacity = initialCapacity; } else { String msg = - "The initial capacity supplied: " - + initialCapacity - + "must be a positive integer"; + "The initial capacity supplied: " + initialCapacity + + "must be a positive integer"; throw new IllegalArgumentException(msg); } } @@ -270,15 +269,14 @@ public class ExpandableDoubleArray implements Serializable, DoubleArray { double value = Double.NaN; if (index >= numElements) { String msg = - "The index specified: " - + index - + " is larger than the current number of elements"; + "The index specified: " + index + + " is larger than the current number of elements"; throw new ArrayIndexOutOfBoundsException(msg); } else if (index >= 0) { value = internalArray[startIndex + index]; } else { String msg = - "Elements cannot be retrieved from a negative " + "array index"; + "Elements cannot be retrieved from a negative array index"; throw new ArrayIndexOutOfBoundsException(msg); } return value; @@ -403,9 +401,8 @@ public class ExpandableDoubleArray implements Serializable, DoubleArray { public synchronized void discardFrontElements(int i) { if (i > numElements) { - String msg = - "Cannot discard more elements than are" - + "contained in this array."; + String msg = "Cannot discard more elements than are" + + "contained in this array."; throw new IllegalArgumentException(msg); } else if (i < 0) { String msg = "Cannot discard a negative number of elements."; diff --git a/src/java/org/apache/commons/math/util/FixedDoubleArray.java b/src/java/org/apache/commons/math/util/FixedDoubleArray.java index ec5d8fcdb..3010ec9e2 100644 --- a/src/java/org/apache/commons/math/util/FixedDoubleArray.java +++ b/src/java/org/apache/commons/math/util/FixedDoubleArray.java @@ -82,7 +82,7 @@ package org.apache.commons.math.util; * "fixed" in memory, this implementation will never allocate, or copy * the internal storage array to a new array instance. *

    - * @version $Revision: 1.5 $ $Date: 2003/07/09 20:04:12 $ + * @version $Revision: 1.6 $ $Date: 2003/09/07 03:12:56 $ */ public class FixedDoubleArray implements DoubleArray { @@ -164,8 +164,8 @@ public class FixedDoubleArray implements DoubleArray { public double getElement(int index) { if (index > (size - 1)) { String msg = - "Attempted to retrieve an element outside of " - + "the element array"; + "Attempted to retrieve an element outside of " + + "the element array"; throw new ArrayIndexOutOfBoundsException(msg); } else { // Return the element requested, if the index supplied @@ -235,9 +235,9 @@ public class FixedDoubleArray implements DoubleArray { // is trying to add an element beyond the boundaries of the // fixed array. String msg = - "Attempted to add a value to an array of fixed " - + "size, please use addElementRolling " - + "to avoid this exception"; + "Attempted to add a value to an array of fixed " + + "size, please use addElementRolling " + + "to avoid this exception"; throw new ArrayIndexOutOfBoundsException(msg); } } diff --git a/src/test/org/apache/commons/math/analysis/InterpolatorTest.java b/src/test/org/apache/commons/math/analysis/InterpolatorTest.java index 394cb03a7..871b51beb 100644 --- a/src/test/org/apache/commons/math/analysis/InterpolatorTest.java +++ b/src/test/org/apache/commons/math/analysis/InterpolatorTest.java @@ -344,7 +344,7 @@ public class InterpolatorTest extends TestCase { try { double xval[] = { 0.0, 1.0 }; double yval[] = { 0.0, 1.0, 2.0 }; - UnivariateRealFunction f = i.interpolate(xval, yval); + i.interpolate(xval, yval); fail("Failed to detect data set array with different sizes."); } catch (IllegalArgumentException iae) { } @@ -352,7 +352,7 @@ public class InterpolatorTest extends TestCase { try { double xval[] = { 0.0, 1.0, 0.5 }; double yval[] = { 0.0, 1.0, 2.0 }; - UnivariateRealFunction f = i.interpolate(xval, yval); + i.interpolate(xval, yval); fail("Failed to detect unsorted arguments."); } catch (IllegalArgumentException iae) { }