The sparse vector and matrix classes have been un-deprecated.
This is a reversal of a former decision, as we now think we should adopt a generally accepted behavior which is ... to ignore the problems of NaNs and infinities in sparse linear algebra entities. JIRA: MATH-870 (which is therefore NOT fixed) git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1569825 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
785ea269eb
commit
499101c88c
|
@ -51,6 +51,12 @@ If the output is not quite correct, check for invisible trailing spaces!
|
|||
</properties>
|
||||
<body>
|
||||
<release version="3.3" date="TBD" description="TBD">
|
||||
<action dev="luc" type="update" issue="MATH-870">
|
||||
The sparse vector and matrix classes have been un-deprecated. This is a reversal
|
||||
of a former decision, as we now think we should adopt a generally accepted
|
||||
behavior which is ... to ignore the problems of NaNs and infinities in
|
||||
sparse linear algebra entities.
|
||||
</action>
|
||||
<action dev="tn" type="add" issue="MATH-749">
|
||||
Added MonotoneChain algorithm to compute the convex hull of a collection of
|
||||
points in 2D. Additionally, the AklToussaintHeuristic can be used to speed up
|
||||
|
|
|
@ -28,15 +28,16 @@ import org.apache.commons.math3.util.OpenIntToDoubleHashMap;
|
|||
/**
|
||||
* Sparse matrix implementation based on an open addressed map.
|
||||
*
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
* @version $Id$
|
||||
* @since 2.0
|
||||
* @deprecated As of version 3.1, this class is deprecated, for reasons exposed
|
||||
* in this JIRA
|
||||
* <a href="https://issues.apache.org/jira/browse/MATH-870">ticket</a>. This
|
||||
* class will be removed in version 4.0.
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class OpenMapRealMatrix extends AbstractRealMatrix
|
||||
implements SparseRealMatrix, Serializable {
|
||||
/** Serializable version identifier. */
|
||||
|
|
|
@ -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.
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
* @version $Id$
|
||||
* @since 2.0
|
||||
* @deprecated As of version 3.1, this class is deprecated, for reasons exposed
|
||||
* in this JIRA
|
||||
* <a href="https://issues.apache.org/jira/browse/MATH-870">ticket</a>. 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. */
|
||||
|
|
|
@ -23,16 +23,17 @@ import org.apache.commons.math3.util.OpenIntToFieldHashMap;
|
|||
/**
|
||||
* Sparse matrix implementation based on an open addressed map.
|
||||
*
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
* @param <T> 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
|
||||
* <a href="https://issues.apache.org/jira/browse/MATH-870">ticket</a>. This
|
||||
* class will be removed in version 4.0.
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMatrix<T> {
|
||||
|
||||
/** Storage for (sparse) matrix elements. */
|
||||
|
|
|
@ -32,15 +32,17 @@ import org.apache.commons.math3.util.OpenIntToFieldHashMap;
|
|||
|
||||
/**
|
||||
* This class implements the {@link FieldVector} interface with a {@link OpenIntToFieldHashMap} backing store.
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
* @param <T> 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
|
||||
* <a href="https://issues.apache.org/jira/browse/MATH-870">ticket</a>. This
|
||||
* class will be removed in version 4.0.
|
||||
*/
|
||||
@Deprecated
|
||||
public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector<T>, Serializable {
|
||||
/** Serialization identifier. */
|
||||
private static final long serialVersionUID = 7841233292190413362L;
|
||||
|
|
|
@ -20,15 +20,16 @@ package org.apache.commons.math3.linear;
|
|||
/**
|
||||
* Marker interface for {@link RealMatrix} implementations that require sparse backing storage
|
||||
*
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
* @version $Id$
|
||||
* @since 2.0
|
||||
* @deprecated As of version 3.1, this class is deprecated, for reasons exposed
|
||||
* in this JIRA
|
||||
* <a href="https://issues.apache.org/jira/browse/MATH-870">ticket</a>. This
|
||||
* class will be removed in version 4.0.
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public interface SparseRealMatrix extends RealMatrix {
|
||||
|
||||
}
|
||||
|
|
|
@ -18,13 +18,14 @@ package org.apache.commons.math3.linear;
|
|||
|
||||
/**
|
||||
* Marker class for RealVectors that require sparse backing storage
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
* @version $Id$
|
||||
* @since 2.0
|
||||
* @deprecated As of version 3.1, this class is deprecated, for reasons exposed
|
||||
* in this JIRA
|
||||
* <a href="https://issues.apache.org/jira/browse/MATH-870">ticket</a>. This
|
||||
* class will be removed in version 4.0.
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class SparseRealVector extends RealVector {}
|
||||
|
|
|
@ -265,7 +265,7 @@ public class SparseFieldMatrixTest {
|
|||
assertClose("identity operate", testVector, m.operate(testVector),
|
||||
entryTolerance);
|
||||
assertClose("identity operate", testVector, m.operate(
|
||||
new ArrayFieldVector<Fraction>(testVector)).getData(), entryTolerance);
|
||||
new ArrayFieldVector<Fraction>(testVector)).toArray(), entryTolerance);
|
||||
m = createSparseMatrix(bigSingular);
|
||||
try {
|
||||
m.operate(testVector);
|
||||
|
|
|
@ -55,57 +55,57 @@ public class SparseFieldVectorTest {
|
|||
//octave = v1 .+ 2.0
|
||||
FieldVector<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> vt2 = new ArrayFieldVectorTest.FieldVectorTestImpl<Fraction>(vec2);
|
||||
FieldVector<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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<Fraction> 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);
|
||||
|
|
Loading…
Reference in New Issue