本文整理汇总了Java中java.util.concurrent.atomic.DoubleAdder.doubleValue方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleAdder.doubleValue方法的具体用法?Java DoubleAdder.doubleValue怎么用?Java DoubleAdder.doubleValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.atomic.DoubleAdder
的用法示例。
在下文中一共展示了DoubleAdder.doubleValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDoubleAdder
import java.util.concurrent.atomic.DoubleAdder; //导入方法依赖的package包/类
static void testDoubleAdder() {
DoubleAdder a = new DoubleAdder();
a.add(20.1d);
DoubleAdder result = echo(a);
if (result.doubleValue() != a.doubleValue())
throw new RuntimeException("Unexpected doubleValue");
checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAdder$SerializationProxy");
}
示例2: evaluate
import java.util.concurrent.atomic.DoubleAdder; //导入方法依赖的package包/类
/**
* Returns a score for the recommendation list.
*
* @param recommendation recommendation list
* @return score of the metric to the recommendation
*/
@Override
public double evaluate(Recommendation<U, I> recommendation) {
RelevanceModel.UserRelevanceModel<U, I> userRelModel = relModel.getModel(recommendation.getUser());
UserIntentModel<U, I, F> uim = intentModel.getModel(recommendation.getUser());
DoubleAdder erria = new DoubleAdder();
Object2DoubleMap<F> pNoPrevRel = new Object2DoubleOpenHashMap<>();
pNoPrevRel.defaultReturnValue(0.0);
uim.getIntents().forEach(f -> pNoPrevRel.put(f, 1.0));
AtomicInteger rank = new AtomicInteger();
recommendation.getItems().stream().limit(cutoff).forEach(iv -> {
if (userRelModel.isRelevant(iv.v1)) {
double gain = userRelModel.gain(iv.v1);
uim.getItemIntents(iv.v1).forEach(f -> {
double red = pNoPrevRel.getDouble(f);
erria.add(uim.pf_u(f) * gain * red / (1.0 + rank.intValue()));
pNoPrevRel.put(f, red * (1 - gain));
});
}
rank.incrementAndGet();
});
return erria.doubleValue();
}
示例3: dist
import java.util.concurrent.atomic.DoubleAdder; //导入方法依赖的package包/类
/**
* Returns a function that returns the feature-based similarity to the
* features of an item.
*
* @param features1 stream of features of an item
* @return function that returns the feature-based similarity to the
* features of an item
*/
@Override
public ToDoubleFunction<Stream<Tuple2<F, Double>>> dist(Stream<Tuple2<F, Double>> features1) {
Object2DoubleMap<F> auxMap = new Object2DoubleOpenHashMap<>();
auxMap.defaultReturnValue(0.0);
DoubleAdder norm1 = new DoubleAdder();
features1.forEach(fv -> {
auxMap.put(fv.v1, fv.v2);
norm1.add(fv.v2 * fv.v2);
});
if (norm1.doubleValue() == 0) {
return features2 -> Double.NaN;
}
return features2 -> {
DoubleAdder prod = new DoubleAdder();
DoubleAdder norm2 = new DoubleAdder();
features2.forEach(fv -> {
prod.add(fv.v2 * auxMap.getDouble(fv.v1));
norm2.add(fv.v2 * fv.v2);
});
if (norm2.doubleValue() == 0) {
return Double.NaN;
}
return dist(prod.doubleValue(), norm1.doubleValue(), norm2.doubleValue());
};
}
示例4: dot
import java.util.concurrent.atomic.DoubleAdder; //导入方法依赖的package包/类
/**
* Will calculate and return the dot product of this 1D-structure and another input 1D-vector.
*
* @param vector Another 1D-structure
* @return The dot product
*/
default double dot(final Access1D<?> vector) {
final DoubleAdder retVal = new DoubleAdder();
Structure1D.loopMatching(this, vector, i -> retVal.add(this.doubleValue(i) * vector.doubleValue(i)));
return retVal.doubleValue();
}