Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 58695 invoked from network); 27 Mar 2011 16:32:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Mar 2011 16:32:26 -0000 Received: (qmail 67089 invoked by uid 500); 27 Mar 2011 16:32:26 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 67027 invoked by uid 500); 27 Mar 2011 16:32:26 -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 67020 invoked by uid 99); 27 Mar 2011 16:32:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Mar 2011 16:32:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Mar 2011 16:32:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3E0D423889B2; Sun, 27 Mar 2011 16:32:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1085981 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math: ./ analysis/integration/ distribution/ linear/ optimization/direct/ special/ stat/clustering/ stat/inference/ Date: Sun, 27 Mar 2011 16:32:01 -0000 To: commits@commons.apache.org From: luc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110327163202.3E0D423889B2@eris.apache.org> Author: luc Date: Sun Mar 27 16:32:01 2011 New Revision: 1085981 URL: http://svn.apache.org/viewvc?rev=1085981&view=rev Log: fixed checkstyle warnings (no functional changes) Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegrator.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/KolmogorovSmirnovDistribution.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/KolmogorovSmirnovDistributionImpl.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldMatrix.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealMatrix.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Beta.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Gamma.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/MannWhitneyUTestImpl.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/WilcoxonSignedRankTestImpl.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java Sun Mar 27 16:32:01 2011 @@ -41,6 +41,9 @@ public class MathException extends Excep /** Serializable version identifier. */ private static final long serialVersionUID = 7428019509644517071L; + /** Deprecation message. */ + private static final String DEPRECATION_MESSAGE = "This class is deprecated; calling this method is a bug."; + /** * Pattern used to build the message. */ @@ -105,22 +108,22 @@ public class MathException extends Excep /** {@inheritDoc} */ public void addMessage(Localizable pat, Object ... args) { - throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); + throw new UnsupportedOperationException(DEPRECATION_MESSAGE); } /** {@inheritDoc} */ public void setContext(String key, Object value) { - throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); + throw new UnsupportedOperationException(DEPRECATION_MESSAGE); } /** {@inheritDoc} */ public Object getContext(String key) { - throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); + throw new UnsupportedOperationException(DEPRECATION_MESSAGE); } /** {@inheritDoc} */ public Set getContextKeys() { - throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); + throw new UnsupportedOperationException(DEPRECATION_MESSAGE); } /** Gets the message in a specified locale. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java Sun Mar 27 16:32:01 2011 @@ -42,6 +42,9 @@ public class MathRuntimeException extend /** Serializable version identifier. */ private static final long serialVersionUID = 9058794795027570002L; + /** Deprecation message. */ + private static final String DEPRECATION_MESSAGE = "This class is deprecated; calling this method is a bug."; + /** * Pattern used to build the message. */ @@ -98,22 +101,22 @@ public class MathRuntimeException extend /** {@inheritDoc} */ public void addMessage(Localizable pat, Object ... args) { - throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); + throw new UnsupportedOperationException(DEPRECATION_MESSAGE); } /** {@inheritDoc} */ public void setContext(String key, Object value) { - throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); + throw new UnsupportedOperationException(DEPRECATION_MESSAGE); } /** {@inheritDoc} */ public Object getContext(String key) { - throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); + throw new UnsupportedOperationException(DEPRECATION_MESSAGE); } /** {@inheritDoc} */ public Set getContextKeys() { - throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); + throw new UnsupportedOperationException(DEPRECATION_MESSAGE); } /** Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegrator.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegrator.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegrator.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegrator.java Sun Mar 27 16:32:01 2011 @@ -40,14 +40,14 @@ public interface UnivariateRealIntegrato * * @param count maximum number of iterations */ - public void setMaximalIterationCount(int count); + void setMaximalIterationCount(int count); /** * Get the upper limit for the number of iterations. * * @return the actual upper limit */ - public int getMaximalIterationCount(); + int getMaximalIterationCount(); /** * Set the absolute accuracy. @@ -64,14 +64,14 @@ public interface UnivariateRealIntegrato * @throws IllegalArgumentException if the accuracy can't be achieved by * the solver or is otherwise deemed unreasonable. */ - public void setAbsoluteAccuracy(double accuracy); + void setAbsoluteAccuracy(double accuracy); /** * Get the actual absolute accuracy. * * @return the accuracy */ - public double getAbsoluteAccuracy(); + double getAbsoluteAccuracy(); /** * Set the relative accuracy. @@ -85,13 +85,13 @@ public interface UnivariateRealIntegrato * * @param accuracy the relative accuracy. */ - public void setRelativeAccuracy(double accuracy); + void setRelativeAccuracy(double accuracy); /** * Get the actual relative accuracy. * @return the accuracy */ - public double getRelativeAccuracy(); + double getRelativeAccuracy(); /** * Set the lower limit for the number of iterations. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java Sun Mar 27 16:32:01 2011 @@ -113,11 +113,11 @@ public abstract class UnivariateRealInte * Convenience function for implementations. * * @param newResult the result to set - * @param iterationCount the iteration count to set + * @param newCount the iteration count to set */ - protected final void setResult(final double newResult, final int iterationCount) { + protected final void setResult(final double newResult, final int newCount) { this.result = newResult; - this.iterationCount = iterationCount; + this.iterationCount = newCount; this.resultComputed = true; } Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java Sun Mar 27 16:32:01 2011 @@ -39,10 +39,11 @@ import org.apache.commons.math.util.Fast public abstract class AbstractContinuousDistribution extends AbstractDistribution implements ContinuousDistribution, Serializable { - /** Serializable version identifier */ - private static final long serialVersionUID = -38038050983108802L; + /** Default accuracy. */ public static final double SOLVER_DEFAULT_ABSOLUTE_ACCURACY = 1e-6; + /** Serializable version identifier */ + private static final long serialVersionUID = -38038050983108802L; /** * RandomData instance used to generate samples from the distribution * @since 2.2 Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/KolmogorovSmirnovDistribution.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/KolmogorovSmirnovDistribution.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/KolmogorovSmirnovDistribution.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/KolmogorovSmirnovDistribution.java Sun Mar 27 16:32:01 2011 @@ -18,21 +18,21 @@ package org.apache.commons.math.distribution; /** - * Treats the distribution of the two-sided + * Treats the distribution of the two-sided * {@code P(D}{@code n}{@code < d)} - * where {@code D}{@code n}{@code = sup_x | G(x) - Gn (x) |} for the + * where {@code D}{@code n}{@code = sup_x | G(x) - Gn (x) |} for the * theoretical cdf G and the emperical cdf Gn. - * + * * @version $Revision$ $Date$ */ public interface KolmogorovSmirnovDistribution { - + /** * Calculates {@code P(D}n {@code < d)}. - * + * * @param d statistic * @return the two-sided probability of {@code P(D}n {@code < d)} */ - public double cdf(double d); - + double cdf(double d); + } Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/KolmogorovSmirnovDistributionImpl.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/KolmogorovSmirnovDistributionImpl.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/KolmogorovSmirnovDistributionImpl.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/KolmogorovSmirnovDistributionImpl.java Sun Mar 27 16:32:01 2011 @@ -32,26 +32,26 @@ import org.apache.commons.math.linear.Re /** * The default implementation of {@link KolmogorovSmirnovDistribution}. - * - *

Treats the distribution of the two-sided + * + *

Treats the distribution of the two-sided * {@code P(D}{@code n}{@code < d)} - * where {@code D}{@code n}{@code = sup_x | G(x) - Gn (x) |} for the + * where {@code D}{@code n}{@code = sup_x | G(x) - Gn (x) |} for the * theoretical cdf G and the emperical cdf Gn.

- * - *

This implementation is based on [1] with certain quick + * + *

This implementation is based on [1] with certain quick * decisions for extreme values given in [2].

- * - *

In short, when wanting to evaluate {@code P(D}{@code n}{@code < d)}, - * the method in [1] is to write {@code d = (k - h) / n} for positive - * integer {@code k} and {@code 0 <= h < 1}. Then + * + *

In short, when wanting to evaluate {@code P(D}{@code n}{@code < d)}, + * the method in [1] is to write {@code d = (k - h) / n} for positive + * integer {@code k} and {@code 0 <= h < 1}. Then * {@code P(D}{@code n}{@code < d) = (n!/n}{@code n}{@code ) * t_kk} - * where {@code t_kk} is the {@code (k, k)}'th entry in the special - * matrix {@code H}{@code n}, i.e. {@code H} to the {@code n}'th power.

- * + * where {@code t_kk} is the {@code (k, k)}'th entry in the special + * matrix {@code H}{@code n}, i.e. {@code H} to the {@code n}'th power.

+ * *

See also * Kolmogorov-Smirnov test on Wikipedia for details.

- * - *

References: + * + *

References: *

    *
  • [1] * Evaluating Kolmogorov's Distribution by George Marsaglia, Wai @@ -60,19 +60,20 @@ import org.apache.commons.math.linear.Re * Computing the Two-Sided Kolmogorov-Smirnov Distribution by Richard Simard * and Pierre L'Ecuyer
  • *
- * Note that [1] contains an error in computing h, refer to + * Note that [1] contains an error in computing h, refer to * MATH-437 for details. *

- * + * * @version $Revision$ $Date$ */ public class KolmogorovSmirnovDistributionImpl implements KolmogorovSmirnovDistribution, Serializable { - + /** Serializable version identifier. */ private static final long serialVersionUID = -4670676796862967187L; + /** Number of observations. */ private int n; - + /** * @param n Number of observations * @throws NotStrictlyPositiveException @@ -82,24 +83,24 @@ public class KolmogorovSmirnovDistributi if (n <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, n); } - + this.n = n; } /** * Calculates {@code P(D}n {@code < d)} using method described in * [1] with quick decisions for extreme values given in [2] (see above). The - * result is not exact as with + * result is not exact as with * {@link KolmogorovSmirnovDistributionImpl#cdfExact(double)} because - * calculations are based on double rather than + * calculations are based on double rather than * {@link org.apache.commons.math.fraction.BigFraction}. - * + * * @param d statistic * @return the two-sided probability of {@code P(D}n {@code < d)} * @throws MathArithmeticException - * if algorithm fails to convert {@code h} to a + * if algorithm fails to convert {@code h} to a * {@link org.apache.commons.math.fraction.BigFraction} in - * expressing {@code d} as {@code (k - h) / m} for integer + * expressing {@code d} as {@code (k - h) / m} for integer * {@code k, m} and {@code 0 <= h < 1}. */ public double cdf(double d) throws MathArithmeticException { @@ -108,19 +109,19 @@ public class KolmogorovSmirnovDistributi /** * Calculates {@code P(D}n {@code < d)} using method described in - * [1] with quick decisions for extreme values given in [2] (see above). - * The result is exact in the sense that BigFraction/BigReal is used everywhere - * at the expense of very slow execution time. Almost never choose this in + * [1] with quick decisions for extreme values given in [2] (see above). + * The result is exact in the sense that BigFraction/BigReal is used everywhere + * at the expense of very slow execution time. Almost never choose this in * real applications unless you are very sure; this is almost solely for - * verification purposes. Normally, you would choose + * verification purposes. Normally, you would choose * {@link KolmogorovSmirnovDistributionImpl#cdf(double)} - * + * * @param d statistic * @return the two-sided probability of {@code P(D}n {@code < d)} * @throws MathArithmeticException - * if algorithm fails to convert {@code h} to a + * if algorithm fails to convert {@code h} to a * {@link org.apache.commons.math.fraction.BigFraction} in - * expressing {@code d} as {@code (k - h) / m} for integer + * expressing {@code d} as {@code (k - h) / m} for integer * {@code k, m} and {@code 0 <= h < 1}. */ public double cdfExact(double d) throws MathArithmeticException { @@ -130,26 +131,24 @@ public class KolmogorovSmirnovDistributi /** * Calculates {@code P(D}n {@code < d)} using method described in * [1] with quick decisions for extreme values given in [2] (see above). - * + * * @param d statistic * @param exact * whether the probability should be calculated exact using * BigFraction everywhere at the expense of very * slow execution time, or if double should be used convenient - * places to gain speed. Almost never choose {@code true} in - * real applications unless you are very sure; {@code true} is + * places to gain speed. Almost never choose {@code true} in + * real applications unless you are very sure; {@code true} is * almost solely for verification purposes. * @return the two-sided probability of {@code P(D}n {@code < d)} * @throws MathArithmeticException - * if algorithm fails to convert {@code h} to a + * if algorithm fails to convert {@code h} to a * {@link org.apache.commons.math.fraction.BigFraction} in - * expressing {@code d} as {@code (k - h) / m} for integer + * expressing {@code d} as {@code (k - h) / m} for integer * {@code k, m} and {@code 0 <= h < 1}. */ public double cdf(double d, boolean exact) throws MathArithmeticException { - - final int n = this.n; final double ninv = 1 / ((double) n); final double ninvhalf = 0.5 * ninv; @@ -179,25 +178,24 @@ public class KolmogorovSmirnovDistributi return 1; } - return (exact) ? this.exactK(d) : this.roundedK(d); + return exact ? exactK(d) : roundedK(d); } /** * Calculates {@code P(D}n {@code < d)} exact using method * described in [1] and BigFraction (see above). - * + * * @param d statistic * @return the two-sided probability of {@code P(D}n {@code < d)} * @throws MathArithmeticException - * if algorithm fails to convert {@code h} to a + * if algorithm fails to convert {@code h} to a * {@link org.apache.commons.math.fraction.BigFraction} in - * expressing {@code d} as {@code (k - h) / m} for integer + * expressing {@code d} as {@code (k - h) / m} for integer * {@code k, m} and {@code 0 <= h < 1}. */ private double exactK(double d) throws MathArithmeticException { - final int n = this.n; final int k = (int) Math.ceil(n * d); final FieldMatrix H = this.createH(d); @@ -214,26 +212,24 @@ public class KolmogorovSmirnovDistributi * denominator to double and divides afterwards. That gives NaN quite * easy. This does not (scale is the number of digits): */ - return pFrac.bigDecimalValue(20, BigDecimal.ROUND_HALF_UP) - .doubleValue(); + return pFrac.bigDecimalValue(20, BigDecimal.ROUND_HALF_UP).doubleValue(); } /** * Calculates {@code P(D}n {@code < d)} using method described in * [1] and doubles (see above). - * + * * @param d statistic * @return the two-sided probability of {@code P(D}n {@code < d)} * @throws MathArithmeticException - * if algorithm fails to convert {@code h} to a + * if algorithm fails to convert {@code h} to a * {@link org.apache.commons.math.fraction.BigFraction} in - * expressing {@code d} as {@code (k - h) / m} for integer + * expressing {@code d} as {@code (k - h) / m} for integer * {@code k, m} and {@code 0 <= h < 1}. */ private double roundedK(double d) throws MathArithmeticException { - - final int n = this.n; + final int k = (int) Math.ceil(n * d); final FieldMatrix HBigFraction = this.createH(d); final int m = HBigFraction.getRowDimension(); @@ -263,28 +259,27 @@ public class KolmogorovSmirnovDistributi /*** * Creates {@code H} of size {@code m x m} as described in [1] (see above). - * + * * @param d statistic - * + * @return H matrix * @throws MathArithmeticException - * if algorithm fails to convert {@code h} to a + * if algorithm fails to convert {@code h} to a * {@link org.apache.commons.math.fraction.BigFraction} in - * expressing {@code d} as {@code (k - h) / m} for integer + * expressing {@code d} as {@code (k - h) / m} for integer * {@code k, m} and {@code 0 <= h < 1}. */ private FieldMatrix createH(double d) throws MathArithmeticException { - int n = this.n; int k = (int) Math.ceil(n * d); - + int m = 2 * k - 1; double hDouble = k - n * d; if (hDouble >= 1) { throw new ArithmeticException("Could not "); } - + BigFraction h = null; try { @@ -340,8 +335,7 @@ public class KolmogorovSmirnovDistributi * 1/2 is sufficient to check: */ if (h.compareTo(BigFraction.ONE_HALF) == 1) { - Hdata[m - 1][0] = Hdata[m - 1][0].add(h.multiply(2).subtract(1) - .pow(m)); + Hdata[m - 1][0] = Hdata[m - 1][0].add(h.multiply(2).subtract(1).pow(m)); } /* @@ -350,7 +344,7 @@ public class KolmogorovSmirnovDistributi * put, so only division with (i - j + 1)! is needed in the elements * that have 1's. There is no need to calculate (i - j + 1)! and then * divide - small steps avoid overflows. - * + * * Note that i - j + 1 > 0 <=> i + 1 > j instead of j'ing all the way to * m. Also note that it is started at g = 2 because dividing by 1 isn't * really necessary. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java Sun Mar 27 16:32:01 2011 @@ -265,21 +265,21 @@ public abstract class AbstractFieldMatri public FieldMatrix preMultiply(final FieldMatrix m) { return m.multiply(this); } - + /** {@inheritDoc} */ public FieldMatrix power(final int p) { if (p < 0) { throw new IllegalArgumentException("p must be >= 0"); } - + if (!isSquare()) { throw new NonSquareMatrixException(getRowDimension(), getColumnDimension()); } - + if (p == 0) { return MatrixUtils.createFieldIdentityMatrix(this.getField(), this.getRowDimension()); } - + if (p == 1) { return this.copy(); } @@ -289,7 +289,7 @@ public abstract class AbstractFieldMatri /* * Only log_2(p) operations is used by doing as follows: * 5^214 = 5^128 * 5^64 * 5^16 * 5^4 * 5^2 - * + * * In general, the same approach is used for A^p. */ Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java Sun Mar 27 16:32:01 2011 @@ -149,64 +149,64 @@ public abstract class AbstractRealMatrix /** {@inheritDoc} */ public RealMatrix preMultiply(final RealMatrix m) { return m.multiply(this); - } + } /** {@inheritDoc} */ public RealMatrix power(final int p) { if (p < 0) { throw new IllegalArgumentException("p must be >= 0"); } - + if (!isSquare()) { throw new NonSquareMatrixException(getRowDimension(), getColumnDimension()); } - + if (p == 0) { return MatrixUtils.createRealIdentityMatrix(this.getRowDimension()); } - + if (p == 1) { return this.copy(); } final int power = p - 1; - + /* * Only log_2(p) operations is used by doing as follows: * 5^214 = 5^128 * 5^64 * 5^16 * 5^4 * 5^2 - * + * * In general, the same approach is used for A^p. - */ - - final char[] binaryRepresentation = Integer.toBinaryString(power).toCharArray(); + */ + + final char[] binaryRepresentation = Integer.toBinaryString(power).toCharArray(); final ArrayList nonZeroPositions = new ArrayList(); int maxI = -1; - - for (int i = 0; i < binaryRepresentation.length; ++i) { + + for (int i = 0; i < binaryRepresentation.length; ++i) { if (binaryRepresentation[i] == '1') { final int pos = binaryRepresentation.length - i - 1; nonZeroPositions.add(pos); - + // The positions are taken in turn, so maxI is only changed once if (maxI == -1) { maxI = pos; } } } - + RealMatrix[] results = new RealMatrix[maxI + 1]; results[0] = this.copy(); - + for (int i = 1; i <= maxI; ++i) { results[i] = results[i-1].multiply(results[i-1]); } - + RealMatrix result = this.copy(); - + for (Integer i : nonZeroPositions) { result = result.multiply(results[i]); - } - + } + return result; } Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldMatrix.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldMatrix.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldMatrix.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldMatrix.java Sun Mar 27 16:32:01 2011 @@ -116,16 +116,16 @@ public interface FieldMatrix preMultiply(FieldMatrix m); /** - * Returns the result multiplying this with itself p times. - * Depending on the type of the field elements, T, - * instability for high powers might occur. + * Returns the result multiplying this with itself p times. + * Depending on the type of the field elements, T, + * instability for high powers might occur. * @param p raise this to power p * @return this^p * @throws IllegalArgumentException if p < 0 * NonSquareMatrixException if the matrix is not square */ FieldMatrix power(final int p); - + /** * Returns matrix entries as a two-dimensional array. * Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealMatrix.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealMatrix.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealMatrix.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealMatrix.java Sun Mar 27 16:32:01 2011 @@ -98,10 +98,10 @@ public interface RealMatrix extends AnyM * if rowDimension(this) != columnDimension(m) */ RealMatrix preMultiply(RealMatrix m); - + /** - * Returns the result multiplying this with itself p times. - * Depending on the underlying storage, instability for high powers might occur. + * Returns the result multiplying this with itself p times. + * Depending on the underlying storage, instability for high powers might occur. * @param p raise this to power p * @return this^p * @throws IllegalArgumentException if p < 0 Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java Sun Mar 27 16:32:01 2011 @@ -826,19 +826,26 @@ public class CMAESOptimizer extends private class FitnessFunction { /** Determines the penalty for boundary violations */ - private double valueRange = 1.0; + private double valueRange; /** * Flag indicating whether the objective variables are forced into their * bounds if defined */ - private boolean isRepairMode = true; + private boolean isRepairMode; + + /** Simple constructor. + */ + public FitnessFunction() { + valueRange = 1.0; + isRepairMode = true; + } /** * @param x * Original objective variables. * @return Normalized objective variables. */ - private double[] encode(final double[] x) { + public double[] encode(final double[] x) { if (boundaries == null) return x; double[] res = new double[x.length]; @@ -854,7 +861,7 @@ public class CMAESOptimizer extends * Normalized objective variables. * @return Original objective variables. */ - private double[] decode(final double[] x) { + public double[] decode(final double[] x) { if (boundaries == null) return x; double[] res = new double[x.length]; @@ -870,7 +877,7 @@ public class CMAESOptimizer extends * Normalized objective variables. * @return Objective value + penalty for violated bounds. */ - private double value(final double[] point) { + public double value(final double[] point) { double value; if (boundaries != null && isRepairMode) { double[] repaired = repair(point); @@ -888,7 +895,7 @@ public class CMAESOptimizer extends * Normalized objective variables. * @return True if in bounds */ - private boolean isFeasible(final double[] x) { + public boolean isFeasible(final double[] x) { if (boundaries == null) return true; for (int i = 0; i < x.length; i++) { @@ -904,7 +911,7 @@ public class CMAESOptimizer extends * @param valueRange * Adjusts the penalty computation. */ - private void setValueRange(double valueRange) { + public void setValueRange(double valueRange) { this.valueRange = valueRange; } Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Beta.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Beta.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Beta.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Beta.java Sun Mar 27 16:32:01 2011 @@ -45,7 +45,6 @@ public class Beta { * @return the regularized beta function I(x, a, b). * @throws org.apache.commons.math.exception.MaxCountExceededException * if the algorithm fails to converge. - * @throws MathException if the algorithm fails to converge. */ public static double regularizedBeta(double x, double a, double b) { return regularizedBeta(x, a, b, DEFAULT_EPSILON, Integer.MAX_VALUE); Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Gamma.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Gamma.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Gamma.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Gamma.java Sun Mar 27 16:32:01 2011 @@ -191,7 +191,7 @@ public class Gamma { * @param a the a parameter. * @param x the value. * @return the regularized gamma function Q(a, x) - * @throws MathException if the algorithm fails to converge. + * @throws MaxCountExceededException if the algorithm fails to converge. */ public static double regularizedGammaQ(double a, double x) { return regularizedGammaQ(a, x, DEFAULT_EPSILON, Integer.MAX_VALUE); Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java Sun Mar 27 16:32:01 2011 @@ -100,12 +100,12 @@ public class KMeansPlusPlusClusterer> clusters = chooseInitialCenters(points, k, random); assignPointsToClusters(clusters, points); Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/MannWhitneyUTestImpl.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/MannWhitneyUTestImpl.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/MannWhitneyUTestImpl.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/MannWhitneyUTestImpl.java Sun Mar 27 16:32:01 2011 @@ -30,6 +30,8 @@ import org.apache.commons.math.util.Fast * @version $Revision$ $Date$ */ public class MannWhitneyUTestImpl implements MannWhitneyUTest { + + /** Ranking algorithm. */ private NaturalRanking naturalRanking; /** @@ -59,8 +61,8 @@ public class MannWhitneyUTestImpl implem /** * Ensures that the provided arrays fulfills the assumptions. * - * @param x - * @param y + * @param x first sample + * @param y second sample * @throws IllegalArgumentException * if assumptions are not met */ @@ -85,7 +87,12 @@ public class MannWhitneyUTestImpl implem } } - private double[] concatinateSamples(final double[] x, final double[] y) { + /** Concatenate the samples into one array. + * @param x first sample + * @param y second sample + * @return concatenated array + */ + private double[] concatenateSamples(final double[] x, final double[] y) { final double[] z = new double[x.length + y.length]; System.arraycopy(x, 0, z, 0, x.length); @@ -110,7 +117,7 @@ public class MannWhitneyUTestImpl implem ensureDataConformance(x, y); - final double[] z = concatinateSamples(x, y); + final double[] z = concatenateSamples(x, y); final double[] ranks = naturalRanking.rank(z); double sumRankX = 0; Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/WilcoxonSignedRankTestImpl.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/WilcoxonSignedRankTestImpl.java?rev=1085981&r1=1085980&r2=1085981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/WilcoxonSignedRankTestImpl.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/WilcoxonSignedRankTestImpl.java Sun Mar 27 16:32:01 2011 @@ -29,6 +29,8 @@ import org.apache.commons.math.util.Fast * @version $Revision$ $Date$ */ public class WilcoxonSignedRankTestImpl implements WilcoxonSignedRankTest { + + /** Ranking algorithm. */ private NaturalRanking naturalRanking; /** @@ -58,8 +60,8 @@ public class WilcoxonSignedRankTestImpl /** * Ensures that the provided arrays fulfills the assumptions. * - * @param x - * @param y + * @param x first sample + * @param y second sample * @throws IllegalArgumentException * if assumptions are not met */ @@ -87,13 +89,11 @@ public class WilcoxonSignedRankTestImpl /** * Calculates y[i] - x[i] for all i * - * @param x - * @param y - * @throws IllegalArgumentException - * if assumptions are not met + * @param x first sample + * @param y second sample + * @return z = y - x */ - private double[] calculateDifferences(final double[] x, final double[] y) - throws IllegalArgumentException { + private double[] calculateDifferences(final double[] x, final double[] y) { final double[] z = new double[x.length]; @@ -107,7 +107,8 @@ public class WilcoxonSignedRankTestImpl /** * Calculates |z[i]| for all i * - * @param z + * @param z sample + * @return |z| * @throws IllegalArgumentException * if assumptions are not met */