fixed a number of warnings identified by findbugs eclipse plugin version 1.3.9
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@790243 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1a5345519c
commit
63d0a79ce2
|
@ -43,6 +43,23 @@
|
|||
</Or>
|
||||
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.linear.EigenDecompositionImpl" />
|
||||
<Method name="computeShiftIncrement" params="int,int,int" returns="void" />
|
||||
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
|
||||
</Match>
|
||||
|
||||
<!-- The following equality test is intentional and needed for semantic purposes -->
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.geometry.Vector3D" />
|
||||
<Method name="equals" params="java.lang.Object" returns="boolean" />
|
||||
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.optimization.linear.LinearConstraint" />
|
||||
<Method name="equals" params="java.lang.Object" returns="boolean" />
|
||||
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
|
||||
</Match>
|
||||
|
||||
<!-- The following equality test is intentional and needed for rounding purposes -->
|
||||
<Match>
|
||||
|
|
|
@ -148,7 +148,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
|
|||
@Override
|
||||
protected boolean isSame(Chromosome another) {
|
||||
// type check
|
||||
if (! (another instanceof RandomKey))
|
||||
if (! (another instanceof RandomKey<?>))
|
||||
return false;
|
||||
RandomKey<?> anotherRk = (RandomKey<?>) another;
|
||||
// size check
|
||||
|
|
|
@ -37,7 +37,7 @@ public class RandomKeyMutation implements MutationPolicy {
|
|||
* {@link RandomKey} instance
|
||||
*/
|
||||
public Chromosome mutate(Chromosome original) {
|
||||
if (!(original instanceof RandomKey)) {
|
||||
if (!(original instanceof RandomKey<?>)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"RandomKeyMutation works only with RandomKeys, got " +
|
||||
original.getClass().getSimpleName());
|
||||
|
|
|
@ -181,7 +181,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
|
||||
/** {@inheritDoc} */
|
||||
public FieldVector<T> append(FieldVector<T> v) {
|
||||
if (v instanceof SparseFieldVector) {
|
||||
if (v instanceof SparseFieldVector<?>) {
|
||||
return append((SparseFieldVector<T>) v);
|
||||
} else {
|
||||
return append(v.toArray());
|
||||
|
@ -438,7 +438,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
/** {@inheritDoc} */
|
||||
public FieldMatrix<T> outerProduct(FieldVector<T> v)
|
||||
throws IllegalArgumentException {
|
||||
if(v instanceof SparseFieldVector)
|
||||
if(v instanceof SparseFieldVector<?>)
|
||||
return outerProduct((SparseFieldVector<T>)v);
|
||||
else
|
||||
return outerProduct(v.toArray());
|
||||
|
@ -513,7 +513,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
/** {@inheritDoc} */
|
||||
public FieldVector<T> subtract(FieldVector<T> v)
|
||||
throws IllegalArgumentException {
|
||||
if(v instanceof SparseFieldVector)
|
||||
if(v instanceof SparseFieldVector<?>)
|
||||
return subtract((SparseFieldVector<T>)v);
|
||||
else
|
||||
return subtract(v.toArray());
|
||||
|
@ -573,7 +573,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
|
||||
/** {@inheritDoc} */
|
||||
public FieldVector<T> add(FieldVector<T> v) throws IllegalArgumentException {
|
||||
if (v instanceof SparseFieldVector) {
|
||||
if (v instanceof SparseFieldVector<?>) {
|
||||
return add((SparseFieldVector<T>)v);
|
||||
} else {
|
||||
return add(v.toArray());
|
||||
|
|
|
@ -613,11 +613,8 @@ public class FastFourierTransformer implements Serializable {
|
|||
* 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;
|
||||
private static class MultiDimensionalComplexMatrix
|
||||
implements Cloneable {
|
||||
|
||||
/** Size in all dimensions. */
|
||||
protected int[] dimensionSize;
|
||||
|
|
|
@ -338,20 +338,20 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
* expansionCriteria
|
||||
*
|
||||
* @param expansionFactor factor to be checked
|
||||
* @param contractionCritera criteria to be checked
|
||||
* @param contractionCriteria criteria to be checked
|
||||
* @throws IllegalArgumentException if the contractionCriteria is less than
|
||||
* the expansionCriteria.
|
||||
*/
|
||||
protected void checkContractExpand(
|
||||
float contractionCritera,
|
||||
float contractionCriteria,
|
||||
float expansionFactor) {
|
||||
|
||||
if (contractionCritera < expansionFactor) {
|
||||
if (contractionCriteria < expansionFactor) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"contraction criteria ({0}) smaller than the expansion factor ({1}). 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",
|
||||
contractionCritera, expansionFactor);
|
||||
contractionCriteria, expansionFactor);
|
||||
}
|
||||
|
||||
if (contractionCriteria <= 1.0) {
|
||||
|
@ -365,7 +365,7 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
if (expansionFactor <= 1.0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"expansion factor smaller than one ({0})",
|
||||
contractionCriteria);
|
||||
expansionFactor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -648,8 +648,10 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
*/
|
||||
public void setContractionCriteria(float contractionCriteria) {
|
||||
checkContractExpand(contractionCriteria, getExpansionFactor());
|
||||
synchronized(this) {
|
||||
this.contractionCriteria = contractionCriteria;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -693,8 +695,10 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
public void setExpansionFactor(float expansionFactor) {
|
||||
checkContractExpand(getContractionCriteria(), expansionFactor);
|
||||
// The check above verifies that the expansion factor is > 1.0;
|
||||
synchronized(this) {
|
||||
this.expansionFactor = expansionFactor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>expansionMode</code>. The specified value must be one of
|
||||
|
@ -711,8 +715,10 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
expansionMode, MULTIPLICATIVE_MODE, "MULTIPLICATIVE_MODE",
|
||||
ADDITIVE_MODE, "ADDITIVE_MODE");
|
||||
}
|
||||
synchronized(this) {
|
||||
this.expansionMode = expansionMode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the initial capacity. Should only be invoked by constructors.
|
||||
|
@ -876,17 +882,15 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
* @since 2.0
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
public synchronized int hashCode() {
|
||||
int[] hashData = new int[7];
|
||||
hashData[0] = new Float(expansionFactor).hashCode();
|
||||
hashData[1] = new Float(contractionCriteria).hashCode();
|
||||
hashData[2] = expansionMode;
|
||||
synchronized(this) {
|
||||
hashData[3] = Arrays.hashCode(internalArray);
|
||||
hashData[4] = initialCapacity;
|
||||
hashData[5] = numElements;
|
||||
hashData[6] = startIndex;
|
||||
}
|
||||
return Arrays.hashCode(hashData);
|
||||
}
|
||||
|
||||
|
|
|
@ -793,18 +793,6 @@ public class LevenbergMarquardtEstimatorTest
|
|||
addMeasurement(new LocalMeasurement(x, y, w));
|
||||
}
|
||||
|
||||
public double getA() {
|
||||
return a.getEstimate();
|
||||
}
|
||||
|
||||
public double getB() {
|
||||
return b.getEstimate();
|
||||
}
|
||||
|
||||
public double getC() {
|
||||
return c.getEstimate();
|
||||
}
|
||||
|
||||
public double theoreticalValue(double x) {
|
||||
return ( (a.getEstimate() * x + b.getEstimate() ) * x + c.getEstimate());
|
||||
}
|
||||
|
|
|
@ -28,14 +28,12 @@ public class RandomKeyTest {
|
|||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testConstructor1() {
|
||||
@SuppressWarnings("unused")
|
||||
DummyRandomKey drk = new DummyRandomKey(new Double[] {0.2, 0.3, 1.2});
|
||||
new DummyRandomKey(new Double[] {0.2, 0.3, 1.2});
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testConstructor2() {
|
||||
@SuppressWarnings("unused")
|
||||
DummyRandomKey drk = new DummyRandomKey(new Double[] {0.2, 0.3, -0.2});
|
||||
new DummyRandomKey(new Double[] {0.2, 0.3, -0.2});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -549,50 +549,50 @@ public final class BlockFieldMatrixTest extends TestCase {
|
|||
// test submatrix accessors
|
||||
public void testGetSubMatrix() {
|
||||
FieldMatrix<Fraction> m = new BlockFieldMatrix<Fraction>(subTestData);
|
||||
checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0, false);
|
||||
checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3, false);
|
||||
checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3, false);
|
||||
checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 }, false);
|
||||
checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 }, false);
|
||||
checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 }, false);
|
||||
checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 }, false);
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4, true);
|
||||
checkGetSubMatrix(m, null, -1, 1, 2, 2, true);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 2, true);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4, true);
|
||||
checkGetSubMatrix(m, null, new int[] {}, new int[] { 0 }, true);
|
||||
checkGetSubMatrix(m, null, new int[] { 0 }, new int[] { 4 }, true);
|
||||
checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0);
|
||||
checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3);
|
||||
checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3);
|
||||
checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
|
||||
checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
|
||||
checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
|
||||
checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4);
|
||||
checkGetSubMatrix(m, null, -1, 1, 2, 2);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 2);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4);
|
||||
checkGetSubMatrix(m, null, new int[] {}, new int[] { 0 });
|
||||
checkGetSubMatrix(m, null, new int[] { 0 }, new int[] { 4 });
|
||||
}
|
||||
|
||||
private void checkGetSubMatrix(FieldMatrix<Fraction> m, Fraction[][] reference,
|
||||
int startRow, int endRow, int startColumn, int endColumn,
|
||||
boolean mustFail) {
|
||||
int startRow, int endRow, int startColumn, int endColumn) {
|
||||
try {
|
||||
FieldMatrix<Fraction> sub = m.getSubMatrix(startRow, endRow, startColumn, endColumn);
|
||||
if (reference != null) {
|
||||
assertEquals(new BlockFieldMatrix<Fraction>(reference), sub);
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGetSubMatrix(FieldMatrix<Fraction> m, Fraction[][] reference,
|
||||
int[] selectedRows, int[] selectedColumns,
|
||||
boolean mustFail) {
|
||||
int[] selectedRows, int[] selectedColumns) {
|
||||
try {
|
||||
FieldMatrix<Fraction> sub = m.getSubMatrix(selectedRows, selectedColumns);
|
||||
if (reference != null) {
|
||||
assertEquals(new BlockFieldMatrix<Fraction>(reference), sub);
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -621,57 +621,57 @@ public final class BlockFieldMatrixTest extends TestCase {
|
|||
|
||||
public void testCopySubMatrix() {
|
||||
FieldMatrix<Fraction> m = new BlockFieldMatrix<Fraction>(subTestData);
|
||||
checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0, false);
|
||||
checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3, false);
|
||||
checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3, false);
|
||||
checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 }, false);
|
||||
checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 }, false);
|
||||
checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 }, false);
|
||||
checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 }, false);
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0);
|
||||
checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3);
|
||||
checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3);
|
||||
checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
|
||||
checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
|
||||
checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
|
||||
checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
|
||||
checkCopy(m, null, 1, 0, 2, 4, true);
|
||||
checkCopy(m, null, -1, 1, 2, 2, true);
|
||||
checkCopy(m, null, 1, 0, 2, 2, true);
|
||||
checkCopy(m, null, 1, 0, 2, 4, true);
|
||||
checkCopy(m, null, new int[] {}, new int[] { 0 }, true);
|
||||
checkCopy(m, null, new int[] { 0 }, new int[] { 4 }, true);
|
||||
checkCopy(m, null, 1, 0, 2, 4);
|
||||
checkCopy(m, null, -1, 1, 2, 2);
|
||||
checkCopy(m, null, 1, 0, 2, 2);
|
||||
checkCopy(m, null, 1, 0, 2, 4);
|
||||
checkCopy(m, null, new int[] {}, new int[] { 0 });
|
||||
checkCopy(m, null, new int[] { 0 }, new int[] { 4 });
|
||||
}
|
||||
|
||||
private void checkCopy(FieldMatrix<Fraction> m, Fraction[][] reference,
|
||||
int startRow, int endRow, int startColumn, int endColumn,
|
||||
boolean mustFail) {
|
||||
int startRow, int endRow, int startColumn, int endColumn) {
|
||||
try {
|
||||
Fraction[][] sub = (reference == null) ?
|
||||
new Fraction[1][1] :
|
||||
new Fraction[reference.length][reference[0].length];
|
||||
m.copySubMatrix(startRow, endRow, startColumn, endColumn, sub);
|
||||
if (reference != null) {
|
||||
assertEquals(new BlockFieldMatrix<Fraction>(reference), new BlockFieldMatrix<Fraction>(sub));
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCopy(FieldMatrix<Fraction> m, Fraction[][] reference,
|
||||
int[] selectedRows, int[] selectedColumns,
|
||||
boolean mustFail) {
|
||||
int[] selectedRows, int[] selectedColumns) {
|
||||
try {
|
||||
Fraction[][] sub = (reference == null) ?
|
||||
new Fraction[1][1] :
|
||||
new Fraction[reference.length][reference[0].length];
|
||||
m.copySubMatrix(selectedRows, selectedColumns, sub);
|
||||
if (reference != null) {
|
||||
assertEquals(new BlockFieldMatrix<Fraction>(reference), new BlockFieldMatrix<Fraction>(sub));
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -476,50 +476,50 @@ public final class BlockRealMatrixTest extends TestCase {
|
|||
// test submatrix accessors
|
||||
public void testGetSubMatrix() {
|
||||
RealMatrix m = new BlockRealMatrix(subTestData);
|
||||
checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0, false);
|
||||
checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3, false);
|
||||
checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3, false);
|
||||
checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 }, false);
|
||||
checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 }, false);
|
||||
checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 }, false);
|
||||
checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 }, false);
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4, true);
|
||||
checkGetSubMatrix(m, null, -1, 1, 2, 2, true);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 2, true);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4, true);
|
||||
checkGetSubMatrix(m, null, new int[] {}, new int[] { 0 }, true);
|
||||
checkGetSubMatrix(m, null, new int[] { 0 }, new int[] { 4 }, true);
|
||||
checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0);
|
||||
checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3);
|
||||
checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3);
|
||||
checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
|
||||
checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
|
||||
checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
|
||||
checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4);
|
||||
checkGetSubMatrix(m, null, -1, 1, 2, 2);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 2);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4);
|
||||
checkGetSubMatrix(m, null, new int[] {}, new int[] { 0 });
|
||||
checkGetSubMatrix(m, null, new int[] { 0 }, new int[] { 4 });
|
||||
}
|
||||
|
||||
private void checkGetSubMatrix(RealMatrix m, double[][] reference,
|
||||
int startRow, int endRow, int startColumn, int endColumn,
|
||||
boolean mustFail) {
|
||||
int startRow, int endRow, int startColumn, int endColumn) {
|
||||
try {
|
||||
RealMatrix sub = m.getSubMatrix(startRow, endRow, startColumn, endColumn);
|
||||
if (reference != null) {
|
||||
assertEquals(new BlockRealMatrix(reference), sub);
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGetSubMatrix(RealMatrix m, double[][] reference,
|
||||
int[] selectedRows, int[] selectedColumns,
|
||||
boolean mustFail) {
|
||||
int[] selectedRows, int[] selectedColumns) {
|
||||
try {
|
||||
RealMatrix sub = m.getSubMatrix(selectedRows, selectedColumns);
|
||||
if (reference != null) {
|
||||
assertEquals(new BlockRealMatrix(reference), sub);
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -546,57 +546,57 @@ public final class BlockRealMatrixTest extends TestCase {
|
|||
|
||||
public void testCopySubMatrix() {
|
||||
RealMatrix m = new BlockRealMatrix(subTestData);
|
||||
checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0, false);
|
||||
checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3, false);
|
||||
checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3, false);
|
||||
checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 }, false);
|
||||
checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 }, false);
|
||||
checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 }, false);
|
||||
checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 }, false);
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0);
|
||||
checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3);
|
||||
checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3);
|
||||
checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
|
||||
checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
|
||||
checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
|
||||
checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
|
||||
checkCopy(m, null, 1, 0, 2, 4, true);
|
||||
checkCopy(m, null, -1, 1, 2, 2, true);
|
||||
checkCopy(m, null, 1, 0, 2, 2, true);
|
||||
checkCopy(m, null, 1, 0, 2, 4, true);
|
||||
checkCopy(m, null, new int[] {}, new int[] { 0 }, true);
|
||||
checkCopy(m, null, new int[] { 0 }, new int[] { 4 }, true);
|
||||
checkCopy(m, null, 1, 0, 2, 4);
|
||||
checkCopy(m, null, -1, 1, 2, 2);
|
||||
checkCopy(m, null, 1, 0, 2, 2);
|
||||
checkCopy(m, null, 1, 0, 2, 4);
|
||||
checkCopy(m, null, new int[] {}, new int[] { 0 });
|
||||
checkCopy(m, null, new int[] { 0 }, new int[] { 4 });
|
||||
}
|
||||
|
||||
private void checkCopy(RealMatrix m, double[][] reference,
|
||||
int startRow, int endRow, int startColumn, int endColumn,
|
||||
boolean mustFail) {
|
||||
int startRow, int endRow, int startColumn, int endColumn) {
|
||||
try {
|
||||
double[][] sub = (reference == null) ?
|
||||
new double[1][1] :
|
||||
new double[reference.length][reference[0].length];
|
||||
m.copySubMatrix(startRow, endRow, startColumn, endColumn, sub);
|
||||
if (reference != null) {
|
||||
assertEquals(new BlockRealMatrix(reference), new BlockRealMatrix(sub));
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCopy(RealMatrix m, double[][] reference,
|
||||
int[] selectedRows, int[] selectedColumns,
|
||||
boolean mustFail) {
|
||||
int[] selectedRows, int[] selectedColumns) {
|
||||
try {
|
||||
double[][] sub = (reference == null) ?
|
||||
new double[1][1] :
|
||||
new double[reference.length][reference[0].length];
|
||||
m.copySubMatrix(selectedRows, selectedColumns, sub);
|
||||
if (reference != null) {
|
||||
assertEquals(new BlockRealMatrix(reference), new BlockRealMatrix(sub));
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -293,13 +293,13 @@ public class EigenDecompositionImplTest extends TestCase {
|
|||
boolean found = false;
|
||||
int i = 0;
|
||||
while (!found && i < searchMatrix.getColumnDimension()) {
|
||||
double multiplier = 1d;
|
||||
double multiplier = 1.0;
|
||||
boolean matching = true;
|
||||
int j = 0;
|
||||
while (matching && j < searchMatrix.getRowDimension()) {
|
||||
double colEntry = searchMatrix.getEntry(j, i);
|
||||
// Use the first entry where both are non-zero as scalar
|
||||
if (multiplier == 1d && Math.abs(colEntry) > 1E-14
|
||||
if (Math.abs(multiplier - 1.0) <= Math.ulp(1.0) && Math.abs(colEntry) > 1E-14
|
||||
&& Math.abs(column[j]) > 1e-14) {
|
||||
multiplier = colEntry / column[j];
|
||||
}
|
||||
|
|
|
@ -363,50 +363,50 @@ public final class FieldMatrixImplTest extends TestCase {
|
|||
// test submatrix accessors
|
||||
public void testGetSubMatrix() {
|
||||
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(subTestData);
|
||||
checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0, false);
|
||||
checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3, false);
|
||||
checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3, false);
|
||||
checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 }, false);
|
||||
checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 }, false);
|
||||
checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 }, false);
|
||||
checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 }, false);
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4, true);
|
||||
checkGetSubMatrix(m, null, -1, 1, 2, 2, true);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 2, true);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4, true);
|
||||
checkGetSubMatrix(m, null, new int[] {}, new int[] { 0 }, true);
|
||||
checkGetSubMatrix(m, null, new int[] { 0 }, new int[] { 4 }, true);
|
||||
checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0);
|
||||
checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3);
|
||||
checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3);
|
||||
checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
|
||||
checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
|
||||
checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
|
||||
checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4);
|
||||
checkGetSubMatrix(m, null, -1, 1, 2, 2);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 2);
|
||||
checkGetSubMatrix(m, null, 1, 0, 2, 4);
|
||||
checkGetSubMatrix(m, null, new int[] {}, new int[] { 0 });
|
||||
checkGetSubMatrix(m, null, new int[] { 0 }, new int[] { 4 });
|
||||
}
|
||||
|
||||
private void checkGetSubMatrix(FieldMatrix<Fraction> m, Fraction[][] reference,
|
||||
int startRow, int endRow, int startColumn, int endColumn,
|
||||
boolean mustFail) {
|
||||
int startRow, int endRow, int startColumn, int endColumn) {
|
||||
try {
|
||||
FieldMatrix<Fraction> sub = m.getSubMatrix(startRow, endRow, startColumn, endColumn);
|
||||
if (reference != null) {
|
||||
assertEquals(new Array2DRowFieldMatrix<Fraction>(reference), sub);
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGetSubMatrix(FieldMatrix<Fraction> m, Fraction[][] reference,
|
||||
int[] selectedRows, int[] selectedColumns,
|
||||
boolean mustFail) {
|
||||
int[] selectedRows, int[] selectedColumns) {
|
||||
try {
|
||||
FieldMatrix<Fraction> sub = m.getSubMatrix(selectedRows, selectedColumns);
|
||||
if (reference != null) {
|
||||
assertEquals(new Array2DRowFieldMatrix<Fraction>(reference), sub);
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -414,57 +414,57 @@ public final class FieldMatrixImplTest extends TestCase {
|
|||
|
||||
public void testCopySubMatrix() {
|
||||
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(subTestData);
|
||||
checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0, false);
|
||||
checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3, false);
|
||||
checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3, false);
|
||||
checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 }, false);
|
||||
checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 }, false);
|
||||
checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 }, false);
|
||||
checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 }, false);
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
|
||||
checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0);
|
||||
checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3);
|
||||
checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3);
|
||||
checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
|
||||
checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
|
||||
checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
|
||||
checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
|
||||
|
||||
checkCopy(m, null, 1, 0, 2, 4, true);
|
||||
checkCopy(m, null, -1, 1, 2, 2, true);
|
||||
checkCopy(m, null, 1, 0, 2, 2, true);
|
||||
checkCopy(m, null, 1, 0, 2, 4, true);
|
||||
checkCopy(m, null, new int[] {}, new int[] { 0 }, true);
|
||||
checkCopy(m, null, new int[] { 0 }, new int[] { 4 }, true);
|
||||
checkCopy(m, null, 1, 0, 2, 4);
|
||||
checkCopy(m, null, -1, 1, 2, 2);
|
||||
checkCopy(m, null, 1, 0, 2, 2);
|
||||
checkCopy(m, null, 1, 0, 2, 4);
|
||||
checkCopy(m, null, new int[] {}, new int[] { 0 });
|
||||
checkCopy(m, null, new int[] { 0 }, new int[] { 4 });
|
||||
}
|
||||
|
||||
private void checkCopy(FieldMatrix<Fraction> m, Fraction[][] reference,
|
||||
int startRow, int endRow, int startColumn, int endColumn,
|
||||
boolean mustFail) {
|
||||
int startRow, int endRow, int startColumn, int endColumn) {
|
||||
try {
|
||||
Fraction[][] sub = (reference == null) ?
|
||||
new Fraction[1][1] :
|
||||
new Fraction[reference.length][reference[0].length];
|
||||
m.copySubMatrix(startRow, endRow, startColumn, endColumn, sub);
|
||||
if (reference != null) {
|
||||
assertEquals(new Array2DRowFieldMatrix<Fraction>(reference), new Array2DRowFieldMatrix<Fraction>(sub));
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCopy(FieldMatrix<Fraction> m, Fraction[][] reference,
|
||||
int[] selectedRows, int[] selectedColumns,
|
||||
boolean mustFail) {
|
||||
int[] selectedRows, int[] selectedColumns) {
|
||||
try {
|
||||
Fraction[][] sub = (reference == null) ?
|
||||
new Fraction[1][1] :
|
||||
new Fraction[reference.length][reference[0].length];
|
||||
m.copySubMatrix(selectedRows, selectedColumns, sub);
|
||||
if (reference != null) {
|
||||
assertEquals(new Array2DRowFieldMatrix<Fraction>(reference), new Array2DRowFieldMatrix<Fraction>(sub));
|
||||
if (mustFail) {
|
||||
} else {
|
||||
fail("Expecting MatrixIndexException");
|
||||
}
|
||||
} catch (MatrixIndexException e) {
|
||||
if (!mustFail) {
|
||||
if (reference != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,11 +149,11 @@ public class SparseFieldMatrixTest extends TestCase {
|
|||
public void testCopyFunctions() {
|
||||
SparseFieldMatrix<Fraction> m1 = createSparseMatrix(testData);
|
||||
FieldMatrix<Fraction> m2 = m1.copy();
|
||||
assertTrue(m2 instanceof SparseFieldMatrix);
|
||||
assertEquals(m1.getClass(), m2.getClass());
|
||||
assertEquals((m2), m1);
|
||||
SparseFieldMatrix<Fraction> m3 = createSparseMatrix(testData);
|
||||
FieldMatrix<Fraction> m4 = m3.copy();
|
||||
assertTrue(m4 instanceof SparseFieldMatrix);
|
||||
assertEquals(m3.getClass(), m4.getClass());
|
||||
assertEquals((m4), m3);
|
||||
}
|
||||
|
||||
|
|
|
@ -130,11 +130,11 @@ public final class SparseRealMatrixTest extends TestCase {
|
|||
public void testCopyFunctions() {
|
||||
OpenMapRealMatrix m1 = createSparseMatrix(testData);
|
||||
RealMatrix m2 = m1.copy();
|
||||
assertTrue(m2 instanceof OpenMapRealMatrix);
|
||||
assertEquals(m1.getClass(), m2.getClass());
|
||||
assertEquals((m2), m1);
|
||||
OpenMapRealMatrix m3 = createSparseMatrix(testData);
|
||||
RealMatrix m4 = m3.copy();
|
||||
assertTrue(m4 instanceof OpenMapRealMatrix);
|
||||
assertEquals(m3.getClass(), m4.getClass());
|
||||
assertEquals((m4), m3);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,12 +62,8 @@ public class TestProblem1
|
|||
y = problem.y.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone operation.
|
||||
* @return a copy of the instance
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
/** {@inheritDoc} */
|
||||
public TestProblem1 copy() {
|
||||
return new TestProblem1(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,12 +63,8 @@ public class TestProblem2
|
|||
y = problem.y.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone operation.
|
||||
* @return a copy of the instance
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
/** {@inheritDoc} */
|
||||
public TestProblem2 copy() {
|
||||
return new TestProblem2(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,12 +78,8 @@ public class TestProblem3
|
|||
y = problem.y.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone operation.
|
||||
* @return a copy of the instance
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
/** {@inheritDoc} */
|
||||
public TestProblem3 copy() {
|
||||
return new TestProblem3(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,12 +68,8 @@ public class TestProblem4
|
|||
y = problem.y.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone operation.
|
||||
* @return a copy of the instance
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
/** {@inheritDoc} */
|
||||
public TestProblem4 copy() {
|
||||
return new TestProblem4(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,4 +36,8 @@ public class TestProblem5
|
|||
setFinalConditions(2 * t0 - t1);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public TestProblem5 copy() {
|
||||
return new TestProblem5();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,12 +63,8 @@ public class TestProblem6
|
|||
y = problem.y.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone operation.
|
||||
* @return a copy of the instance
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
/** {@inheritDoc} */
|
||||
public TestProblem6 copy() {
|
||||
return new TestProblem6(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.math.ode.events.EventHandler;
|
|||
* integrated during the junit tests for the ODE integrators.
|
||||
*/
|
||||
public abstract class TestProblemAbstract
|
||||
implements FirstOrderDifferentialEquations, Cloneable {
|
||||
implements FirstOrderDifferentialEquations {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = -8521928974502839379L;
|
||||
|
@ -82,11 +82,10 @@ public abstract class TestProblemAbstract
|
|||
}
|
||||
|
||||
/**
|
||||
* Clone operation.
|
||||
* Copy operation.
|
||||
* @return a copy of the instance
|
||||
*/
|
||||
@Override
|
||||
public abstract Object clone();
|
||||
public abstract TestProblemAbstract copy();
|
||||
|
||||
/**
|
||||
* Set the initial conditions
|
||||
|
|
|
@ -83,7 +83,7 @@ public class ClassicalRungeKuttaIntegratorTest
|
|||
double previousError = Double.NaN;
|
||||
for (int i = 4; i < 10; ++i) {
|
||||
|
||||
TestProblemAbstract pb = (TestProblemAbstract) problems[k].clone();
|
||||
TestProblemAbstract pb = problems[k].copy();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * Math.pow(2.0, -i);
|
||||
|
||||
FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
|
||||
|
|
|
@ -230,7 +230,7 @@ public class DormandPrince853IntegratorTest
|
|||
public void testNoDenseOutput()
|
||||
throws DerivativeException, IntegratorException {
|
||||
TestProblem1 pb1 = new TestProblem1();
|
||||
TestProblem1 pb2 = (TestProblem1) pb1.clone();
|
||||
TestProblem1 pb2 = pb1.copy();
|
||||
double minStep = 0.1 * (pb1.getFinalTime() - pb1.getInitialTime());
|
||||
double maxStep = pb1.getFinalTime() - pb1.getInitialTime();
|
||||
double scalAbsoluteTolerance = 1.0e-4;
|
||||
|
|
|
@ -62,7 +62,7 @@ public class EulerIntegratorTest
|
|||
double previousError = Double.NaN;
|
||||
for (int i = 4; i < 10; ++i) {
|
||||
|
||||
TestProblemAbstract pb = (TestProblemAbstract) problems[k].clone();
|
||||
TestProblemAbstract pb = problems[k].copy();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime())
|
||||
* Math.pow(2.0, -i);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class GillIntegratorTest
|
|||
double previousError = Double.NaN;
|
||||
for (int i = 5; i < 10; ++i) {
|
||||
|
||||
TestProblemAbstract pb = (TestProblemAbstract) problems[k].clone();
|
||||
TestProblemAbstract pb = problems[k].copy();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime())
|
||||
* Math.pow(2.0, -i);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class MidpointIntegratorTest
|
|||
double previousError = Double.NaN;
|
||||
for (int i = 4; i < 10; ++i) {
|
||||
|
||||
TestProblemAbstract pb = (TestProblemAbstract) problems[k].clone();
|
||||
TestProblemAbstract pb = problems[k].copy();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime())
|
||||
* Math.pow(2.0, -i);
|
||||
FirstOrderIntegrator integ = new MidpointIntegrator(step);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ThreeEighthesIntegratorTest
|
|||
double previousError = Double.NaN;
|
||||
for (int i = 4; i < 10; ++i) {
|
||||
|
||||
TestProblemAbstract pb = (TestProblemAbstract) problems[k].clone();
|
||||
TestProblemAbstract pb = problems[k].copy();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime())
|
||||
* Math.pow(2.0, -i);
|
||||
|
||||
|
|
|
@ -128,8 +128,8 @@ public class DummyStepInterpolatorTest {
|
|||
}
|
||||
|
||||
private static class BadStepInterpolator extends DummyStepInterpolator {
|
||||
@SuppressWarnings("unused")
|
||||
public BadStepInterpolator() {
|
||||
super();
|
||||
}
|
||||
public BadStepInterpolator(double[] y, boolean forward) {
|
||||
super(y, forward);
|
||||
|
|
|
@ -59,7 +59,7 @@ public class MultiStartMultivariateRealOptimizerTest {
|
|||
|
||||
}
|
||||
|
||||
private class Rosenbrock implements MultivariateRealFunction {
|
||||
private static class Rosenbrock implements MultivariateRealFunction {
|
||||
|
||||
private int count;
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ public class NelderMeadTest {
|
|||
}
|
||||
}
|
||||
|
||||
private class Rosenbrock implements MultivariateRealFunction {
|
||||
private static class Rosenbrock implements MultivariateRealFunction {
|
||||
|
||||
private int count;
|
||||
|
||||
|
@ -225,7 +225,7 @@ public class NelderMeadTest {
|
|||
|
||||
}
|
||||
|
||||
private class Powell implements MultivariateRealFunction {
|
||||
private static class Powell implements MultivariateRealFunction {
|
||||
|
||||
private int count;
|
||||
|
||||
|
|
|
@ -434,7 +434,6 @@ public class LevenbergMarquardtOptimizerTest
|
|||
Arrays.fill(target, 0.0);
|
||||
double[] weights = new double[circle.getN()];
|
||||
Arrays.fill(weights, 2.0);
|
||||
optimum =
|
||||
optimizer.optimize(circle, target, weights, new double[] { 98.680, 47.345 });
|
||||
cov = optimizer.getCovariances();
|
||||
assertEquals(0.0016, cov[0][0], 0.001);
|
||||
|
|
|
@ -429,10 +429,6 @@ extends TestCase {
|
|||
points.add(new Point2D.Double(px, py));
|
||||
}
|
||||
|
||||
public int getN() {
|
||||
return points.size();
|
||||
}
|
||||
|
||||
public double getRadius(Point2D.Double center) {
|
||||
double r = 0;
|
||||
for (Point2D.Double point : points) {
|
||||
|
|
|
@ -199,5 +199,6 @@ public class NaturalRankingTest extends TestCase {
|
|||
ranking = new NaturalRanking(NaNStrategy.MINIMAL);
|
||||
ranks = ranking.rank(data);
|
||||
correctRanks = new double[] { 3, 4, 1.5, 1.5 };
|
||||
TestUtils.assertEquals(correctRanks, ranks, 0d);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public final class MathUtilsTest extends TestCase {
|
|||
*/
|
||||
private long binomialCoefficient(int n, int k) throws ArithmeticException {
|
||||
if (binomialCache.size() > n) {
|
||||
Long cachedResult = binomialCache.get(n).get(new Integer(k));
|
||||
Long cachedResult = binomialCache.get(n).get(Integer.valueOf(k));
|
||||
if (cachedResult != null) {
|
||||
return cachedResult.longValue();
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public final class MathUtilsTest extends TestCase {
|
|||
for (int i = binomialCache.size(); i < n + 1; i++) {
|
||||
binomialCache.add(new HashMap<Integer, Long>());
|
||||
}
|
||||
binomialCache.get(n).put(new Integer(k), new Long(result));
|
||||
binomialCache.get(n).put(Integer.valueOf(k), Long.valueOf(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue