当前位置: 首页>>代码示例>>Java>>正文


Java ToDoubleBiFunction.applyAsDouble方法代码示例

本文整理汇总了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;
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:25,代码来源:IntegrationUtils.java

示例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));
}
 
开发者ID:codebulb,项目名称:LambdaOmega,代码行数:26,代码来源:L.java

示例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));
        }

    };
}
 
开发者ID:hendriks73,项目名称:separator,代码行数:17,代码来源:SelfSimilarityFunction.java

示例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);
        }
    });
}
 
开发者ID:codebulb,项目名称:LambdaOmega,代码行数:9,代码来源:F.java

示例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");
    }
}
 
开发者ID:jOOQ,项目名称:jOOL,代码行数:11,代码来源:CheckedBiFunctionTest.java

示例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;
}
 
开发者ID:saybur,项目名称:fractala,代码行数:23,代码来源:Matrix.java

示例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);
}
 
开发者ID:gridtec,项目名称:lambda4j,代码行数:16,代码来源:ToDoubleBiFunction2.java


注:本文中的java.util.function.ToDoubleBiFunction.applyAsDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。