fixed various errors and warnings detected by checkstyle and findbugs
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@729291 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0e1654b627
commit
17a35b2e8c
|
@ -27,14 +27,14 @@
|
|||
<!-- which already know about limited precision of the double numbers -->
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.analysis.BrentSolver" />
|
||||
<Method name="solve" params="double,double,double,double,double,double" returns="double" />
|
||||
<Method name="solve" params="UnivariateRealFunction,double,double,double,double,double,double" returns="double" />
|
||||
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.analysis.MullerSolver" />
|
||||
<Or>
|
||||
<Method name="solve" params="double,double" returns="double" />
|
||||
<Method name="solve2" params="double,double" returns="double" />
|
||||
<Method name="solve" params="UnivariateRealFunction,double,double" returns="double" />
|
||||
<Method name="solve2" params="UnivariateRealFunction,double,double" returns="double" />
|
||||
</Or>
|
||||
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
|
||||
</Match>
|
||||
|
@ -79,7 +79,7 @@
|
|||
</Match>
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.util.ResizableDoubleArray"/>
|
||||
<Method name="getValues" params="" returns="double[]" />
|
||||
<Method name="getInternalValues" params="" returns="double[]" />
|
||||
<Bug pattern="EI_EXPOSE_REP" />
|
||||
</Match>
|
||||
<Match>
|
||||
|
|
|
@ -193,6 +193,7 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @return built exception
|
||||
*/
|
||||
public static ArithmeticException createArithmeticException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
|
@ -214,6 +215,7 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @return built exception
|
||||
*/
|
||||
public static ArrayIndexOutOfBoundsException createArrayIndexOutOfBoundsException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
|
@ -235,6 +237,7 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @return built exception
|
||||
*/
|
||||
public static EOFException createEOFException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
|
@ -260,6 +263,7 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* with Java 6.</p>
|
||||
* @param rootCause the exception or error that caused this exception
|
||||
* to be thrown.
|
||||
* @return built exception
|
||||
*/
|
||||
public static IOException createIOException(final Throwable rootCause) {
|
||||
IOException ioe = new IOException(rootCause.getLocalizedMessage());
|
||||
|
@ -272,6 +276,7 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @return built exception
|
||||
*/
|
||||
public static IllegalArgumentException createIllegalArgumentException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
|
@ -293,6 +298,7 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @return built exception
|
||||
*/
|
||||
public static IllegalStateException createIllegalStateException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
|
@ -314,6 +320,7 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @return built exception
|
||||
*/
|
||||
public static ConcurrentModificationException createConcurrentModificationException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
|
@ -335,6 +342,7 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @return built exception
|
||||
*/
|
||||
public static NoSuchElementException createNoSuchElementException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
|
@ -358,6 +366,7 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @param offset offset at which error occurred
|
||||
* @return built exception
|
||||
*/
|
||||
public static ParseException createParseException(final String pattern,
|
||||
final Object[] arguments,
|
||||
|
|
|
@ -141,6 +141,7 @@ public class BrentSolver extends UnivariateRealSolverImpl {
|
|||
* signs. An <code>IllegalArgumentException</code> is thrown if this is not
|
||||
* the case.</p>
|
||||
*
|
||||
* @param f the function to solve
|
||||
* @param min the lower bound for the interval.
|
||||
* @param max the upper bound for the interval.
|
||||
* @return the value where the function is zero
|
||||
|
|
|
@ -264,6 +264,7 @@ public class MullerSolver extends UnivariateRealSolverImpl {
|
|||
* <p>
|
||||
* The formulas here do not use divided differences directly.</p>
|
||||
*
|
||||
* @param f the function to solve
|
||||
* @param min the lower bound for the interval
|
||||
* @param max the upper bound for the interval
|
||||
* @return the point at which the function value is zero
|
||||
|
|
|
@ -72,6 +72,7 @@ public class NewtonSolver extends UnivariateRealSolverImpl {
|
|||
/**
|
||||
* Find a zero near the midpoint of <code>min</code> and <code>max</code>.
|
||||
*
|
||||
* @param f the function to solve
|
||||
* @param min the lower bound for the interval
|
||||
* @param max the upper bound for the interval
|
||||
* @return the value where the function is zero
|
||||
|
@ -89,6 +90,7 @@ public class NewtonSolver extends UnivariateRealSolverImpl {
|
|||
/**
|
||||
* Find a zero near the value <code>startValue</code>.
|
||||
*
|
||||
* @param f the function to solve
|
||||
* @param min the lower bound for the interval (ignored).
|
||||
* @param max the upper bound for the interval (ignored).
|
||||
* @param startValue the start value to use.
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
* 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.
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
* 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.
|
||||
|
@ -28,9 +28,14 @@ import org.apache.commons.math.MathRuntimeException;
|
|||
*/
|
||||
public class ZipfDistributionImpl extends AbstractIntegerDistribution
|
||||
implements ZipfDistribution, Serializable {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = -140627372283420404L;
|
||||
|
||||
/** Number of elements. */
|
||||
private int numberOfElements;
|
||||
|
||||
/** Exponent parameter of the distribution. */
|
||||
private double exponent;
|
||||
|
||||
/**
|
||||
|
@ -38,8 +43,8 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
|
|||
* exponent. Both values must be positive; otherwise an
|
||||
* <code>IllegalArgumentException</code> is thrown.
|
||||
*
|
||||
* @param n the number of elements
|
||||
* @param s the exponent
|
||||
* @param numberOfElements the number of elements
|
||||
* @param exponent the exponent
|
||||
* @exception IllegalArgumentException if n ≤ 0 or s ≤ 0.0
|
||||
*/
|
||||
public ZipfDistributionImpl(final int numberOfElements, final double exponent)
|
||||
|
|
|
@ -16,5 +16,10 @@
|
|||
*/
|
||||
package org.apache.commons.math.genetics;
|
||||
|
||||
public interface Fitness extends Comparable {
|
||||
/**
|
||||
* Interface used to compare chromosomes.
|
||||
* @version $Revision$ $Date$
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface Fitness extends Comparable<Fitness> {
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ public class GeneticAlgorithm {
|
|||
/**
|
||||
* <p>Evolve the given population into the next generation.</p>
|
||||
* <p><ol>
|
||||
* <li>Get nextGeneration polulation to fill from <code>current</code>
|
||||
* <li>Get nextGeneration population to fill from <code>current</code>
|
||||
* generation, using its nextGeneration method</li>
|
||||
* <li>Loop until new generation is filled:</li>
|
||||
* <ul><li>Apply configured SelectionPolicy to select a pair of parents
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<html>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<!-- $Revision$ -->
|
||||
<body>
|
||||
<p>
|
||||
This package provides basic genetic algorithms components.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -76,7 +76,6 @@ public interface DecompositionSolver extends Serializable {
|
|||
boolean isNonSingular();
|
||||
|
||||
/** Get the inverse (or pseudo-inverse) of the decomposed matrix.
|
||||
* @param decomposition decomposition of the matrix A
|
||||
* @return inverse matrix
|
||||
* @throws InvalidMatrixException if decomposed matrix is singular
|
||||
*/
|
||||
|
|
|
@ -186,8 +186,8 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
* Calculates the eigen decomposition of the given tridiagonal symmetric matrix.
|
||||
* <p>Calling this constructor is equivalent to first call the no-arguments
|
||||
* constructor and then call {@link #decompose(double[], double[])}.</p>
|
||||
* @param main the main diagonal of the matrix
|
||||
* @param secondary the secondary diagonal of the matrix
|
||||
* @param main the main diagonal of the matrix (will be copied)
|
||||
* @param secondary the secondary diagonal of the matrix (will be copied)
|
||||
* @param splitTolerance tolerance on the off-diagonal elements relative to the
|
||||
* geometric mean to split the tridiagonal matrix (a suggested value is
|
||||
* {@link MathUtils#SAFE_MIN})
|
||||
|
@ -198,8 +198,8 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
final double splitTolerance)
|
||||
throws InvalidMatrixException {
|
||||
|
||||
this.main = main;
|
||||
this.secondary = secondary;
|
||||
this.main = main.clone();
|
||||
this.secondary = secondary.clone();
|
||||
transformer = null;
|
||||
|
||||
// pre-compute some elements
|
||||
|
@ -365,7 +365,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
if (eigenvectors == null) {
|
||||
findEigenVectors();
|
||||
}
|
||||
return new Solver(realEigenvalues, eigenvectors);
|
||||
return new Solver(realEigenvalues, imagEigenvalues, eigenvectors);
|
||||
}
|
||||
|
||||
/** Specialized solver. */
|
||||
|
@ -374,20 +374,26 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = -8965845906036558410L;
|
||||
|
||||
/** Eigenvalues. */
|
||||
private final double[] eigenvalues;
|
||||
/** Real part of the realEigenvalues. */
|
||||
private double[] realEigenvalues;
|
||||
|
||||
/** Imaginary part of the realEigenvalues. */
|
||||
private double[] imagEigenvalues;
|
||||
|
||||
/** Eigenvectors. */
|
||||
private final RealVectorImpl[] eigenvectors;
|
||||
|
||||
/**
|
||||
* Build a solver from decomposed matrix.
|
||||
* @param realEigenvalues realEigenvalues
|
||||
* @param realEigenvalues real parts of the eigenvalues
|
||||
* @param imagEigenvalues imaginary parts of the eigenvalues
|
||||
* @param eigenvectors eigenvectors
|
||||
*/
|
||||
private Solver(final double[] eigenvalues, final RealVectorImpl[] eigenvectors) {
|
||||
this.eigenvalues = eigenvalues;
|
||||
this.eigenvectors = eigenvectors;
|
||||
private Solver(final double[] realEigenvalues, final double[] imagEigenvalues,
|
||||
final RealVectorImpl[] eigenvectors) {
|
||||
this.realEigenvalues = realEigenvalues;
|
||||
this.imagEigenvalues = imagEigenvalues;
|
||||
this.eigenvectors = eigenvectors;
|
||||
}
|
||||
|
||||
/** Solve the linear equation A × X = B for symmetric matrices A.
|
||||
|
@ -405,7 +411,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
throw new SingularMatrixException();
|
||||
}
|
||||
|
||||
final int m = eigenvalues.length;
|
||||
final int m = realEigenvalues.length;
|
||||
if (b.length != m) {
|
||||
throw new IllegalArgumentException("constant vector has wrong length");
|
||||
}
|
||||
|
@ -414,7 +420,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
for (int i = 0; i < m; ++i) {
|
||||
final RealVectorImpl v = eigenvectors[i];
|
||||
final double[] vData = v.getDataRef();
|
||||
final double s = v.dotProduct(b) / eigenvalues[i];
|
||||
final double s = v.dotProduct(b) / realEigenvalues[i];
|
||||
for (int j = 0; j < m; ++j) {
|
||||
bp[j] += s * vData[j];
|
||||
}
|
||||
|
@ -439,7 +445,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
throw new SingularMatrixException();
|
||||
}
|
||||
|
||||
final int m = eigenvalues.length;
|
||||
final int m = realEigenvalues.length;
|
||||
if (b.getDimension() != m) {
|
||||
throw new IllegalArgumentException("constant vector has wrong length");
|
||||
}
|
||||
|
@ -448,7 +454,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
for (int i = 0; i < m; ++i) {
|
||||
final RealVectorImpl v = eigenvectors[i];
|
||||
final double[] vData = v.getDataRef();
|
||||
final double s = v.dotProduct(b) / eigenvalues[i];
|
||||
final double s = v.dotProduct(b) / realEigenvalues[i];
|
||||
for (int j = 0; j < m; ++j) {
|
||||
bp[j] += s * vData[j];
|
||||
}
|
||||
|
@ -473,7 +479,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
throw new SingularMatrixException();
|
||||
}
|
||||
|
||||
final int m = eigenvalues.length;
|
||||
final int m = realEigenvalues.length;
|
||||
if (b.getRowDimension() != m) {
|
||||
throw new IllegalArgumentException("Incorrect row dimension");
|
||||
}
|
||||
|
@ -488,7 +494,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
for (int j = 0; j < m; ++j) {
|
||||
s += v.getEntry(j) * b.getEntry(j, k);
|
||||
}
|
||||
s /= eigenvalues[i];
|
||||
s /= realEigenvalues[i];
|
||||
for (int j = 0; j < m; ++j) {
|
||||
bp[j][k] += s * vData[j];
|
||||
}
|
||||
|
@ -504,8 +510,8 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
* @return true if the decomposed matrix is non-singular
|
||||
*/
|
||||
public boolean isNonSingular() {
|
||||
for (double lambda : eigenvalues) {
|
||||
if (lambda == 0) {
|
||||
for (int i = 0; i < realEigenvalues.length; ++i) {
|
||||
if ((realEigenvalues[i] == 0) && (imagEigenvalues[i] == 0)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -523,7 +529,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
throw new SingularMatrixException();
|
||||
}
|
||||
|
||||
final int m = eigenvalues.length;
|
||||
final int m = realEigenvalues.length;
|
||||
final double[][] invData = new double[m][m];
|
||||
|
||||
for (int i = 0; i < m; ++i) {
|
||||
|
@ -532,7 +538,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
double invIJ = 0;
|
||||
for (int k = 0; k < m; ++k) {
|
||||
final double[] vK = eigenvectors[k].getDataRef();
|
||||
invIJ += vK[i] * vK[j] / eigenvalues[k];
|
||||
invIJ += vK[i] * vK[j] / realEigenvalues[k];
|
||||
}
|
||||
invI[j] = invIJ;
|
||||
}
|
||||
|
@ -818,18 +824,12 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
throws InvalidMatrixException {
|
||||
|
||||
// check decomposed matrix data range
|
||||
final int fourN1 = 4 * (n - 1);
|
||||
double sumDiag = 0;
|
||||
double sumOffDiag = 0;
|
||||
for (int i = 0; i < n - 1; ++i) {
|
||||
final int fourI = 4 * i;
|
||||
final double qi = work[fourI];
|
||||
final double ei = work[fourI + 2];
|
||||
sumDiag += qi;
|
||||
sumOffDiag += ei;
|
||||
}
|
||||
final double qi = work[fourN1];
|
||||
sumDiag += qi;
|
||||
|
||||
if (sumOffDiag == 0) {
|
||||
// matrix is already diagonal
|
||||
|
|
|
@ -44,7 +44,7 @@ public interface QRDecomposition extends Serializable {
|
|||
* <p>R is an upper-triangular matrix</p>
|
||||
* @return the R matrix
|
||||
*/
|
||||
RealMatrix getR() throws IllegalStateException;
|
||||
RealMatrix getR();
|
||||
|
||||
/**
|
||||
* Returns the matrix Q of the decomposition.
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package org.apache.commons.math.linear;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Interface defining a real-valued matrix with basic algebraic operations.
|
||||
* <p>
|
||||
|
@ -25,7 +27,7 @@ package org.apache.commons.math.linear;
|
|||
*
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
public interface RealMatrix {
|
||||
public interface RealMatrix extends Serializable {
|
||||
|
||||
/**
|
||||
* Create a new RealMatrix of the same type as the instance with the supplied
|
||||
|
@ -33,6 +35,7 @@ public interface RealMatrix {
|
|||
*
|
||||
* @param rowDimension the number of rows in the new matrix
|
||||
* @param columnDimension the number of columns in the new matrix
|
||||
* @return a new matrix of the same type as the instance
|
||||
* @throws IllegalArgumentException if row or column dimension is not positive
|
||||
* @since 2.0
|
||||
*/
|
||||
|
|
|
@ -52,10 +52,10 @@ public class SingularValueDecompositionImpl implements SingularValueDecompositio
|
|||
private double[] secondaryBidiagonal;
|
||||
|
||||
/** Main diagonal of the tridiagonal matrix. */
|
||||
double[] mainTridiagonal;
|
||||
private double[] mainTridiagonal;
|
||||
|
||||
/** Secondary diagonal of the tridiagonal matrix. */
|
||||
double[] secondaryTridiagonal;
|
||||
private double[] secondaryTridiagonal;
|
||||
|
||||
/** Eigen decomposition of the tridiagonal matrix. */
|
||||
private EigenDecomposition eigenDecomposition;
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
*/
|
||||
|
||||
package org.apache.commons.math.random;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Random data generation utilities.
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
public interface RandomData {
|
||||
public interface RandomData extends Serializable {
|
||||
/**
|
||||
* Generates a random string of hex characters of length
|
||||
* <code>len</code>.
|
||||
|
|
|
@ -164,7 +164,7 @@ public class Mean extends AbstractStorelessUnivariateStatistic
|
|||
return Double.NaN;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Mean copy() {
|
||||
|
|
|
@ -131,7 +131,7 @@ public class Max extends AbstractStorelessUnivariateStatistic {
|
|||
return max;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Max copy() {
|
||||
|
|
|
@ -133,7 +133,7 @@ public class Min extends AbstractStorelessUnivariateStatistic implements Seriali
|
|||
return min;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Min copy() {
|
||||
|
|
|
@ -248,7 +248,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
|
|||
quantile = p;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Percentile copy() {
|
||||
|
|
|
@ -123,7 +123,7 @@ public class Product extends AbstractStorelessUnivariateStatistic implements Ser
|
|||
return product;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Product copy() {
|
||||
|
|
|
@ -123,7 +123,7 @@ public class Sum extends AbstractStorelessUnivariateStatistic implements Seriali
|
|||
return sum;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Sum copy() {
|
||||
|
|
|
@ -134,7 +134,7 @@ public class SumOfLogs extends AbstractStorelessUnivariateStatistic implements S
|
|||
return sumLog;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public SumOfLogs copy() {
|
||||
|
|
|
@ -123,7 +123,7 @@ public class SumOfSquares extends AbstractStorelessUnivariateStatistic implement
|
|||
return sumSq;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public SumOfSquares copy() {
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.commons.math.complex.Complex;
|
|||
*/
|
||||
public class FastFourierTransformer implements Serializable {
|
||||
|
||||
/** serializable version identifier */
|
||||
/** Serializable version identifier. */
|
||||
static final long serialVersionUID = 5138259215438106000L;
|
||||
|
||||
/** array of the roots of unity */
|
||||
|
@ -566,16 +566,17 @@ public class FastFourierTransformer implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Performs a multi-dimensional Fourier transform on a given
|
||||
* array, using {@link #inversetransform2(Complex[])} and
|
||||
* Performs a multi-dimensional Fourier transform on a given array.
|
||||
* Use {@link #inversetransform2(Complex[])} and
|
||||
* {@link #transform2(Complex[])} in a row-column implementation
|
||||
* in any number of dimensions with O(N×log(N)) complexity with
|
||||
* N=n<sub>1</sub>×n<sub>2</sub>×n<sub>3</sub>×...×n<sub>d</sub>,
|
||||
* n<sub>x</sub>=number of elements in dimension x,
|
||||
* and d=total number of dimensions.
|
||||
*
|
||||
* @param forward inverseTransform2 is preformed if this is false
|
||||
* @param mdca Multi-Dimensional Complex Array id est Complex[][][][]
|
||||
* @param forward inverseTransform2 is preformed if this is false
|
||||
* @return transform of mdca as a Multi-Dimensional Complex Array id est Complex[][][][]
|
||||
* @throws MathException if any dimension is not a power of two
|
||||
*/
|
||||
public Object mdfft(Object mdca, boolean forward) throws MathException {
|
||||
|
@ -589,6 +590,15 @@ public class FastFourierTransformer implements Serializable {
|
|||
return mdcm.getArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs one dimension of a multi-dimensional Fourier transform.
|
||||
*
|
||||
* @param mdcm input matrix
|
||||
* @param forward inverseTransform2 is preformed if this is false
|
||||
* @param d index of the dimension to process
|
||||
* @param subVector recursion subvector
|
||||
* @throws MathException if any dimension is not a power of two
|
||||
*/
|
||||
private void mdfft(MultiDimensionalComplexMatrix mdcm, boolean forward,
|
||||
int d, int[] subVector) throws MathException {
|
||||
int[] dimensionSize = mdcm.getDimensionSizes();
|
||||
|
@ -629,19 +639,28 @@ public class FastFourierTransformer implements Serializable {
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* not designed for synchronized access
|
||||
/**
|
||||
* Complex matrix implementation.
|
||||
* Not designed for synchronized access
|
||||
* may eventually be replaced by jsr-83 of the java community process
|
||||
* http://jcp.org/en/jsr/detail?id=83
|
||||
* may require additional exception throws for other basic requirements.
|
||||
*/
|
||||
private class MultiDimensionalComplexMatrix implements Serializable,
|
||||
Cloneable {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = 0x564FCD47EBA8169BL;
|
||||
|
||||
|
||||
/** Size in all dimensions. */
|
||||
protected int[] dimensionSize = new int[1];
|
||||
|
||||
/** Storage array. */
|
||||
protected Object multiDimensionalComplexArray;
|
||||
|
||||
|
||||
/** Simple constructor.
|
||||
* @param multiDimensionalComplexArray array containing the matrix elements
|
||||
*/
|
||||
public MultiDimensionalComplexMatrix(Object
|
||||
multiDimensionalComplexArray) {
|
||||
this.multiDimensionalComplexArray = multiDimensionalComplexArray;
|
||||
|
@ -669,12 +688,16 @@ public class FastFourierTransformer implements Serializable {
|
|||
dimensionSize = newDimensionSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a matrix element.
|
||||
* @param vector indices of the element
|
||||
* @return matrix element
|
||||
*/
|
||||
public Complex get(int... vector) {
|
||||
if ((vector == null && dimensionSize.length > 1) ||
|
||||
vector.length != dimensionSize.length) {
|
||||
throw new IllegalArgumentException("Number of dimensions must "
|
||||
+ "match");
|
||||
(vector != null && vector.length != dimensionSize.length)) {
|
||||
throw new IllegalArgumentException("Number of dimensions must match");
|
||||
}
|
||||
|
||||
Object lastDimension = multiDimensionalComplexArray;
|
||||
|
@ -685,11 +708,16 @@ public class FastFourierTransformer implements Serializable {
|
|||
return (Complex) lastDimension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a matrix element.
|
||||
* @param magnitude magnitude of the element
|
||||
* @param vector indices of the element
|
||||
* @return the previous value
|
||||
*/
|
||||
public Complex set(Complex magnitude, int... vector) {
|
||||
if ((vector == null && dimensionSize.length > 1) ||
|
||||
vector.length != dimensionSize.length) {
|
||||
throw new IllegalArgumentException("Number of dimensions must "
|
||||
+ "match");
|
||||
(vector != null && vector.length != dimensionSize.length)) {
|
||||
throw new IllegalArgumentException("Number of dimensions must match");
|
||||
}
|
||||
|
||||
Object lastDimension = multiDimensionalComplexArray;
|
||||
|
@ -704,15 +732,24 @@ public class FastFourierTransformer implements Serializable {
|
|||
magnitude;
|
||||
return lastValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the size in all dimensions.
|
||||
* @return size in all dimensions
|
||||
*/
|
||||
public int[] getDimensionSizes() {
|
||||
return dimensionSize.clone();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the underlying storage array
|
||||
* @return underlying storage array
|
||||
*/
|
||||
public Object getArray() {
|
||||
return multiDimensionalComplexArray;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Object clone() {
|
||||
MultiDimensionalComplexMatrix mdcm =
|
||||
|
@ -722,8 +759,9 @@ public class FastFourierTransformer implements Serializable {
|
|||
return mdcm;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Copy contents of current array into mdcm.
|
||||
* @param mdcm array where to copy data
|
||||
*/
|
||||
private void clone(MultiDimensionalComplexMatrix mdcm) {
|
||||
int[] vector = new int[dimensionSize.length];
|
||||
|
|
|
@ -454,7 +454,7 @@ public class OpenIntToDoubleHashMap implements Serializable {
|
|||
public class Iterator {
|
||||
|
||||
/** Reference modification count. */
|
||||
final int referenceCount;
|
||||
private final int referenceCount;
|
||||
|
||||
/** Index of curent element. */
|
||||
private int current;
|
||||
|
|
|
@ -251,7 +251,7 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
* on original. Original may not be null; otherwise a NullPointerException
|
||||
* is thrown.
|
||||
*
|
||||
* @param original
|
||||
* @param original array to copy
|
||||
* @since 2.0
|
||||
*/
|
||||
public ResizableDoubleArray(ResizableDoubleArray original) {
|
||||
|
@ -846,18 +846,22 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
if (object instanceof ResizableDoubleArray == false) {
|
||||
return false;
|
||||
}
|
||||
boolean result = true;
|
||||
ResizableDoubleArray other = (ResizableDoubleArray) object;
|
||||
result = result && (other.initialCapacity == initialCapacity);
|
||||
result = result && (other.contractionCriteria == contractionCriteria);
|
||||
result = result && (other.expansionFactor == expansionFactor);
|
||||
result = result && (other.expansionMode == expansionMode);
|
||||
result = result && (other.numElements == numElements);
|
||||
result = result && (other.startIndex == startIndex);
|
||||
if (!result) {
|
||||
return false;
|
||||
} else {
|
||||
return Arrays.equals(internalArray, other.internalArray);
|
||||
synchronized(this) {
|
||||
synchronized(object) {
|
||||
boolean result = true;
|
||||
ResizableDoubleArray other = (ResizableDoubleArray) object;
|
||||
result = result && (other.initialCapacity == initialCapacity);
|
||||
result = result && (other.contractionCriteria == contractionCriteria);
|
||||
result = result && (other.expansionFactor == expansionFactor);
|
||||
result = result && (other.expansionMode == expansionMode);
|
||||
result = result && (other.numElements == numElements);
|
||||
result = result && (other.startIndex == startIndex);
|
||||
if (!result) {
|
||||
return false;
|
||||
} else {
|
||||
return Arrays.equals(internalArray, other.internalArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue