java.util.function.IntToDoubleFunction Java Examples
The following examples show how to use
java.util.function.IntToDoubleFunction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntPipeline.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #2
Source File: IntPipeline.java From Bytecoder with Apache License 2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #3
Source File: WriteReadTest.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
private static ExampleSet createExampleSetNumFloat(int columns, int rows, boolean allowIntegers) { List<Attribute> attributes = IntStream.range(0, columns).mapToObj(i -> "att-" + i + "-" + (allowIntegers && i % 2 == 1)) .map(name -> AttributeFactory.createAttribute(name, name.endsWith("true") ? Ontology.INTEGER : Ontology.REAL)) .collect(Collectors.toList()); ExampleSetBuilder builder = ExampleSets.from(attributes).withBlankSize(rows); IntToDoubleFunction doubleFiller = i -> (float) rng.nextDouble(); IntToDoubleFunction intFiller = i -> (float)rng.nextInt(); attributes.forEach(att -> builder.withColumnFiller(att, att.getValueType() == Ontology.REAL ? doubleFiller : intFiller)); ExampleSet build = builder.build(); build.getAnnotations().put("bla", "blup"); build.getAnnotations().put("blabla", "blupblup"); build.recalculateAllAttributeStatistics(); return build; }
Example #4
Source File: WriteReadTest.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
private static ExampleSet createExampleSetNum(int columns, int rows, boolean allowIntegers) { List<Attribute> attributes = IntStream.range(0, columns).mapToObj(i -> "att-" + i + "-" + (allowIntegers && i % 2 == 1)) .map(name -> AttributeFactory.createAttribute(name, name.endsWith("true") ? Ontology.INTEGER : Ontology.REAL)) .collect(Collectors.toList()); ExampleSetBuilder builder = ExampleSets.from(attributes).withBlankSize(rows); IntToDoubleFunction doubleFiller = i -> rng.nextDouble(); IntToDoubleFunction intFiller = i -> rng.nextInt(); attributes.forEach(att -> builder.withColumnFiller(att, att.getValueType() == Ontology.REAL ? doubleFiller : intFiller)); ExampleSet build = builder.build(); build.getAnnotations().put("bla", "blup"); build.getAnnotations().put("blabla", "blupblup"); build.recalculateAllAttributeStatistics(); return build; }
Example #5
Source File: WriteReadTest.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
private static ExampleSet createExampleSetNumNoFractions(int columns, int rows, boolean allowIntegers) { List<Attribute> attributes = IntStream.range(0, columns).mapToObj(i -> "att-" + i + "-" + (allowIntegers && i % 2 == 1)) .map(name -> AttributeFactory.createAttribute(name, name.endsWith("true") ? Ontology.INTEGER : Ontology.REAL)) .collect(Collectors.toList()); ExampleSetBuilder builder = ExampleSets.from(attributes).withBlankSize(rows); IntToDoubleFunction doubleFiller = i -> (int) (rng.nextDouble() * 1000); IntToDoubleFunction intFiller = i -> rng.nextInt(); attributes.forEach(att -> builder.withColumnFiller(att, att.getValueType() == Ontology.REAL ? doubleFiller : intFiller)); ExampleSet build = builder.build(); build.getAnnotations().put("bla", "blup"); build.getAnnotations().put("blabla", "blupblup"); build.recalculateAllAttributeStatistics(); return build; }
Example #6
Source File: RandomVariableLazyEvaluation.java From finmath-lib with Apache License 2.0 | 6 votes |
@Override public RandomVariable cache() { synchronized (this) { if(realizationsArray == null) { realizationsArray = getRealizationsStream().toArray(); realizations = new IntToDoubleFunction() { @Override public double applyAsDouble(final int i) { return realizationsArray[i]; } }; } } return this; }
Example #7
Source File: IntPipeline.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #8
Source File: IntPipeline.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #9
Source File: IntPipeline.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #10
Source File: RandomVariableLazyEvaluation.java From finmath-lib with Apache License 2.0 | 6 votes |
@Override public RandomVariable apply(final DoubleUnaryOperator operator) { if(isDeterministic()) { return new RandomVariableLazyEvaluation(time, operator.applyAsDouble(valueIfNonStochastic)); } else { final IntToDoubleFunction newRealizations = new IntToDoubleFunction() { @Override public double applyAsDouble(final int i) { return operator.applyAsDouble(realizations.applyAsDouble(i)); } }; return new RandomVariableLazyEvaluation(time, newRealizations, size()); } }
Example #11
Source File: RandomVariableFromDoubleArray.java From finmath-lib with Apache License 2.0 | 6 votes |
/** * Create a stochastic random variable. * * @param time the filtration time, set to 0.0 if not used. * @param realizations A map mapping integer (path or state) to double, representing this random variable. * @param size The size, i.e., number of paths. * @param typePriority The priority of this type in construction of result types. See "operator type priority" for details. */ public RandomVariableFromDoubleArray(final double time, final IntToDoubleFunction realizations, final int size, final int typePriority) { super(); this.time = time; this.realizations = size == 1 ? null : new double[size];//IntStream.range(0,size).parallel().mapToDouble(realisations).toArray(); valueIfNonStochastic = size == 1 ? realizations.applyAsDouble(0) : Double.NaN; if(size > 1) { IntStream.range(0,size).parallel().forEach(new IntConsumer() { @Override public void accept(final int i) { RandomVariableFromDoubleArray.this.realizations[i] = realizations.applyAsDouble(i); } } ); } this.typePriority = typePriority; }
Example #12
Source File: IntPipeline.java From desugar_jdk_libs with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #13
Source File: RandomVariableFromDoubleArray.java From finmath-lib with Apache License 2.0 | 6 votes |
@Override public RandomVariable apply(final DoubleTernaryOperator operator, final RandomVariable argument1, final RandomVariable argument2) { double newTime = Math.max(time, argument1.getFiltrationTime()); newTime = Math.max(newTime, argument2.getFiltrationTime()); final int newSize = Math.max(Math.max(this.size(), argument1.size()), argument2.size()); final IntToDoubleFunction argument0Operator = this.getOperator(); final IntToDoubleFunction argument1Operator = argument1.getOperator(); final IntToDoubleFunction argument2Operator = argument2.getOperator(); final IntToDoubleFunction result = new IntToDoubleFunction() { @Override public double applyAsDouble(final int i) { return operator.applyAsDouble(argument0Operator.applyAsDouble(i), argument1Operator.applyAsDouble(i), argument2Operator.applyAsDouble(i)); } }; return new RandomVariableFromDoubleArray(newTime, result, newSize); }
Example #14
Source File: IntPipeline.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #15
Source File: IntPipeline.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #16
Source File: AbstractVector.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public Vector assign(IntToDoubleFunction fun) { assert fun != null; if (sto.isArrayBased()) { ensureReadOnly(); Arrays.setAll(sto.data(), fun); } else { int len = size(); for (int i = 0; i < len; i++) storageSet(i, fun.applyAsDouble(i)); } return this; }
Example #17
Source File: IntPipeline.java From JDKSourceCode1.8 with MIT License | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #18
Source File: RandomVariableLazyEvaluation.java From finmath-lib with Apache License 2.0 | 6 votes |
@Override public RandomVariable cache() { synchronized (this) { if(realizationsArray == null) { realizationsArray = getRealizationsStream().toArray(); realizations = new IntToDoubleFunction() { @Override public double applyAsDouble(final int i) { return realizationsArray[i]; } }; } } return this; }
Example #19
Source File: IntPipeline.java From j2objc with Apache License 2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override public Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #20
Source File: RandomVariableFromFloatArray.java From finmath-lib with Apache License 2.0 | 6 votes |
@Override public RandomVariable apply(final DoubleTernaryOperator operator, final RandomVariable argument1, final RandomVariable argument2) { double newTime = Math.max(time, argument1.getFiltrationTime()); newTime = Math.max(newTime, argument2.getFiltrationTime()); final int newSize = Math.max(Math.max(this.size(), argument1.size()), argument2.size()); final IntToDoubleFunction argument0Operator = this.getOperator(); final IntToDoubleFunction argument1Operator = argument1.getOperator(); final IntToDoubleFunction argument2Operator = argument2.getOperator(); final IntToDoubleFunction result = new IntToDoubleFunction() { @Override public double applyAsDouble(final int i) { return operator.applyAsDouble(argument0Operator.applyAsDouble(i), argument1Operator.applyAsDouble(i), argument2Operator.applyAsDouble(i)); } }; return new RandomVariableFromFloatArray(newTime, result, newSize); }
Example #21
Source File: RandomVariableFromFloatArray.java From finmath-lib with Apache License 2.0 | 6 votes |
/** * Create a stochastic random variable. * * @param time the filtration time, set to 0.0 if not used. * @param realizations A map mapping integer (path or state) to double, representing this random variable. * @param size The size, i.e., number of paths. * @param typePriority The priority of this type in construction of result types. See "operator type priority" for details. */ public RandomVariableFromFloatArray(final double time, final IntToDoubleFunction realizations, final int size, final int typePriority) { super(); this.time = time; this.realizations = size == 1 ? null : new float[size];//IntStream.range(0,size).parallel().mapToDouble(realisations).toArray(); valueIfNonStochastic = size == 1 ? realizations.applyAsDouble(0) : Double.NaN; if(size > 1) { IntStream.range(0,size).parallel().forEach(new IntConsumer() { @Override public void accept(final int i) { RandomVariableFromFloatArray.this.realizations[i] = (float) realizations.applyAsDouble(i); } } ); } this.typePriority = typePriority; }
Example #22
Source File: IntPipeline.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #23
Source File: IntPipeline.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #24
Source File: IntPipeline.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream mapToDouble(IntToDoubleFunction mapper) { Objects.requireNonNull(mapper); return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedInt<Double>(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); } }; } }; }
Example #25
Source File: InputDevice.java From strongback-java with MIT License | 6 votes |
/** * Create an input device from the supplied mapping functions. * @param axisToValue the function that maps an integer to a double value for the axis * @param buttonNumberToSwitch the function that maps an integer to whether the button is pressed * @param padToValue the function that maps an integer to the directional axis output * @return the resulting input device; never null */ public static InputDevice create( IntToDoubleFunction axisToValue, IntToBooleanFunction buttonNumberToSwitch, IntToIntFunction padToValue ) { return new InputDevice() { @Override public ContinuousRange getAxis(int axis) { return ()->axisToValue.applyAsDouble(axis); } @Override public Switch getButton(int button) { return ()->buttonNumberToSwitch.applyAsBoolean(button); } @Override public DirectionalAxis getDPad(int pad) { return ()->padToValue.applyAsInt(pad); } }; }
Example #26
Source File: SetAllTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "double") public void testSetAllDouble(String name, int size, IntToDoubleFunction generator, double[] expected) { double[] result = new double[size]; Arrays.setAll(result, generator); assertDoubleArrayEquals(result, expected, 0.05, "setAll(double[], IntToDoubleFunction) case " + name + " failed."); // ensure fresh array result = new double[size]; Arrays.parallelSetAll(result, generator); assertDoubleArrayEquals(result, expected, 0.05, "setAll(double[], IntToDoubleFunction) case " + name + " failed."); }
Example #27
Source File: SetAllTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "double") public void testSetAllDouble(String name, int size, IntToDoubleFunction generator, double[] expected) { double[] result = new double[size]; Arrays.setAll(result, generator); assertDoubleArrayEquals(result, expected, 0.05, "setAll(double[], IntToDoubleFunction) case " + name + " failed."); // ensure fresh array result = new double[size]; Arrays.parallelSetAll(result, generator); assertDoubleArrayEquals(result, expected, 0.05, "setAll(double[], IntToDoubleFunction) case " + name + " failed."); }
Example #28
Source File: SetAllTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "double") public void testSetAllDouble(String name, int size, IntToDoubleFunction generator, double[] expected) { double[] result = new double[size]; Arrays.setAll(result, generator); assertDoubleArrayEquals(result, expected, 0.05, "setAll(double[], IntToDoubleFunction) case " + name + " failed."); // ensure fresh array result = new double[size]; Arrays.parallelSetAll(result, generator); assertDoubleArrayEquals(result, expected, 0.05, "setAll(double[], IntToDoubleFunction) case " + name + " failed."); }
Example #29
Source File: WriteReadTest.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
private static ExampleSet createExampleSetDatetime(int columns, int rows, boolean date) { List<Attribute> attributes = IntStream.range(0, columns).mapToObj(i -> "att-" + i + "-" + (date && i % 2 == 1)) .map(name -> AttributeFactory.createAttribute(name, name.endsWith("true") ? Ontology.DATE : Ontology.DATE_TIME)) .collect(Collectors.toList()); ExampleSetBuilder builder = ExampleSets.from(attributes).withBlankSize(rows); IntToDoubleFunction datetimeFiller = i -> rng.nextInt() * 1000001; IntToDoubleFunction dateFiller = i -> (rng.nextInt() * 1000000) / 1000 * 1000; attributes.forEach(att -> builder.withColumnFiller(att, att.getValueType() == Ontology.DATE_TIME ? datetimeFiller : dateFiller)); ExampleSet build = builder.build(); build.getAnnotations().put("bla", "blup"); build.recalculateAllAttributeStatistics(); return build; }
Example #30
Source File: SetAllTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "double") public void testSetAllDouble(String name, int size, IntToDoubleFunction generator, double[] expected) { double[] result = new double[size]; Arrays.setAll(result, generator); assertDoubleArrayEquals(result, expected, 0.05, "setAll(double[], IntToDoubleFunction) case " + name + " failed."); // ensure fresh array result = new double[size]; Arrays.parallelSetAll(result, generator); assertDoubleArrayEquals(result, expected, 0.05, "setAll(double[], IntToDoubleFunction) case " + name + " failed."); }