@Test public void testSelf() { Vector x = first.like(); Vector xBase = new DenseVector(CARDINALITY); List<Double> items = Lists.newArrayList(); for (int i = 0; i < x.size(); ++i) { items.add(r.nextDouble()); } for (int i = 1; i < x.size(); ++i) { x.setQuick(i, items.get(i)); xBase.setQuick(i, items.get(i)); } Vector y = second.like().assign(x); Vector yBase = new DenseVector(x); System.out.printf("aggregator %s; combiner %s; operation %s\n", aggregator, combiner, operation); double expectedResult = combiner.apply(0, 0); for (int i = 1; i < x.size(); ++i) { expectedResult = aggregator.apply(expectedResult, combiner.apply(items.get(i), items.get(i))); } double result = operation.aggregate(x, y, aggregator, combiner); double resultBase = operation.aggregate(xBase, yBase, aggregator, combiner); assertEquals(expectedResult, result, 0.0); assertEquals(resultBase, result, 0.0); }
public abstract double aggregate(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc);
VectorBinaryAggregate { public abstract double aggregate(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc); }
VectorBinaryAggregate { public abstract double aggregate(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc);  }
VectorBinaryAggregate { public abstract double aggregate(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc);  abstract boolean isValid(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc); abstract double estimateCost(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc); abstract double aggregate(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc); static VectorBinaryAggregate getBestOperation(Vector x, Vector y, DoubleDoubleFunction fa,
                                                       DoubleDoubleFunction fc); static double aggregateBest(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc); }
VectorBinaryAggregate { public abstract double aggregate(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc);  abstract boolean isValid(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc); abstract double estimateCost(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc); abstract double aggregate(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc); static VectorBinaryAggregate getBestOperation(Vector x, Vector y, DoubleDoubleFunction fa,
                                                       DoubleDoubleFunction fc); static double aggregateBest(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc); static final VectorBinaryAggregate[] OPERATIONS; }