Added MonotoneChain algorithm to compute the convex hull of a collection of
points in 2D. Additionally, the AklToussaintHeuristic can be used to speed up
diff --git a/src/main/java/org/apache/commons/math3/linear/OpenMapRealMatrix.java b/src/main/java/org/apache/commons/math3/linear/OpenMapRealMatrix.java
index 31c586321..79c4d85d6 100644
--- a/src/main/java/org/apache/commons/math3/linear/OpenMapRealMatrix.java
+++ b/src/main/java/org/apache/commons/math3/linear/OpenMapRealMatrix.java
@@ -28,15 +28,16 @@ import org.apache.commons.math3.util.OpenIntToDoubleHashMap;
/**
* Sparse matrix implementation based on an open addressed map.
*
+ *
+ * Caveat: This implementation assumes that, for any {@code x},
+ * the equality {@code x * 0d == 0d} holds. But it is is not true for
+ * {@code NaN}. Moreover, zero entries will lose their sign.
+ * Some operations (that involve {@code NaN} and/or infinities) may
+ * thus give incorrect results.
+ *
* @version $Id$
* @since 2.0
- * @deprecated As of version 3.1, this class is deprecated, for reasons exposed
- * in this JIRA
- * ticket. This
- * class will be removed in version 4.0.
- *
*/
-@Deprecated
public class OpenMapRealMatrix extends AbstractRealMatrix
implements SparseRealMatrix, Serializable {
/** Serializable version identifier. */
diff --git a/src/main/java/org/apache/commons/math3/linear/OpenMapRealVector.java b/src/main/java/org/apache/commons/math3/linear/OpenMapRealVector.java
index 55d2b6a3f..e347ba83a 100644
--- a/src/main/java/org/apache/commons/math3/linear/OpenMapRealVector.java
+++ b/src/main/java/org/apache/commons/math3/linear/OpenMapRealVector.java
@@ -30,14 +30,16 @@ import org.apache.commons.math3.util.OpenIntToDoubleHashMap.Iterator;
/**
* This class implements the {@link RealVector} interface with a
* {@link OpenIntToDoubleHashMap} backing store.
+ *
+ * Caveat: This implementation assumes that, for any {@code x},
+ * the equality {@code x * 0d == 0d} holds. But it is is not true for
+ * {@code NaN}. Moreover, zero entries will lose their sign.
+ * Some operations (that involve {@code NaN} and/or infinities) may
+ * thus give incorrect results.
+ *
* @version $Id$
* @since 2.0
- * @deprecated As of version 3.1, this class is deprecated, for reasons exposed
- * in this JIRA
- * ticket. This
- * class will be removed in version 4.0.
*/
-@Deprecated
public class OpenMapRealVector extends SparseRealVector
implements Serializable {
/** Default Tolerance for having a value considered zero. */
diff --git a/src/main/java/org/apache/commons/math3/linear/SparseFieldMatrix.java b/src/main/java/org/apache/commons/math3/linear/SparseFieldMatrix.java
index 4705d256a..9d4e70ab6 100644
--- a/src/main/java/org/apache/commons/math3/linear/SparseFieldMatrix.java
+++ b/src/main/java/org/apache/commons/math3/linear/SparseFieldMatrix.java
@@ -23,16 +23,17 @@ import org.apache.commons.math3.util.OpenIntToFieldHashMap;
/**
* Sparse matrix implementation based on an open addressed map.
*
+ *
+ * Caveat: This implementation assumes that, for any {@code x},
+ * the equality {@code x * 0d == 0d} holds. But it is is not true for
+ * {@code NaN}. Moreover, zero entries will lose their sign.
+ * Some operations (that involve {@code NaN} and/or infinities) may
+ * thus give incorrect results.
+ *
* @param the type of the field elements
* @version $Id$
* @since 2.0
- * @deprecated As of version 3.1, this class is deprecated, for reasons exposed
- * in this JIRA
- * ticket. This
- * class will be removed in version 4.0.
- *
*/
-@Deprecated
public class SparseFieldMatrix> extends AbstractFieldMatrix {
/** Storage for (sparse) matrix elements. */
diff --git a/src/main/java/org/apache/commons/math3/linear/SparseFieldVector.java b/src/main/java/org/apache/commons/math3/linear/SparseFieldVector.java
index 9468a5ec0..c4a702335 100644
--- a/src/main/java/org/apache/commons/math3/linear/SparseFieldVector.java
+++ b/src/main/java/org/apache/commons/math3/linear/SparseFieldVector.java
@@ -32,15 +32,17 @@ import org.apache.commons.math3.util.OpenIntToFieldHashMap;
/**
* This class implements the {@link FieldVector} interface with a {@link OpenIntToFieldHashMap} backing store.
+ *
+ * Caveat: This implementation assumes that, for any {@code x},
+ * the equality {@code x * 0d == 0d} holds. But it is is not true for
+ * {@code NaN}. Moreover, zero entries will lose their sign.
+ * Some operations (that involve {@code NaN} and/or infinities) may
+ * thus give incorrect results.
+ *
* @param the type of the field elements
* @version $Id$
* @since 2.0
- * @deprecated As of version 3.1, this class is deprecated, for reasons exposed
- * in this JIRA
- * ticket. This
- * class will be removed in version 4.0.
*/
-@Deprecated
public class SparseFieldVector> implements FieldVector, Serializable {
/** Serialization identifier. */
private static final long serialVersionUID = 7841233292190413362L;
diff --git a/src/main/java/org/apache/commons/math3/linear/SparseRealMatrix.java b/src/main/java/org/apache/commons/math3/linear/SparseRealMatrix.java
index a0156b675..c21b408b5 100644
--- a/src/main/java/org/apache/commons/math3/linear/SparseRealMatrix.java
+++ b/src/main/java/org/apache/commons/math3/linear/SparseRealMatrix.java
@@ -20,15 +20,16 @@ package org.apache.commons.math3.linear;
/**
* Marker interface for {@link RealMatrix} implementations that require sparse backing storage
*
+ *
+ * Caveat: Implementation are allowed to assume that, for any {@code x},
+ * the equality {@code x * 0d == 0d} holds. But it is is not true for
+ * {@code NaN}. Moreover, zero entries will lose their sign.
+ * Some operations (that involve {@code NaN} and/or infinities) may
+ * thus give incorrect results.
+ *
* @version $Id$
* @since 2.0
- * @deprecated As of version 3.1, this class is deprecated, for reasons exposed
- * in this JIRA
- * ticket. This
- * class will be removed in version 4.0.
- *
*/
-@Deprecated
public interface SparseRealMatrix extends RealMatrix {
}
diff --git a/src/main/java/org/apache/commons/math3/linear/SparseRealVector.java b/src/main/java/org/apache/commons/math3/linear/SparseRealVector.java
index c66d4d716..08df6be60 100644
--- a/src/main/java/org/apache/commons/math3/linear/SparseRealVector.java
+++ b/src/main/java/org/apache/commons/math3/linear/SparseRealVector.java
@@ -18,13 +18,14 @@ package org.apache.commons.math3.linear;
/**
* Marker class for RealVectors that require sparse backing storage
+ *
+ * Caveat: Implementation are allowed to assume that, for any {@code x},
+ * the equality {@code x * 0d == 0d} holds. But it is is not true for
+ * {@code NaN}. Moreover, zero entries will lose their sign.
+ * Some operations (that involve {@code NaN} and/or infinities) may
+ * thus give incorrect results.
+ *
* @version $Id$
* @since 2.0
- * @deprecated As of version 3.1, this class is deprecated, for reasons exposed
- * in this JIRA
- * ticket. This
- * class will be removed in version 4.0.
- *
*/
-@Deprecated
public abstract class SparseRealVector extends RealVector {}
diff --git a/src/test/java/org/apache/commons/math3/linear/SparseFieldMatrixTest.java b/src/test/java/org/apache/commons/math3/linear/SparseFieldMatrixTest.java
index cc5b61a70..9b5f0f4c3 100644
--- a/src/test/java/org/apache/commons/math3/linear/SparseFieldMatrixTest.java
+++ b/src/test/java/org/apache/commons/math3/linear/SparseFieldMatrixTest.java
@@ -265,7 +265,7 @@ public class SparseFieldMatrixTest {
assertClose("identity operate", testVector, m.operate(testVector),
entryTolerance);
assertClose("identity operate", testVector, m.operate(
- new ArrayFieldVector(testVector)).getData(), entryTolerance);
+ new ArrayFieldVector(testVector)).toArray(), entryTolerance);
m = createSparseMatrix(bigSingular);
try {
m.operate(testVector);
diff --git a/src/test/java/org/apache/commons/math3/linear/SparseFieldVectorTest.java b/src/test/java/org/apache/commons/math3/linear/SparseFieldVectorTest.java
index 7f51d5559..07f5432b9 100644
--- a/src/test/java/org/apache/commons/math3/linear/SparseFieldVectorTest.java
+++ b/src/test/java/org/apache/commons/math3/linear/SparseFieldVectorTest.java
@@ -55,57 +55,57 @@ public class SparseFieldVectorTest {
//octave = v1 .+ 2.0
FieldVector v_mapAdd = v1.mapAdd(new Fraction(2));
Fraction[] result_mapAdd = {new Fraction(3), new Fraction(4), new Fraction(5)};
- Assert.assertArrayEquals("compare vectors" ,result_mapAdd,v_mapAdd.getData());
+ Assert.assertArrayEquals("compare vectors" ,result_mapAdd,v_mapAdd.toArray());
//octave = v1 .+ 2.0
FieldVector v_mapAddToSelf = v1.copy();
v_mapAddToSelf.mapAddToSelf(new Fraction(2));
Fraction[] result_mapAddToSelf = {new Fraction(3), new Fraction(4), new Fraction(5)};
- Assert.assertArrayEquals("compare vectors" ,result_mapAddToSelf,v_mapAddToSelf.getData());
+ Assert.assertArrayEquals("compare vectors" ,result_mapAddToSelf,v_mapAddToSelf.toArray());
//octave = v1 .- 2.0
FieldVector v_mapSubtract = v1.mapSubtract(new Fraction(2));
Fraction[] result_mapSubtract = {new Fraction(-1), new Fraction(0), new Fraction(1)};
- Assert.assertArrayEquals("compare vectors" ,result_mapSubtract,v_mapSubtract.getData());
+ Assert.assertArrayEquals("compare vectors" ,result_mapSubtract,v_mapSubtract.toArray());
//octave = v1 .- 2.0
FieldVector v_mapSubtractToSelf = v1.copy();
v_mapSubtractToSelf.mapSubtractToSelf(new Fraction(2));
Fraction[] result_mapSubtractToSelf = {new Fraction(-1), new Fraction(0), new Fraction(1)};
- Assert.assertArrayEquals("compare vectors" ,result_mapSubtractToSelf,v_mapSubtractToSelf.getData());
+ Assert.assertArrayEquals("compare vectors" ,result_mapSubtractToSelf,v_mapSubtractToSelf.toArray());
//octave = v1 .* 2.0
FieldVector v_mapMultiply = v1.mapMultiply(new Fraction(2));
Fraction[] result_mapMultiply = {new Fraction(2), new Fraction(4), new Fraction(6)};
- Assert.assertArrayEquals("compare vectors" ,result_mapMultiply,v_mapMultiply.getData());
+ Assert.assertArrayEquals("compare vectors" ,result_mapMultiply,v_mapMultiply.toArray());
//octave = v1 .* 2.0
FieldVector v_mapMultiplyToSelf = v1.copy();
v_mapMultiplyToSelf.mapMultiplyToSelf(new Fraction(2));
Fraction[] result_mapMultiplyToSelf = {new Fraction(2), new Fraction(4), new Fraction(6)};
- Assert.assertArrayEquals("compare vectors" ,result_mapMultiplyToSelf,v_mapMultiplyToSelf.getData());
+ Assert.assertArrayEquals("compare vectors" ,result_mapMultiplyToSelf,v_mapMultiplyToSelf.toArray());
//octave = v1 ./ 2.0
FieldVector v_mapDivide = v1.mapDivide(new Fraction(2));
Fraction[] result_mapDivide = {new Fraction(.5d), new Fraction(1), new Fraction(1.5d)};
- Assert.assertArrayEquals("compare vectors" ,result_mapDivide,v_mapDivide.getData());
+ Assert.assertArrayEquals("compare vectors" ,result_mapDivide,v_mapDivide.toArray());
//octave = v1 ./ 2.0
FieldVector v_mapDivideToSelf = v1.copy();
v_mapDivideToSelf.mapDivideToSelf(new Fraction(2));
Fraction[] result_mapDivideToSelf = {new Fraction(.5d), new Fraction(1), new Fraction(1.5d)};
- Assert.assertArrayEquals("compare vectors" ,result_mapDivideToSelf,v_mapDivideToSelf.getData());
+ Assert.assertArrayEquals("compare vectors" ,result_mapDivideToSelf,v_mapDivideToSelf.toArray());
//octave = v1 .^-1
FieldVector v_mapInv = v1.mapInv();
Fraction[] result_mapInv = {new Fraction(1),new Fraction(0.5d),new Fraction(3.333333333333333e-01d)};
- Assert.assertArrayEquals("compare vectors" ,result_mapInv,v_mapInv.getData());
+ Assert.assertArrayEquals("compare vectors" ,result_mapInv,v_mapInv.toArray());
//octave = v1 .^-1
FieldVector v_mapInvToSelf = v1.copy();
v_mapInvToSelf.mapInvToSelf();
Fraction[] result_mapInvToSelf = {new Fraction(1),new Fraction(0.5d),new Fraction(3.333333333333333e-01d)};
- Assert.assertArrayEquals("compare vectors" ,result_mapInvToSelf,v_mapInvToSelf.getData());
+ Assert.assertArrayEquals("compare vectors" ,result_mapInvToSelf,v_mapInvToSelf.toArray());
}
@@ -120,39 +120,39 @@ public class SparseFieldVectorTest {
//octave = v1 + v2
FieldVector v_add = v1.add(v2);
Fraction[] result_add = {new Fraction(5), new Fraction(7), new Fraction(9)};
- Assert.assertArrayEquals("compare vect" ,v_add.getData(),result_add);
+ Assert.assertArrayEquals("compare vect" ,v_add.toArray(),result_add);
FieldVector vt2 = new ArrayFieldVectorTest.FieldVectorTestImpl(vec2);
FieldVector v_add_i = v1.add(vt2);
Fraction[] result_add_i = {new Fraction(5), new Fraction(7), new Fraction(9)};
- Assert.assertArrayEquals("compare vect" ,v_add_i.getData(),result_add_i);
+ Assert.assertArrayEquals("compare vect" ,v_add_i.toArray(),result_add_i);
//octave = v1 - v2
SparseFieldVector v_subtract = v1.subtract(v2);
Fraction[] result_subtract = {new Fraction(-3), new Fraction(-3), new Fraction(-3)};
- assertClose("compare vect" ,v_subtract.getData(),result_subtract,normTolerance);
+ assertClose("compare vect" ,v_subtract.toArray(),result_subtract,normTolerance);
FieldVector v_subtract_i = v1.subtract(vt2);
Fraction[] result_subtract_i = {new Fraction(-3), new Fraction(-3), new Fraction(-3)};
- assertClose("compare vect" ,v_subtract_i.getData(),result_subtract_i,normTolerance);
+ assertClose("compare vect" ,v_subtract_i.toArray(),result_subtract_i,normTolerance);
// octave v1 .* v2
FieldVector v_ebeMultiply = v1.ebeMultiply(v2);
Fraction[] result_ebeMultiply = {new Fraction(4), new Fraction(10), new Fraction(18)};
- assertClose("compare vect" ,v_ebeMultiply.getData(),result_ebeMultiply,normTolerance);
+ assertClose("compare vect" ,v_ebeMultiply.toArray(),result_ebeMultiply,normTolerance);
FieldVector v_ebeMultiply_2 = v1.ebeMultiply(v2_t);
Fraction[] result_ebeMultiply_2 = {new Fraction(4), new Fraction(10), new Fraction(18)};
- assertClose("compare vect" ,v_ebeMultiply_2.getData(),result_ebeMultiply_2,normTolerance);
+ assertClose("compare vect" ,v_ebeMultiply_2.toArray(),result_ebeMultiply_2,normTolerance);
// octave v1 ./ v2
FieldVector v_ebeDivide = v1.ebeDivide(v2);
Fraction[] result_ebeDivide = {new Fraction(0.25d), new Fraction(0.4d), new Fraction(0.5d)};
- assertClose("compare vect" ,v_ebeDivide.getData(),result_ebeDivide,normTolerance);
+ assertClose("compare vect" ,v_ebeDivide.toArray(),result_ebeDivide,normTolerance);
FieldVector v_ebeDivide_2 = v1.ebeDivide(v2_t);
Fraction[] result_ebeDivide_2 = {new Fraction(0.25d), new Fraction(0.4d), new Fraction(0.5d)};
- assertClose("compare vect" ,v_ebeDivide_2.getData(),result_ebeDivide_2,normTolerance);
+ assertClose("compare vect" ,v_ebeDivide_2.toArray(),result_ebeDivide_2,normTolerance);
// octave dot(v1,v2)
Fraction dot = v1.dotProduct(v2);