You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ce...@apache.org on 2012/07/06 07:47:02 UTC
svn commit: r1358048 - in /commons/proper/math/trunk/src:
main/java/org/apache/commons/math3/linear/
test/java/org/apache/commons/math3/linear/
Author: celestin
Date: Fri Jul 6 05:47:02 2012
New Revision: 1358048
URL: http://svn.apache.org/viewvc?rev=1358048&view=rev
Log:
MATH-795:
- Corrected some build failures caused by changes in r1358046.
- Moved javadoc of boolean ArrayRealVector.equals(Object) to RealVector.
- In RealVector, default implementations of equals(Object) and hashCode() throw UnsupportedOperationException, in order to force implementation in subclasses.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayRealVector.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/ArrayRealVectorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorTest.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayRealVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayRealVector.java?rev=1358048&r1=1358047&r2=1358048&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayRealVector.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayRealVector.java Fri Jul 6 05:47:02 2012
@@ -792,20 +792,7 @@ public class ArrayRealVector extends Rea
return false;
}
- /**
- * Test for the equality of two real vectors.
- * If all coordinates of two real vectors are exactly the same, and none are
- * {@code NaN}, the two real vectors are considered to be equal.
- * {@code NaN} coordinates are considered to affect globally the vector
- * and be equals to each other - i.e, if either (or all) coordinates of the
- * real vector are equal to {@code NaN}, the real vector is equal to
- * a vector with all {@code NaN} coordinates.
- *
- * @param other Object to test for equality.
- * @return {@code true} if two vector objects are equal, {@code false} if
- * {@code other} is null, not an instance of {@code RealVector}, or
- * not equal to this {@code RealVector} instance.
- */
+ /** {@inheritDoc} */
@Override
public boolean equals(Object other) {
if (this == other) {
@@ -834,10 +821,7 @@ public class ArrayRealVector extends Rea
}
/**
- * Get a hashCode for the real vector.
- * All {@code NaN} values have the same hash code.
- *
- * @return a hash code.
+ * {@inheritDoc} All {@code NaN} values have the same hash code.
*/
@Override
public int hashCode() {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java?rev=1358048&r1=1358047&r2=1358048&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java Fri Jul 6 05:47:02 2012
@@ -1076,6 +1076,40 @@ public abstract class RealVector {
}
/**
+ * <p>
+ * Test for the equality of two real vectors. If all coordinates of two real
+ * vectors are exactly the same, and none are {@code NaN}, the two real
+ * vectors are considered to be equal. {@code NaN} coordinates are
+ * considered to affect globally the vector and be equals to each other -
+ * i.e, if either (or all) coordinates of the real vector are equal to
+ * {@code NaN}, the real vector is equal to a vector with all {@code NaN}
+ * coordinates.
+ * </p>
+ * <p>
+ * This method <em>must</em> be overriden by concrete subclasses of
+ * {@link RealVector}.
+ * </p>
+ *
+ * @param other Object to test for equality.
+ * @return {@code true} if two vector objects are equal, {@code false} if
+ * {@code other} is null, not an instance of {@code RealVector}, or
+ * not equal to this {@code RealVector} instance.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}. This method <em>must</em> be overriden by concrete
+ * subclasses of {@link RealVector}.
+ */
+ @Override
+ public int hashCode() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
* This class should rarely be used, but is here to provide
* a default implementation of sparseIterator(), which is implemented
* by walking over the entries, skipping those whose values are the default one.
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/ArrayRealVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/ArrayRealVectorTest.java?rev=1358048&r1=1358047&r2=1358048&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/ArrayRealVectorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/ArrayRealVectorTest.java Fri Jul 6 05:47:02 2012
@@ -488,9 +488,7 @@ public class ArrayRealVectorTest extends
}
@Test
- @Override
public void testPredicates() {
- super.testPredicates();
final ArrayRealVector v = (ArrayRealVector) create(new double[] { 0, 1, 2 });
Assert.assertFalse(v.equals(v.getDataRef()));
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorTest.java?rev=1358048&r1=1358047&r2=1358048&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorTest.java Fri Jul 6 05:47:02 2012
@@ -336,21 +336,6 @@ public class RealVectorTest extends Real
}
@Test
- @Ignore
- @Override
- public void testBasicFunctions() {
- /*
- * TODO this test is huge, and some of the methods being tested are not
- * supported by TestVectorImpl. For the time being, this test is skipped
- * (testBasicFunctions() is overriden, ommitting the @Test anotation).
- *
- * What should really be done: split testBasicFunctions() in many
- * smaller unit tests, and skip only those tests which are not meaningfull
- * for RealVector.
- */
- }
-
- @Test
public void testSparseIterator() throws Exception {
RealVector v = new TestVectorImpl(vec2.clone());
Entry e;
@@ -436,24 +421,16 @@ public class RealVectorTest extends Real
}
@Test
- @Ignore
+ @Ignore("Abstract class RealVector is not serializable.")
@Override
- public void testPredicates() {
- /*
- * TODO Some of the tests carried out in testPredicates() do not pass,
- * as the methods to be tested are not implemented in TestVectorImpl.
- * For the time being, testPredicates() is overriden, while ommitting
- * the @Test annotation, which effectively skips the test.
- *
- * In the future, testPredicates() should be split in smaller units, and
- * only those units which do not make sense should be skipped.
- */
+ public void testSerial() {
+ // Do nothing
}
@Test
- @Ignore("Abstract class RealVector is not serializable.")
+ @Ignore("Abstract class RealVector does not override equals(Object).")
@Override
- public void testSerial() {
+ public void testEquals() {
// Do nothing
}
}