SparseFieldVector implements FieldVector<T>, Serializable { public FieldMatrix<T> outerProduct(SparseFieldVector<T> v) { final int n = v.getDimension(); SparseFieldMatrix<T> res = new SparseFieldMatrix<T>(field, virtualSize, n); OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator(); while (iter.hasNext()) { iter.advance(); OpenIntToFieldHashMap<T>.Iterator iter2 = v.entries.iterator(); while (iter2.hasNext()) { iter2.advance(); res.setEntry(iter.key(), iter2.key(), iter.value().multiply(iter2.value())); } } return res; } SparseFieldVector(Field<T> field);  SparseFieldVector(Field<T> field, int dimension); protected  SparseFieldVector(SparseFieldVector<T> v, int resize);  SparseFieldVector(Field<T> field, int dimension, int expectedSize);  SparseFieldVector(Field<T> field, T[] values);  SparseFieldVector(SparseFieldVector<T> v); FieldVector<T> add(SparseFieldVector<T> v); FieldVector<T> append(SparseFieldVector<T> v); FieldVector<T> append(FieldVector<T> v); FieldVector<T> append(T d); FieldVector<T> copy(); T dotProduct(FieldVector<T> v); FieldVector<T> ebeDivide(FieldVector<T> v); FieldVector<T> ebeMultiply(FieldVector<T> v); @Deprecated T[] getData(); int getDimension(); T getEntry(int index); Field<T> getField(); FieldVector<T> getSubVector(int index, int n); FieldVector<T> mapAdd(T d); FieldVector<T> mapAddToSelf(T d); FieldVector<T> mapDivide(T d); FieldVector<T> mapDivideToSelf(T d); FieldVector<T> mapInv(); FieldVector<T> mapInvToSelf(); FieldVector<T> mapMultiply(T d); FieldVector<T> mapMultiplyToSelf(T d); FieldVector<T> mapSubtract(T d); FieldVector<T> mapSubtractToSelf(T d); FieldMatrix<T> outerProduct(SparseFieldVector<T> v); FieldMatrix<T> outerProduct(FieldVector<T> v); FieldVector<T> projection(FieldVector<T> v); void set(T value); void setEntry(int index, T value); void setSubVector(int index, FieldVector<T> v); SparseFieldVector<T> subtract(SparseFieldVector<T> v); FieldVector<T> subtract(FieldVector<T> v); T[] toArray(); FieldVector<T> add(FieldVector<T> v); T walkInDefaultOrder(final FieldVectorPreservingVisitor<T> visitor); T walkInDefaultOrder(final FieldVectorPreservingVisitor<T> visitor,
                                final int start, final int end); T walkInOptimizedOrder(final FieldVectorPreservingVisitor<T> visitor); T walkInOptimizedOrder(final FieldVectorPreservingVisitor<T> visitor,
                                  final int start, final int end); T walkInDefaultOrder(final FieldVectorChangingVisitor<T> visitor); T walkInDefaultOrder(final FieldVectorChangingVisitor<T> visitor,
                                final int start, final int end); T walkInOptimizedOrder(final FieldVectorChangingVisitor<T> visitor); T walkInOptimizedOrder(final FieldVectorChangingVisitor<T> visitor,
                                  final int start, final int end); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testOuterProduct() { final SparseFieldVector<Fraction> u = new SparseFieldVector<Fraction>(FractionField.getInstance(), new Fraction[] {new Fraction(1), new Fraction(2), new Fraction(-3)}); final SparseFieldVector<Fraction> v = new SparseFieldVector<Fraction>(FractionField.getInstance(), new Fraction[] {new Fraction(4), new Fraction(-2)}); final FieldMatrix<Fraction> uv = u.outerProduct(v); final double tol = Math.ulp(1d); Assert.assertEquals(new Fraction(4).doubleValue(), uv.getEntry(0, 0).doubleValue(), tol); Assert.assertEquals(new Fraction(-2).doubleValue(), uv.getEntry(0, 1).doubleValue(), tol); Assert.assertEquals(new Fraction(8).doubleValue(), uv.getEntry(1, 0).doubleValue(), tol); Assert.assertEquals(new Fraction(-4).doubleValue(), uv.getEntry(1, 1).doubleValue(), tol); Assert.assertEquals(new Fraction(-12).doubleValue(), uv.getEntry(2, 0).doubleValue(), tol); Assert.assertEquals(new Fraction(6).doubleValue(), uv.getEntry(2, 1).doubleValue(), tol); }