use of org.eclipse.collections.api.ParallelIterable in project eclipse-collections by eclipse.
the class ParallelIterableTestCase method sumOfFloatConsistentRounding.
@Test
public void sumOfFloatConsistentRounding() {
FloatFunction<Integer> roundingSensitiveElementFunction = i -> (i <= 99995) ? 1.0e-18f : 1.0f;
MutableList<Integer> list = Interval.oneTo(100_000).toList().shuffleThis();
double baseline = this.getExpectedWith(list.toArray(new Integer[] {})).sumOfFloat(roundingSensitiveElementFunction);
for (Integer batchSize : BATCH_SIZES) {
this.batchSize = batchSize;
ParallelIterable<Integer> testCollection = this.newWith(list.toArray(new Integer[] {}));
Assert.assertEquals("Batch size: " + this.batchSize, baseline, testCollection.sumOfFloat(roundingSensitiveElementFunction), 1.0e-15d);
}
}
use of org.eclipse.collections.api.ParallelIterable in project eclipse-collections by eclipse.
the class ParallelIterableTestCase method sumOfDoubleConsistentRounding.
@Test
public void sumOfDoubleConsistentRounding() {
DoubleFunction<Integer> roundingSensitiveElementFunction = i -> (i <= 99995) ? 1.0e-18d : 1.0d;
MutableList<Integer> list = Interval.oneTo(100_000).toList().shuffleThis();
double baseline = this.getExpectedWith(list.toArray(new Integer[] {})).sumOfDouble(roundingSensitiveElementFunction);
for (Integer batchSize : BATCH_SIZES) {
this.batchSize = batchSize;
ParallelIterable<Integer> testCollection = this.newWith(list.toArray(new Integer[] {}));
Assert.assertEquals("Batch size: " + this.batchSize, baseline, testCollection.sumOfDouble(roundingSensitiveElementFunction), 1.0e-15d);
}
}
Aggregations