Search in sources :

Example 1 with DoubleSupplier

use of java.util.function.DoubleSupplier in project geode by apache.

the class StatisticsImplTest method invokeDoubleSuppliersShouldUpdateStats.

@Test
public void invokeDoubleSuppliersShouldUpdateStats() {
    DoubleSupplier supplier1 = mock(DoubleSupplier.class);
    when(supplier1.getAsDouble()).thenReturn(23.3);
    stats.setDoubleSupplier(4, supplier1);
    assertEquals(0, stats.invokeSuppliers());
    verify(supplier1).getAsDouble();
    assertEquals(23.3, stats.getDouble(4), 0.1f);
}
Also used : DoubleSupplier(java.util.function.DoubleSupplier) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 2 with DoubleSupplier

use of java.util.function.DoubleSupplier in project intellij-community by JetBrains.

the class Main method test.

public void test(String... list) {
    DoubleSupplier s = () -> Stream.of(list).filter(Objects::nonNull).co < caret > llect(Collectors.averagingLong(String::length));
    System.out.println(s.getAsDouble());
}
Also used : DoubleSupplier(java.util.function.DoubleSupplier)

Example 3 with DoubleSupplier

use of java.util.function.DoubleSupplier in project BuildCraft by BuildCraft.

the class GuiUtil method moveAreaToCentre.

public static IGuiArea moveAreaToCentre(IGuiArea area) {
    if (area instanceof GuiRectangle || area instanceof IConstantNode) {
        return moveRectangleToCentre(area.asImmutable());
    }
    DoubleSupplier posX = () -> (AREA_WHOLE_SCREEN.getWidth() - area.getWidth()) / 2;
    DoubleSupplier posY = () -> (AREA_WHOLE_SCREEN.getHeight() - area.getHeight()) / 2;
    return IGuiArea.create(posX, posY, area::getWidth, area::getHeight);
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle) DoubleSupplier(java.util.function.DoubleSupplier) IConstantNode(buildcraft.lib.expression.api.IConstantNode)

Example 4 with DoubleSupplier

use of java.util.function.DoubleSupplier in project MindsEye by SimiaCryptus.

the class RecursiveSubspaceTest method buildModel.

@Override
public DAGNetwork buildModel(@Nonnull NotebookOutput log) {
    log.h3("Model");
    log.p("We use a multi-level convolution network");
    return log.code(() -> {
        @Nonnull final PipelineNetwork network = new PipelineNetwork();
        double weight = 1e-3;
        @Nonnull DoubleSupplier init = () -> weight * (Math.random() - 0.5);
        network.add(new ConvolutionLayer(3, 3, 1, 5).set(init));
        network.add(new ImgBandBiasLayer(5));
        network.add(new PoolingLayer().setMode(PoolingLayer.PoolingMode.Max));
        network.add(new ActivationLayer(ActivationLayer.Mode.RELU));
        network.add(newNormalizationLayer());
        network.add(new ConvolutionLayer(3, 3, 5, 5).set(init));
        network.add(new ImgBandBiasLayer(5));
        network.add(new PoolingLayer().setMode(PoolingLayer.PoolingMode.Max));
        network.add(new ActivationLayer(ActivationLayer.Mode.RELU));
        network.add(newNormalizationLayer());
        network.add(new BiasLayer(7, 7, 5));
        network.add(new FullyConnectedLayer(new int[] { 7, 7, 5 }, new int[] { 10 }).set(init));
        network.add(new SoftmaxActivationLayer());
        return network;
    });
}
Also used : SoftmaxActivationLayer(com.simiacryptus.mindseye.layers.java.SoftmaxActivationLayer) FullyConnectedLayer(com.simiacryptus.mindseye.layers.java.FullyConnectedLayer) ImgBandBiasLayer(com.simiacryptus.mindseye.layers.cudnn.ImgBandBiasLayer) ActivationLayer(com.simiacryptus.mindseye.layers.cudnn.ActivationLayer) SoftmaxActivationLayer(com.simiacryptus.mindseye.layers.java.SoftmaxActivationLayer) Nonnull(javax.annotation.Nonnull) DoubleSupplier(java.util.function.DoubleSupplier) PoolingLayer(com.simiacryptus.mindseye.layers.cudnn.PoolingLayer) PipelineNetwork(com.simiacryptus.mindseye.network.PipelineNetwork) ConvolutionLayer(com.simiacryptus.mindseye.layers.cudnn.ConvolutionLayer) ImgBandBiasLayer(com.simiacryptus.mindseye.layers.cudnn.ImgBandBiasLayer) BiasLayer(com.simiacryptus.mindseye.layers.java.BiasLayer)

Example 5 with DoubleSupplier

use of java.util.function.DoubleSupplier in project symja_android_library by axkr.

the class FractionTestCase method getRandomStream.

private DoubleStream getRandomStream() {
    Random rnd = new Random();
    int maxExp = 308;
    IntSupplier sign = () -> (rnd.nextBoolean() ? -1 : 1);
    DoubleSupplier mantissa = rnd::nextDouble;
    DoubleSupplier power = () -> Math.pow(10, rnd.nextInt(2 * maxExp) - maxExp);
    return IntStream.range(0, 10_000).mapToDouble(i -> sign.getAsInt() * mantissa.getAsDouble() * power.getAsDouble());
}
Also used : Random(java.util.Random) IntSupplier(java.util.function.IntSupplier) DoubleSupplier(java.util.function.DoubleSupplier)

Aggregations

DoubleSupplier (java.util.function.DoubleSupplier)10 IGuiPosition (buildcraft.lib.gui.pos.IGuiPosition)2 IConstantNode (buildcraft.lib.expression.api.IConstantNode)1 GuiElementText (buildcraft.lib.gui.elem.GuiElementText)1 GuiRectangle (buildcraft.lib.gui.pos.GuiRectangle)1 ActivationLayer (com.simiacryptus.mindseye.layers.cudnn.ActivationLayer)1 ConvolutionLayer (com.simiacryptus.mindseye.layers.cudnn.ConvolutionLayer)1 ImgBandBiasLayer (com.simiacryptus.mindseye.layers.cudnn.ImgBandBiasLayer)1 PoolingLayer (com.simiacryptus.mindseye.layers.cudnn.PoolingLayer)1 BiasLayer (com.simiacryptus.mindseye.layers.java.BiasLayer)1 FullyConnectedLayer (com.simiacryptus.mindseye.layers.java.FullyConnectedLayer)1 SoftmaxActivationLayer (com.simiacryptus.mindseye.layers.java.SoftmaxActivationLayer)1 PipelineNetwork (com.simiacryptus.mindseye.network.PipelineNetwork)1 ModularUI (gregtech.api.gui.ModularUI)1 LabelWidget (gregtech.api.gui.widgets.LabelWidget)1 ProgressWidget (gregtech.api.gui.widgets.ProgressWidget)1 ServerWidgetGroup (gregtech.api.gui.widgets.ServerWidgetGroup)1 SlotWidget (gregtech.api.gui.widgets.SlotWidget)1 Random (java.util.Random)1 IntSupplier (java.util.function.IntSupplier)1