Java Code Examples for java.util.stream.DoubleStream#generate()

The following examples show how to use java.util.stream.DoubleStream#generate() . 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: RandomVariableFromFloatArray.java    From finmath-lib with Apache License 2.0 5 votes vote down vote up
@Override
public DoubleStream getRealizationsStream() {
	if(isDeterministic()) {
		return DoubleStream.generate(new DoubleSupplier() {
			@Override
			public double getAsDouble() {
				return valueIfNonStochastic;
			}
		});
	} else {
		return Arrays.stream(getDoubleArray(realizations));
	}
}
 
Example 2
Source File: RandomVariableLazyEvaluation.java    From finmath-lib with Apache License 2.0 5 votes vote down vote up
@Override
public DoubleStream getRealizationsStream() {
	if(isDeterministic()) {
		return DoubleStream.generate(new DoubleSupplier() {
			@Override
			public double getAsDouble() {
				return valueIfNonStochastic;
			}
		});
	}
	else {
		return IntStream.range(0,size()).mapToDouble(realizations).parallel();
	}
}
 
Example 3
Source File: RandomVariableFromDoubleArray.java    From finmath-lib with Apache License 2.0 5 votes vote down vote up
@Override
public DoubleStream getRealizationsStream() {
	if(isDeterministic()) {
		return DoubleStream.generate(new DoubleSupplier() {
			@Override
			public double getAsDouble() {
				return valueIfNonStochastic;
			}
		});
	}
	else {
		return Arrays.stream(realizations);
	}
}
 
Example 4
Source File: RandomVariableFromFloatArray.java    From finmath-lib with Apache License 2.0 5 votes vote down vote up
@Override
public DoubleStream getRealizationsStream() {
	if(isDeterministic()) {
		return DoubleStream.generate(new DoubleSupplier() {
			@Override
			public double getAsDouble() {
				return valueIfNonStochastic;
			}
		});
	} else {
		return Arrays.stream(getDoubleArray(realizations));
	}
}
 
Example 5
Source File: RandomVariableLazyEvaluation.java    From finmath-lib with Apache License 2.0 5 votes vote down vote up
@Override
public DoubleStream getRealizationsStream() {
	if(isDeterministic()) {
		return DoubleStream.generate(new DoubleSupplier() {
			@Override
			public double getAsDouble() {
				return valueIfNonStochastic;
			}
		});
	}
	else {
		return IntStream.range(0,size()).mapToDouble(realizations).parallel();
	}
}
 
Example 6
Source File: RandomVariableFromDoubleArray.java    From finmath-lib with Apache License 2.0 5 votes vote down vote up
@Override
public DoubleStream getRealizationsStream() {
	if(isDeterministic()) {
		return DoubleStream.generate(new DoubleSupplier() {
			@Override
			public double getAsDouble() {
				return valueIfNonStochastic;
			}
		});
	}
	else {
		return Arrays.stream(realizations);
	}
}
 
Example 7
Source File: MockUnitDouble.java    From mockneat with Apache License 2.0 2 votes vote down vote up
/**
 * <p>Transforms an existing {@code MockUnitDouble} into a {@code MockUnit<DoubleStream>}.</p>
 *
 * <p>The DoubleStream will be "infinite" and will contain values generated by the internal {@code MockUnitDouble} supplier.</p>
 *
 * @return A new {@code MockUnit<DoubleStream>}
 */
default MockUnit<DoubleStream> doubleStream() {
    Supplier<DoubleStream> supp = () -> DoubleStream.generate(supplier()::get);
    return () -> supp;
}