本文整理汇总了Java中edu.berkeley.nlp.math.SloppyMath.isDangerous方法的典型用法代码示例。如果您正苦于以下问题:Java SloppyMath.isDangerous方法的具体用法?Java SloppyMath.isDangerous怎么用?Java SloppyMath.isDangerous使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.berkeley.nlp.math.SloppyMath
的用法示例。
在下文中一共展示了SloppyMath.isDangerous方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scaleArrayToScale
import edu.berkeley.nlp.math.SloppyMath; //导入方法依赖的package包/类
public static void scaleArrayToScale(double[] scores, int previousScale,
int newScale) {
int scaleDiff = previousScale - newScale;
if (scaleDiff == 0)
return; // nothing to do
double max = DoubleArrays.max(scores);
if (SloppyMath.isDangerous(max))
return;
double scale = calcScaleFactor(scaleDiff);
if (Math.abs(scaleDiff) >= 800) {
// under-/overflow...
Arrays.fill(scores, 0.0);
return;
}
for (int i = 0; i < scores.length; i++) {
scores[i] *= scale;
}
// if (SloppyMath.isDangerous(ArrayMath.max(scores))){
// System.out.println("Undeflow when scaling scores!");
// }
}
示例2: scaleToScale
import edu.berkeley.nlp.math.SloppyMath; //导入方法依赖的package包/类
public static double scaleToScale(double score, int previousScale,
int newScale) {
int scaleDiff = previousScale - newScale;
if (scaleDiff == 0)
return score; // nothing to do
double max = score;
if (SloppyMath.isDangerous(max))
return 0;
double scale = calcScaleFactor(scaleDiff);
if (Math.abs(scaleDiff) >= 800) {
// under-/overflow...
return 0;
}
score *= scale;
return score;
}