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);
}
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());
}
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);
}
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;
});
}
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());
}
Aggregations