本文整理汇总了Java中java.util.function.ToDoubleBiFunction.applyAsDouble方法的典型用法代码示例。如果您正苦于以下问题:Java ToDoubleBiFunction.applyAsDouble方法的具体用法?Java ToDoubleBiFunction.applyAsDouble怎么用?Java ToDoubleBiFunction.applyAsDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.function.ToDoubleBiFunction
的用法示例。
在下文中一共展示了ToDoubleBiFunction.applyAsDouble方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: integrate2d
import java.util.function.ToDoubleBiFunction; //导入方法依赖的package包/类
public static double integrate2d(final ToDoubleBiFunction<Double, Double> getIntegrand,
final double xLowerBound, final double xUpperBound, final int xNumPoints,
final double yLowerBound, final double yUpperBound, final int yNumPoints){
final GaussIntegrator xIntegrator = integratorFactory.legendre(xNumPoints, xLowerBound, xUpperBound);
final GaussIntegrator yIntegrator = integratorFactory.legendre(yNumPoints, yLowerBound, yUpperBound);
final double[] xIntegrationWeights = new IndexRange(0, xNumPoints).mapToDouble(xIntegrator::getWeight);
final double[] xAbscissas = new IndexRange(0, xNumPoints).mapToDouble(xIntegrator::getPoint);
final double[] yIntegrationWeights = new IndexRange(0, yNumPoints).mapToDouble(yIntegrator::getWeight);
final double[] yAbscissas = new IndexRange(0, yNumPoints).mapToDouble(yIntegrator::getPoint);
double integral = 0;
for (int i = 0; i < xNumPoints; i++) {
final double x = xAbscissas[i];
for (int j = 0; j < yNumPoints; j++) {
final double y = yAbscissas[j];
final double integrand = getIntegrand.applyAsDouble(x, y);
integral += xIntegrationWeights[i] * yIntegrationWeights[j] * integrand;
}
}
return integral;
}
示例2: sum
import java.util.function.ToDoubleBiFunction; //导入方法依赖的package包/类
@Override
public double sum(ToDoubleBiFunction<? super Integer, ? super T> mapper) {
ToDoubleFunction<T> function;
if (!isParallel()) {
// use fast sequential counting
function = new ToDoubleFunction<T>() {
int i = 0;
@Override
public double applyAsDouble(T t) {
return mapper.applyAsDouble(i++, t);
}
};
}
else {
// retrieve each index individually
function = new ToDoubleFunction<T>() {
List<T> list = stream().collect(Collectors.toList());
@Override
public double applyAsDouble(T t) {
return mapper.applyAsDouble(list.indexOf(t), t);
}
};
}
return stream().collect(Collectors.summingDouble(function));
}
示例3: selfSimilarity
import java.util.function.ToDoubleBiFunction; //导入方法依赖的package包/类
/**
* Creates a self-similarity view of the given matrix, interpreting rows as features vectors.
*
* @param m source matrix
* @param similarityFunction similarity function
* @return self-similarity matrix
*/
private Matrix selfSimilarity(final Matrix m, final ToDoubleBiFunction<float[], float[]> similarityFunction) {
return new AbstractSelfSimilarityMatrix(m) {
@Override
public float get(final int row, final int column) {
return (float)similarityFunction.applyAsDouble(m.getRow(row), m.getRow(column));
}
};
}
示例4: F
import java.util.function.ToDoubleBiFunction; //导入方法依赖的package包/类
F(ToDoubleBiFunction<T1, T2> toDoubleBiFunction) {
this(new BiFunction<T1, T2, R>() {
@Override
public R apply(T1 t, T2 u) {
return (R)(Double)toDoubleBiFunction.applyAsDouble(t, u);
}
});
}
示例5: assertToDoubleBiFunction
import java.util.function.ToDoubleBiFunction; //导入方法依赖的package包/类
private <E extends Exception> void assertToDoubleBiFunction(ToDoubleBiFunction<Object, Object> test, Class<E> type) {
assertNotNull(test);
try {
test.applyAsDouble(null, null);
fail();
}
catch (Exception e) {
assertException(type, e, "null:null");
}
}
示例6: apply
import java.util.function.ToDoubleBiFunction; //导入方法依赖的package包/类
/**
* Applies the given operator to each value of the <code>Matrix</code>, in
* order.
* <p>
* The function is given a <code>double</code> value that is the current
* value at the given position, and a <code>int</code> array index position.
* The index-less version of this method is
* {@link #apply(DoubleUnaryOperator)}, which avoids boxing values. The
* return value of the function is saved to each index of the backing array.
*
* @param function
* the function to apply, as described.
* @return this object, for chaining calls.
*/
public Matrix apply(ToDoubleBiFunction<Double, Integer> function)
{
checkNotNull(function, "function");
for(int i = 0; i < data.length; i++)
data[i] = function.applyAsDouble(data[i], i);
return this;
}
示例7: call
import java.util.function.ToDoubleBiFunction; //导入方法依赖的package包/类
/**
* Calls the given {@link ToDoubleBiFunction} with the given arguments and returns its result.
*
* @param <T> The type of the first argument to the function
* @param <U> The type of the second argument to the function
* @param function The function to be called
* @param t The first argument to the function
* @param u The second argument to the function
* @return The result from the given {@code ToDoubleBiFunction2}.
* @throws NullPointerException If given argument is {@code null}
*/
static <T, U> double call(@Nonnull final ToDoubleBiFunction<? super T, ? super U> function, T t, U u) {
Objects.requireNonNull(function);
return function.applyAsDouble(t, u);
}