Search in sources :

Example 6 with DoubleSummaryStatistics

use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.

the class InternalArrayIterate method summarizeDouble.

/**
 * @since 8.0
 */
public static <T> DoubleSummaryStatistics summarizeDouble(T[] items, int size, DoubleFunction<? super T> function) {
    DoubleSummaryStatistics stats = new DoubleSummaryStatistics();
    for (int i = 0; i < size; i++) {
        T item = items[i];
        stats.accept(function.doubleValueOf(item));
    }
    return stats;
}
Also used : DoubleSummaryStatistics(java.util.DoubleSummaryStatistics)

Example 7 with DoubleSummaryStatistics

use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.

the class AbstractRichIterableTestCase method summarizeDouble.

@Test
public void summarizeDouble() {
    RichIterable<Integer> objects = this.newWith(1, 2, 3);
    DoubleSummaryStatistics expected = objects.summarizeDouble(Integer::doubleValue);
    Assert.assertEquals(6.0d, expected.getSum(), 0.0);
    Assert.assertEquals(3, expected.getCount());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DoubleSummaryStatistics(java.util.DoubleSummaryStatistics) Test(org.junit.Test)

Example 8 with DoubleSummaryStatistics

use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.

the class RichIterable method summarizeFloat.

/**
 * Returns the result of summarizing the value returned from applying the FloatFunction to
 * each element of the iterable.
 * <p>
 * <pre>
 * DoubleSummaryStatistics stats =
 *     Lists.mutable.with(1, 2, 3).summarizeFloat(Integer::floatValue);
 * </pre>
 *
 * @since 8.0
 */
default DoubleSummaryStatistics summarizeFloat(FloatFunction<? super T> function) {
    DoubleSummaryStatistics stats = new DoubleSummaryStatistics();
    this.each(each -> stats.accept(function.floatValueOf(each)));
    return stats;
}
Also used : DoubleSummaryStatistics(java.util.DoubleSummaryStatistics)

Example 9 with DoubleSummaryStatistics

use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.

the class Bag method summarizeFloat.

/**
 * @since 8.0
 */
@Override
default DoubleSummaryStatistics summarizeFloat(FloatFunction<? super T> function) {
    DoubleSummaryStatistics stats = new DoubleSummaryStatistics();
    this.forEachWithOccurrences((each, occurrences) -> {
        float result = function.floatValueOf(each);
        for (int i = 0; i < occurrences; i++) {
            stats.accept(result);
        }
    });
    return stats;
}
Also used : DoubleSummaryStatistics(java.util.DoubleSummaryStatistics)

Example 10 with DoubleSummaryStatistics

use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.

the class Bag method summarizeDouble.

/**
 * @since 8.0
 */
@Override
default DoubleSummaryStatistics summarizeDouble(DoubleFunction<? super T> function) {
    DoubleSummaryStatistics stats = new DoubleSummaryStatistics();
    this.forEachWithOccurrences((each, occurrences) -> {
        double result = function.doubleValueOf(each);
        for (int i = 0; i < occurrences; i++) {
            stats.accept(result);
        }
    });
    return stats;
}
Also used : DoubleSummaryStatistics(java.util.DoubleSummaryStatistics)

Aggregations

DoubleSummaryStatistics (java.util.DoubleSummaryStatistics)39 Arrays (java.util.Arrays)9 List (java.util.List)9 Test (org.junit.Test)9 Layer (com.simiacryptus.mindseye.lang.Layer)8 Tensor (com.simiacryptus.mindseye.lang.Tensor)8 LongSummaryStatistics (java.util.LongSummaryStatistics)8 IntStream (java.util.stream.IntStream)8 Nonnull (javax.annotation.Nonnull)8 Nullable (javax.annotation.Nullable)8 TrainingMonitor (com.simiacryptus.mindseye.opt.TrainingMonitor)7 Map (java.util.Map)6 LoggingWrapperLayer (com.simiacryptus.mindseye.layers.java.LoggingWrapperLayer)5 MonitoringWrapperLayer (com.simiacryptus.mindseye.layers.java.MonitoringWrapperLayer)5 StochasticComponent (com.simiacryptus.mindseye.layers.java.StochasticComponent)5 DAGNetwork (com.simiacryptus.mindseye.network.DAGNetwork)5 DAGNode (com.simiacryptus.mindseye.network.DAGNode)5 Step (com.simiacryptus.mindseye.opt.Step)5 MonitoredObject (com.simiacryptus.util.MonitoredObject)5 DoubleStatistics (com.simiacryptus.util.data.DoubleStatistics)5