本文整理了Java中java.lang.Double.isFinite()
方法的一些代码示例,展示了Double.isFinite()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Double.isFinite()
方法的具体详情如下:
包路径:java.lang.Double
类名称:Double
方法名:isFinite
暂无
代码示例来源:origin: apache/incubator-druid
@Override
public int compare(Double lhs, Double rhs)
{
if (Double.isFinite(lhs) && !Double.isFinite(rhs)) {
return 1;
}
if (!Double.isFinite(lhs) && Double.isFinite(rhs)) {
return -1;
}
return Double.compare(lhs, rhs);
}
}
代码示例来源:origin: apache/ignite
/** */
public BinaryClassificationMetrics withPositiveClsLb(double positiveClsLb) {
if (Double.isFinite(positiveClsLb))
this.positiveClsLb = positiveClsLb;
return this;
}
代码示例来源:origin: apache/ignite
/** */
public BinaryClassificationMetrics withNegativeClsLb(double negativeClsLb) {
if (Double.isFinite(negativeClsLb))
this.negativeClsLb = negativeClsLb;
return this;
}
代码示例来源:origin: prestodb/presto
private static String formatDouble(double value)
{
if (isFinite(value)) {
return format(Locale.US, "%.2f", value);
}
return "?";
}
代码示例来源:origin: prestodb/presto
private static String formatAsLong(double value)
{
if (isFinite(value)) {
return format(Locale.US, "%d", Math.round(value));
}
return "?";
}
代码示例来源:origin: prestodb/presto
private static double normalizeFraction(double fraction)
{
checkArgument(!isNaN(fraction), "fraction is NaN");
checkArgument(isFinite(fraction), "fraction must be finite");
if (fraction < 0) {
return 0;
}
if (fraction > 1) {
return 1;
}
return fraction;
}
代码示例来源:origin: prestodb/presto
public void update(long nanos, double utilization, int currentConcurrency)
{
checkArgument(nanos >= 0, "nanos is negative");
checkArgument(isFinite(utilization), "utilization must be finite");
checkArgument(utilization >= 0, "utilization is negative");
checkArgument(currentConcurrency >= 0, "currentConcurrency is negative");
threadNanosSinceLastAdjustment += nanos;
if (threadNanosSinceLastAdjustment >= adjustmentIntervalNanos && utilization < TARGET_UTILIZATION && currentConcurrency >= targetConcurrency) {
threadNanosSinceLastAdjustment = 0;
targetConcurrency++;
}
}
代码示例来源:origin: prestodb/presto
public void splitFinished(long splitThreadNanos, double utilization, int currentConcurrency)
{
checkArgument(splitThreadNanos >= 0, "nanos is negative");
checkArgument(isFinite(utilization), "utilization must be finite");
checkArgument(utilization >= 0, "utilization is negative");
checkArgument(currentConcurrency >= 0, "currentConcurrency is negative");
if (threadNanosSinceLastAdjustment >= adjustmentIntervalNanos || threadNanosSinceLastAdjustment >= splitThreadNanos) {
if (utilization > TARGET_UTILIZATION && targetConcurrency > 1) {
threadNanosSinceLastAdjustment = 0;
targetConcurrency--;
}
else if (utilization < TARGET_UTILIZATION && currentConcurrency >= targetConcurrency) {
threadNanosSinceLastAdjustment = 0;
targetConcurrency++;
}
}
}
}
代码示例来源:origin: neo4j/neo4j
PointValue( CoordinateReferenceSystem crs, double... coordinate )
{
this.crs = crs;
this.coordinate = coordinate;
for ( double c : coordinate )
{
if ( !Double.isFinite( c ) )
{
throw new InvalidValuesArgumentException( "Cannot create a point with non-finite coordinate values: " + Arrays.toString(coordinate) );
}
}
}
代码示例来源:origin: apache/incubator-druid
@Override
public int compare(Comparable lhs, Comparable rhs)
{
if (lhs instanceof Long && rhs instanceof Long) {
return Long.compare(((Number) lhs).longValue(), ((Number) rhs).longValue());
} else if (lhs instanceof Number && rhs instanceof Number) {
double d1 = ((Number) lhs).doubleValue();
double d2 = ((Number) rhs).doubleValue();
if (Double.isFinite(d1) && !Double.isFinite(d2)) {
return 1;
}
if (!Double.isFinite(d1) && Double.isFinite(d2)) {
return -1;
}
return Double.compare(d1, d2);
} else {
return Comparators.<Comparable>naturalNullsFirst().compare(lhs, rhs);
}
}
}
代码示例来源:origin: prestodb/presto
@OutputFunction(StandardTypes.REAL)
public static void corr(@AggregationState CorrelationState state, BlockBuilder out)
{
double result = getCorrelation(state);
if (Double.isFinite(result)) {
long resultBits = floatToRawIntBits((float) result);
REAL.writeLong(out, resultBits);
}
else {
out.appendNull();
}
}
}
代码示例来源:origin: prestodb/presto
@AggregationFunction("regr_slope")
@OutputFunction(StandardTypes.REAL)
public static void regrSlope(@AggregationState RegressionState state, BlockBuilder out)
{
double result = getRegressionSlope(state);
if (Double.isFinite(result)) {
REAL.writeLong(out, floatToRawIntBits((float) result));
}
else {
out.appendNull();
}
}
代码示例来源:origin: prestodb/presto
@AggregationFunction("regr_intercept")
@OutputFunction(StandardTypes.REAL)
public static void regrIntercept(@AggregationState RegressionState state, BlockBuilder out)
{
double result = getRegressionIntercept(state);
if (Double.isFinite(result)) {
REAL.writeLong(out, floatToRawIntBits((float) result));
}
else {
out.appendNull();
}
}
}
代码示例来源:origin: prestodb/presto
@OutputFunction(StandardTypes.DOUBLE)
public static void corr(@AggregationState CorrelationState state, BlockBuilder out)
{
double result = getCorrelation(state);
if (Double.isFinite(result)) {
DOUBLE.writeDouble(out, result);
}
else {
out.appendNull();
}
}
}
代码示例来源:origin: prestodb/presto
@AggregationFunction("regr_slope")
@OutputFunction(StandardTypes.DOUBLE)
public static void regrSlope(@AggregationState RegressionState state, BlockBuilder out)
{
double result = getRegressionSlope(state);
if (Double.isFinite(result)) {
DOUBLE.writeDouble(out, result);
}
else {
out.appendNull();
}
}
代码示例来源:origin: prestodb/presto
@AggregationFunction("regr_intercept")
@OutputFunction(StandardTypes.DOUBLE)
public static void regrIntercept(@AggregationState RegressionState state, BlockBuilder out)
{
double result = getRegressionIntercept(state);
if (Double.isFinite(result)) {
DOUBLE.writeDouble(out, result);
}
else {
out.appendNull();
}
}
}
代码示例来源:origin: prestodb/presto
private void testNonTrivialAggregation(Double[] y, Double[] x)
{
SimpleRegression regression = new SimpleRegression();
for (int i = 0; i < x.length; i++) {
regression.addData(x[i], y[i]);
}
double expected = regression.getSlope();
checkArgument(Double.isFinite(expected) && expected != 0.0, "Expected result is trivial");
testAggregation(expected, createDoublesBlock(y), createDoublesBlock(x));
}
}
代码示例来源:origin: prestodb/presto
private void testNonTrivialAggregation(Double[] y, Double[] x)
{
SimpleRegression regression = new SimpleRegression();
for (int i = 0; i < x.length; i++) {
regression.addData(x[i], y[i]);
}
double expected = regression.getIntercept();
checkArgument(Double.isFinite(expected) && expected != 0., "Expected result is trivial");
testAggregation(expected, createDoublesBlock(y), createDoublesBlock(x));
}
}
代码示例来源:origin: prestodb/presto
private void testNonTrivialAggregation(double[] y, double[] x)
{
PearsonsCorrelation corr = new PearsonsCorrelation();
double expected = corr.correlation(x, y);
checkArgument(Double.isFinite(expected) && expected != 0.0 && expected != 1.0, "Expected result is trivial");
testAggregation(expected, createDoublesBlock(box(y)), createDoublesBlock(box(x)));
}
代码示例来源:origin: prestodb/presto
private static PlanNodeStatsEstimate estimateExpressionNotEqualToExpression(
PlanNodeStatsEstimate inputStatistics,
SymbolStatsEstimate leftExpressionStatistics,
Optional<Symbol> leftExpressionSymbol,
SymbolStatsEstimate rightExpressionStatistics,
Optional<Symbol> rightExpressionSymbol)
{
double nullsFilterFactor = (1 - leftExpressionStatistics.getNullsFraction()) * (1 - rightExpressionStatistics.getNullsFraction());
PlanNodeStatsEstimate inputNullsFiltered = inputStatistics.mapOutputRowCount(size -> size * nullsFilterFactor);
SymbolStatsEstimate leftNullsFiltered = leftExpressionStatistics.mapNullsFraction(nullsFraction -> 0.0);
SymbolStatsEstimate rightNullsFiltered = rightExpressionStatistics.mapNullsFraction(nullsFraction -> 0.0);
PlanNodeStatsEstimate equalityStats = estimateExpressionEqualToExpression(
inputNullsFiltered,
leftNullsFiltered,
leftExpressionSymbol,
rightNullsFiltered,
rightExpressionSymbol);
if (equalityStats.isOutputRowCountUnknown()) {
return PlanNodeStatsEstimate.unknown();
}
PlanNodeStatsEstimate.Builder result = PlanNodeStatsEstimate.buildFrom(inputNullsFiltered);
double equalityFilterFactor = equalityStats.getOutputRowCount() / inputNullsFiltered.getOutputRowCount();
if (!isFinite(equalityFilterFactor)) {
equalityFilterFactor = 0.0;
}
result.setOutputRowCount(inputNullsFiltered.getOutputRowCount() * (1 - equalityFilterFactor));
leftExpressionSymbol.ifPresent(symbol -> result.addSymbolStatistics(symbol, leftNullsFiltered));
rightExpressionSymbol.ifPresent(symbol -> result.addSymbolStatistics(symbol, rightNullsFiltered));
return result.build();
}
内容来源于网络,如有侵权,请联系作者删除!