commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1172044 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/linear/ test/java/org/apache/commons/math/linear/
Date Sat, 17 Sep 2011 18:42:03 GMT
Author: celestin
Date: Sat Sep 17 18:42:03 2011
New Revision: 1172044

URL: http://svn.apache.org/viewvc?rev=1172044&view=rev
Log:
Removed methods treating T[] as FieldVector. Modified SparseFieldVectorTest to allow for testing
of operations on mixed types (Sparse/non-sparse).

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/ArrayFieldVector.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldVector.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SparseFieldVector.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/ArrayFieldVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/ArrayFieldVector.java?rev=1172044&r1=1172043&r2=1172044&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/ArrayFieldVector.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/ArrayFieldVector.java
Sat Sep 17 18:42:03 2011
@@ -410,16 +410,6 @@ public class ArrayFieldVector<T extends 
         }
     }
 
-    /** {@inheritDoc} */
-    public FieldVector<T> add(T[] v) {
-        checkVectorDimensions(v.length);
-        T[] out = buildArray(data.length);
-        for (int i = 0; i < data.length; i++) {
-            out[i] = data[i].add(v[i]);
-        }
-        return new ArrayFieldVector<T>(field, out, false);
-    }
-
     /**
      * Compute the sum of this and v.
      * @param v vector to be added
@@ -427,7 +417,12 @@ public class ArrayFieldVector<T extends 
      * @throws IllegalArgumentException if v is not the same size as this
      */
     public ArrayFieldVector<T> add(ArrayFieldVector<T> v) {
-        return (ArrayFieldVector<T>) add(v.data);
+        checkVectorDimensions(v.data.length);
+        T[] out = buildArray(data.length);
+        for (int i = 0; i < data.length; i++) {
+            out[i] = data[i].add(v.data[i]);
+        }
+        return new ArrayFieldVector<T>(field, out, false);
     }
 
     /** {@inheritDoc} */
@@ -444,16 +439,6 @@ public class ArrayFieldVector<T extends 
         }
     }
 
-    /** {@inheritDoc} */
-    public FieldVector<T> subtract(T[] v) {
-        checkVectorDimensions(v.length);
-        T[] out = buildArray(data.length);
-        for (int i = 0; i < data.length; i++) {
-            out[i] = data[i].subtract(v[i]);
-        }
-        return new ArrayFieldVector<T>(field, out, false);
-    }
-
     /**
      * Compute this minus v.
      * @param v vector to be subtracted
@@ -461,7 +446,12 @@ public class ArrayFieldVector<T extends 
      * @throws IllegalArgumentException if v is not the same size as this
      */
     public ArrayFieldVector<T> subtract(ArrayFieldVector<T> v) {
-        return (ArrayFieldVector<T>) subtract(v.data);
+        checkVectorDimensions(v.data.length);
+        T[] out = buildArray(data.length);
+        for (int i = 0; i < data.length; i++) {
+            out[i] = data[i].subtract(v.data[i]);
+        }
+        return new ArrayFieldVector<T>(field, out, false);
     }
 
     /** {@inheritDoc} */
@@ -565,16 +555,6 @@ public class ArrayFieldVector<T extends 
         }
     }
 
-    /** {@inheritDoc} */
-    public FieldVector<T> ebeMultiply(T[] v) {
-        checkVectorDimensions(v.length);
-        T[] out = buildArray(data.length);
-        for (int i = 0; i < data.length; i++) {
-            out[i] = data[i].multiply(v[i]);
-        }
-        return new ArrayFieldVector<T>(field, out, false);
-    }
-
     /**
      * Element-by-element multiplication.
      * @param v vector by which instance elements must be multiplied
@@ -582,7 +562,12 @@ public class ArrayFieldVector<T extends 
      * @exception IllegalArgumentException if v is not the same size as this
      */
     public ArrayFieldVector<T> ebeMultiply(ArrayFieldVector<T> v) {
-        return (ArrayFieldVector<T>) ebeMultiply(v.data);
+        checkVectorDimensions(v.data.length);
+        T[] out = buildArray(data.length);
+        for (int i = 0; i < data.length; i++) {
+            out[i] = data[i].multiply(v.data[i]);
+        }
+        return new ArrayFieldVector<T>(field, out, false);
     }
 
     /** {@inheritDoc} */
@@ -599,16 +584,6 @@ public class ArrayFieldVector<T extends 
         }
     }
 
-    /** {@inheritDoc} */
-    public FieldVector<T> ebeDivide(T[] v) {
-        checkVectorDimensions(v.length);
-        T[] out = buildArray(data.length);
-        for (int i = 0; i < data.length; i++) {
-                out[i] = data[i].divide(v[i]);
-        }
-        return new ArrayFieldVector<T>(field, out, false);
-    }
-
     /**
      * Element-by-element division.
      * @param v vector by which instance elements must be divided
@@ -616,7 +591,12 @@ public class ArrayFieldVector<T extends 
      * @throws IllegalArgumentException if v is not the same size as this
      */
     public ArrayFieldVector<T> ebeDivide(ArrayFieldVector<T> v) {
-        return (ArrayFieldVector<T>) ebeDivide(v.data);
+        checkVectorDimensions(v.data.length);
+        T[] out = buildArray(data.length);
+        for (int i = 0; i < data.length; i++) {
+                out[i] = data[i].divide(v.data[i]);
+        }
+        return new ArrayFieldVector<T>(field, out, false);
     }
 
     /** {@inheritDoc} */
@@ -647,16 +627,6 @@ public class ArrayFieldVector<T extends 
         }
     }
 
-    /** {@inheritDoc} */
-    public T dotProduct(T[] v) {
-        checkVectorDimensions(v.length);
-        T dot = field.getZero();
-        for (int i = 0; i < data.length; i++) {
-            dot = dot.add(data[i].multiply(v[i]));
-        }
-        return dot;
-    }
-
     /**
      * Compute the dot product.
      * @param v vector with which dot product should be computed
@@ -664,7 +634,12 @@ public class ArrayFieldVector<T extends 
      * @exception IllegalArgumentException if v is not the same size as this
      */
     public T dotProduct(ArrayFieldVector<T> v) {
-        return dotProduct(v.data);
+        checkVectorDimensions(v.data.length);
+        T dot = field.getZero();
+        for (int i = 0; i < data.length; i++) {
+            dot = dot.add(data[i].multiply(v.data[i]));
+        }
+        return dot;
     }
 
     /** {@inheritDoc} */
@@ -672,11 +647,6 @@ public class ArrayFieldVector<T extends 
         return v.mapMultiply(dotProduct(v).divide(v.dotProduct(v)));
     }
 
-    /** {@inheritDoc} */
-    public FieldVector<T> projection(T[] v) {
-        return projection(new ArrayFieldVector<T>(getField(), v, false));
-    }
-
    /** Find the orthogonal projection of this vector onto another vector.
      * @param v vector onto which instance must be projected
      * @return projection of the instance onto v
@@ -710,17 +680,12 @@ public class ArrayFieldVector<T extends 
      * @exception IllegalArgumentException if v is not the same size as this
      */
     public FieldMatrix<T> outerProduct(ArrayFieldVector<T> v) {
-        return outerProduct(v.data);
-    }
-
-    /** {@inheritDoc} */
-    public FieldMatrix<T> outerProduct(T[] v) {
         final int m = data.length;
-        final int n = v.length;
+        final int n = v.data.length;
         final FieldMatrix<T> out = new Array2DRowFieldMatrix<T>(field, m, n);
         for (int i = 0; i < m; i++) {
             for (int j = 0; j < n; j++) {
-                out.setEntry(i, j, data[i].multiply(v[j]));
+                out.setEntry(i, j, data[i].multiply(v.data[j]));
             }
         }
         return out;
@@ -763,11 +728,6 @@ public class ArrayFieldVector<T extends 
     }
 
     /** {@inheritDoc} */
-    public FieldVector<T> append(T[] in) {
-        return new ArrayFieldVector<T>(this, in);
-    }
-
-    /** {@inheritDoc} */
     public FieldVector<T> getSubVector(int index, int n) {
         ArrayFieldVector<T> out = new ArrayFieldVector<T>(field, n);
         try {
@@ -804,16 +764,6 @@ public class ArrayFieldVector<T extends 
         }
     }
 
-    /** {@inheritDoc} */
-    public void setSubVector(int index, T[] v) {
-        try {
-            System.arraycopy(v, 0, data, index, v.length);
-        } catch (IndexOutOfBoundsException e) {
-            checkIndex(index);
-            checkIndex(index + v.length - 1);
-        }
-    }
-
     /**
      * Set a set of consecutive elements.
      *
@@ -823,7 +773,12 @@ public class ArrayFieldVector<T extends 
      * inconsistent with vector size
      */
     public void set(int index, ArrayFieldVector<T> v) {
-        setSubVector(index, v.data);
+        try {
+            System.arraycopy(v.data, 0, data, index, v.data.length);
+        } catch (IndexOutOfBoundsException e) {
+            checkIndex(index);
+            checkIndex(index + v.data.length - 1);
+        }
     }
 
     /** {@inheritDoc} */

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldVector.java?rev=1172044&r1=1172043&r2=1172044&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldVector.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldVector.java
Sat Sep 17 18:42:03 2011
@@ -67,15 +67,6 @@ public interface FieldVector<T extends F
         throws IllegalArgumentException;
 
     /**
-     * Compute the sum of this and v.
-     * @param v vector to be added
-     * @return this + v
-     * @throws IllegalArgumentException if v is not the same size as this
-     */
-    FieldVector<T> add(T[] v)
-        throws IllegalArgumentException;
-
-    /**
      * Compute this minus v.
      * @param v vector to be subtracted
      * @return this + v
@@ -85,15 +76,6 @@ public interface FieldVector<T extends F
         throws IllegalArgumentException;
 
     /**
-     * Compute this minus v.
-     * @param v vector to be subtracted
-     * @return this + v
-     * @throws IllegalArgumentException if v is not the same size as this
-     */
-    FieldVector<T> subtract(T[] v)
-        throws IllegalArgumentException;
-
-    /**
      * Map an addition operation to each entry.
      * @param d value to be added to each entry
      * @return this + d
@@ -175,14 +157,6 @@ public interface FieldVector<T extends F
     FieldVector<T> ebeMultiply(FieldVector<T> v) throws IllegalArgumentException;
 
     /**
-     * Element-by-element multiplication.
-     * @param v vector by which instance elements must be multiplied
-     * @return a vector containing this[i] * v[i] for all i
-     * @throws IllegalArgumentException if v is not the same size as this
-     */
-    FieldVector<T> ebeMultiply(T[] v) throws IllegalArgumentException;
-
-    /**
      * Element-by-element division.
      * @param v vector by which instance elements must be divided
      * @return a vector containing this[i] / v[i] for all i
@@ -191,14 +165,6 @@ public interface FieldVector<T extends F
     FieldVector<T> ebeDivide(FieldVector<T> v) throws IllegalArgumentException;
 
     /**
-     * Element-by-element division.
-     * @param v vector by which instance elements must be divided
-     * @return a vector containing this[i] / v[i] for all i
-     * @throws IllegalArgumentException if v is not the same size as this
-     */
-    FieldVector<T> ebeDivide(T[] v) throws IllegalArgumentException;
-
-    /**
      * Returns vector entries as a T array.
      * @return T array of entries
      */
@@ -213,15 +179,6 @@ public interface FieldVector<T extends F
     T dotProduct(FieldVector<T> v)
         throws IllegalArgumentException;
 
-    /**
-     * Compute the dot product.
-     * @param v vector with which dot product should be computed
-     * @return the scalar dot product between instance and v
-     * @exception IllegalArgumentException if v is not the same size as this
-     */
-    T dotProduct(T[] v)
-        throws IllegalArgumentException;
-
     /** Find the orthogonal projection of this vector onto another vector.
      * @param v vector onto which instance must be projected
      * @return projection of the instance onto v
@@ -230,14 +187,6 @@ public interface FieldVector<T extends F
     FieldVector<T> projection(FieldVector<T> v)
         throws IllegalArgumentException;
 
-    /** Find the orthogonal projection of this vector onto another vector.
-     * @param v vector onto which instance must be projected
-     * @return projection of the instance onto v
-     * @throws IllegalArgumentException if v is not the same size as this
-     */
-    FieldVector<T> projection(T[] v)
-        throws IllegalArgumentException;
-
     /**
      * Compute the outer product.
      * @param v vector with which outer product should be computed
@@ -246,13 +195,6 @@ public interface FieldVector<T extends F
     FieldMatrix<T> outerProduct(FieldVector<T> v);
 
     /**
-     * Compute the outer product.
-     * @param v vector with which outer product should be computed
-     * @return the matrix outer product between instance and v
-     */
-    FieldMatrix<T> outerProduct(T[] v);
-
-    /**
      * Returns the entry in the specified index.
      *
      * @param index Index location of entry to be fetched.
@@ -294,13 +236,6 @@ public interface FieldVector<T extends F
     FieldVector<T> append(T d);
 
     /**
-     * Construct a vector by appending a T array to this vector.
-     * @param a T array to append.
-     * @return a new vector
-     */
-    FieldVector<T> append(T[] a);
-
-    /**
      * Get a subvector from consecutive elements.
      * @param index index of first element.
      * @param n number of elements to be retrieved.
@@ -321,16 +256,6 @@ public interface FieldVector<T extends F
     void setSubVector(int index, FieldVector<T> v);
 
     /**
-     * Set a set of consecutive elements.
-     * @param index index of first element to be set.
-     * @param v vector containing the values to set.
-     * @throws org.apache.commons.math.exception.OutOfRangeException
-     * if the index is inconsistent with vector size.
-     * @see #setSubVector(int, FieldVector)
-     */
-    void setSubVector(int index, T[] v);
-
-    /**
      * Set all elements to a single value.
      * @param value single value to set for all elements
      */

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SparseFieldVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SparseFieldVector.java?rev=1172044&r1=1172043&r2=1172044&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SparseFieldVector.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SparseFieldVector.java
Sat Sep 17 18:42:03 2011
@@ -158,17 +158,6 @@ public class SparseFieldVector<T extends
 
     }
 
-
-    /** {@inheritDoc} */
-    public FieldVector<T> add(T[] v) {
-        checkVectorDimensions(v.length);
-        SparseFieldVector<T> res = new SparseFieldVector<T>(field,getDimension());
-        for (int i = 0; i < v.length; i++) {
-            res.setEntry(i, v[i].add(getEntry(i)));
-        }
-        return res;
-    }
-
     /**
      * Construct a vector by appending a vector to this vector.
      *
@@ -190,7 +179,12 @@ public class SparseFieldVector<T extends
         if (v instanceof SparseFieldVector<?>) {
             return append((SparseFieldVector<T>) v);
         } else {
-            return append(v.toArray());
+            final int n = v.getDimension();
+            FieldVector<T> res = new SparseFieldVector<T>(this, n);
+            for (int i = 0; i < n; i++) {
+                res.setEntry(i + virtualSize, v.getEntry(i));
+            }
+            return res;
         }
     }
 
@@ -202,15 +196,6 @@ public class SparseFieldVector<T extends
      }
 
     /** {@inheritDoc} */
-    public FieldVector<T> append(T[] a) {
-        FieldVector<T> res = new SparseFieldVector<T>(this, a.length);
-        for (int i = 0; i < a.length; i++) {
-            res.setEntry(i + virtualSize, a[i]);
-        }
-        return res;
-     }
-
-    /** {@inheritDoc} */
     public FieldVector<T> copy() {
         return new SparseFieldVector<T>(this);
    }
@@ -228,22 +213,6 @@ public class SparseFieldVector<T extends
     }
 
     /** {@inheritDoc} */
-    public T dotProduct(T[] v) {
-        checkVectorDimensions(v.length);
-        T res = field.getZero();
-        OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
-        while (iter.hasNext()) {
-            int idx = iter.key();
-            T value = field.getZero();
-            if (idx < v.length) {
-                value = v[idx];
-            }
-            res = res.add(value.multiply(iter.value()));
-        }
-        return res;
-     }
-
-    /** {@inheritDoc} */
     public FieldVector<T> ebeDivide(FieldVector<T> v) {
         checkVectorDimensions(v.getDimension());
         SparseFieldVector<T> res = new SparseFieldVector<T>(this);
@@ -256,18 +225,6 @@ public class SparseFieldVector<T extends
     }
 
     /** {@inheritDoc} */
-    public FieldVector<T> ebeDivide(T[] v) {
-        checkVectorDimensions(v.length);
-        SparseFieldVector<T> res = new SparseFieldVector<T>(this);
-        OpenIntToFieldHashMap<T>.Iterator iter = res.entries.iterator();
-        while (iter.hasNext()) {
-            iter.advance();
-            res.setEntry(iter.key(), iter.value().divide(v[iter.key()]));
-        }
-        return res;
-    }
-
-    /** {@inheritDoc} */
     public FieldVector<T> ebeMultiply(FieldVector<T> v) {
         checkVectorDimensions(v.getDimension());
         SparseFieldVector<T> res = new SparseFieldVector<T>(this);
@@ -279,18 +236,6 @@ public class SparseFieldVector<T extends
         return res;
     }
 
-    /** {@inheritDoc} */
-     public FieldVector<T> ebeMultiply(T[] v) {
-        checkVectorDimensions(v.length);
-        SparseFieldVector<T> res = new SparseFieldVector<T>(this);
-        OpenIntToFieldHashMap<T>.Iterator iter = res.entries.iterator();
-        while (iter.hasNext()) {
-            iter.advance();
-            res.setEntry(iter.key(), iter.value().multiply(v[iter.key()]));
-        }
-        return res;
-    }
-
      /** {@inheritDoc} */
      public T[] getData() {
         T[] res = buildArray(virtualSize);
@@ -424,27 +369,22 @@ public class SparseFieldVector<T extends
     }
 
     /** {@inheritDoc} */
-    public FieldMatrix<T> outerProduct(T[] v) {
-        final int n = v.length;
-        FieldMatrix<T> res = new SparseFieldMatrix<T>(field, virtualSize, n);
-        OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
-        while (iter.hasNext()) {
-            iter.advance();
-            int row = iter.key();
-            FieldElement<T>value = iter.value();
-            for (int col = 0; col < n; col++) {
-                res.setEntry(row, col, value.multiply(v[col]));
-            }
-        }
-        return res;
-     }
-
-    /** {@inheritDoc} */
     public FieldMatrix<T> outerProduct(FieldVector<T> v) {
         if (v instanceof SparseFieldVector<?>) {
             return outerProduct((SparseFieldVector<T>)v);
         } else {
-            return outerProduct(v.toArray());
+            final int n = v.getDimension();
+            FieldMatrix<T> res = new SparseFieldMatrix<T>(field, virtualSize,
n);
+            OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
+            while (iter.hasNext()) {
+                iter.advance();
+                int row = iter.key();
+                FieldElement<T>value = iter.value();
+                for (int col = 0; col < n; col++) {
+                    res.setEntry(row, col, value.multiply(v.getEntry(col)));
+                }
+            }
+            return res;
         }
     }
 
@@ -455,12 +395,6 @@ public class SparseFieldVector<T extends
     }
 
     /** {@inheritDoc} */
-    public FieldVector<T> projection(T[] v) {
-        checkVectorDimensions(v.length);
-        return projection(new SparseFieldVector<T>(field,v));
-    }
-
-    /** {@inheritDoc} */
     public void set(T value) {
         for (int i = 0; i < virtualSize; i++) {
             setEntry(i, value);
@@ -477,17 +411,10 @@ public class SparseFieldVector<T extends
     public void setSubVector(int index, FieldVector<T> v) {
         checkIndex(index);
         checkIndex(index + v.getDimension() - 1);
-        setSubVector(index, v.getData());
-    }
-
-    /** {@inheritDoc} */
-    public void setSubVector(int index, T[] v) {
-        checkIndex(index);
-        checkIndex(index + v.length - 1);
-        for (int i = 0; i < v.length; i++) {
-            setEntry(i + index, v[i]);
+        final int n = v.getDimension();
+        for (int i = 0; i < n; i++) {
+            setEntry(i + index, v.getEntry(i));
         }
-
     }
 
     /**
@@ -519,22 +446,18 @@ public class SparseFieldVector<T extends
         if (v instanceof SparseFieldVector<?>) {
             return subtract((SparseFieldVector<T>)v);
         } else {
-            return subtract(v.toArray());
-        }
-    }
-
-    /** {@inheritDoc} */
-    public FieldVector<T> subtract(T[] v) {
-        checkVectorDimensions(v.length);
-        SparseFieldVector<T> res = new SparseFieldVector<T>(this);
-        for (int i = 0; i < v.length; i++) {
-            if (entries.containsKey(i)) {
-                res.setEntry(i, entries.get(i).subtract(v[i]));
-            } else {
-                res.setEntry(i, field.getZero().subtract(v[i]));
+            final int n = v.getDimension();
+            checkVectorDimensions(n);
+            SparseFieldVector<T> res = new SparseFieldVector<T>(this);
+            for (int i = 0; i < n; i++) {
+                if (entries.containsKey(i)) {
+                    res.setEntry(i, entries.get(i).subtract(v.getEntry(i)));
+                } else {
+                    res.setEntry(i, field.getZero().subtract(v.getEntry(i)));
+                }
             }
+            return res;
         }
-        return res;
     }
 
     /** {@inheritDoc} */
@@ -569,9 +492,16 @@ public class SparseFieldVector<T extends
     /** {@inheritDoc} */
     public FieldVector<T> add(FieldVector<T> v) {
         if (v instanceof SparseFieldVector<?>) {
-            return add((SparseFieldVector<T>)v);
+            return add((SparseFieldVector<T>) v);
         } else {
-            return add(v.toArray());
+            final int n = v.getDimension();
+            checkVectorDimensions(n);
+            SparseFieldVector<T> res = new SparseFieldVector<T>(field,
+                                                                getDimension());
+            for (int i = 0; i < n; i++) {
+                res.setEntry(i, v.getEntry(i).add(getEntry(i)));
+            }
+            return res;
         }
     }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java?rev=1172044&r1=1172043&r2=1172044&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java
Sat Sep 17 18:42:03 2011
@@ -342,10 +342,6 @@ public class ArrayFieldVectorTest {
         Assert.assertEquals(4, v_append_2.getDimension());
         Assert.assertEquals(new Fraction(2), v_append_2.getEntry(3));
 
-        FieldVector<Fraction> v_append_3 = v1.append(vec2);
-        Assert.assertEquals(6, v_append_3.getDimension());
-        Assert.assertEquals(new Fraction(4), v_append_3.getEntry(3));
-
         FieldVector<Fraction> v_append_4 = v1.append(v2_t);
         Assert.assertEquals(6, v_append_4.getDimension());
         Assert.assertEquals(new Fraction(4), v_append_4.getEntry(3));

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java?rev=1172044&r1=1172043&r2=1172044&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java
Sat Sep 17 18:42:03 2011
@@ -115,14 +115,14 @@ public class SparseFieldVectorTest {
         SparseFieldVector<Fraction> v1 = new SparseFieldVector<Fraction>(field,vec1);
         SparseFieldVector<Fraction> v2 = new SparseFieldVector<Fraction>(field,vec2);
 
-        SparseFieldVector<Fraction> v2_t = new SparseFieldVector<Fraction>(field,vec2);
+        FieldVector<Fraction> v2_t = new ArrayFieldVectorTest.FieldVectorTestImpl<Fraction>(vec2);
 
         //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);
 
-        SparseFieldVector<Fraction> vt2 = new SparseFieldVector<Fraction>(field,vec2);
+        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);



Mime
View raw message