當前位置: 首頁>>代碼示例>>Java>>正文


Java Doubles.isFinite方法代碼示例

本文整理匯總了Java中com.google.common.primitives.Doubles.isFinite方法的典型用法代碼示例。如果您正苦於以下問題:Java Doubles.isFinite方法的具體用法?Java Doubles.isFinite怎麽用?Java Doubles.isFinite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.primitives.Doubles的用法示例。


在下文中一共展示了Doubles.isFinite方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseDouble

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
public static double parseDouble(String input) throws NumberInvalidException
{
    try
    {
        double d0 = Double.parseDouble(input);

        if (!Doubles.isFinite(d0))
        {
            throw new NumberInvalidException("commands.generic.num.invalid", new Object[] {input});
        }
        else
        {
            return d0;
        }
    }
    catch (NumberFormatException var3)
    {
        throw new NumberInvalidException("commands.generic.num.invalid", new Object[] {input});
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:21,代碼來源:CommandBase.java

示例2: checkInputs

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * @param function The function, not null
 * @param x0 The starting point, not null
 */
protected void checkInputs(final Function1D<DoubleMatrix1D, DoubleMatrix1D> function, final DoubleMatrix1D x0) {
  ArgumentChecker.notNull(function, "function");
  ArgumentChecker.notNull(x0, "x0");
  final int n = x0.getNumberOfElements();
  for (int i = 0; i < n; i++) {
    if (!Doubles.isFinite(x0.getEntry(i))) {
      throw new IllegalArgumentException("Invalid start position x0 = " + x0.toString());
    }
  }
  final DoubleMatrix1D y = function.evaluate(x0);
  final int m = y.getNumberOfElements();
  for (int i = 0; i < m; i++) {
    if (!Doubles.isFinite(y.getEntry(i))) {
      throw new IllegalArgumentException("Invalid start position f(x0) = " + y.toString());
    }
  }
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:22,代碼來源:VectorRootFinder.java

示例3: calculateGLScreenVirtualBounds

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * @param scale The scale factor from virtual coordinates to real coordinates.
 */
private static Rect2D calculateGLScreenVirtualBounds(int clipX, int clipY, int screenWidth,
        int screenHeight, double scale) {
    double s = 1.0 / scale;
    if (!Doubles.isFinite(s)) {
        return Rect2D.EMPTY;
    }

    double x = s * -clipX;
    double y = s * -clipY;
    double w = s * screenWidth;
    double h = s * screenHeight;

    w = Double.isNaN(w) ? 0 : Math.max(0, w);
    h = Double.isNaN(h) ? 0 : Math.max(0, h);

    return Rect2D.of(x, y, w, h);
}
 
開發者ID:anonl,項目名稱:nvlist,代碼行數:21,代碼來源:RenderEnv.java

示例4: parseDouble

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * Parses a double from the given string or throws an exception if it's not a double.
 */
public static double parseDouble(ICommandSender par0ICommandSender, String par1Str)
{
    try
    {
        double var2 = Double.parseDouble(par1Str);

        if (!Doubles.isFinite(var2))
        {
            throw new NumberInvalidException("commands.generic.num.invalid", new Object[] {par1Str});
        }
        else
        {
            return var2;
        }
    }
    catch (NumberFormatException var4)
    {
        throw new NumberInvalidException("commands.generic.num.invalid", new Object[] {par1Str});
    }
}
 
開發者ID:MinecraftModdedClients,項目名稱:Resilience-Client-Source,代碼行數:24,代碼來源:CommandBase.java

示例5: getNextPosition

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
private boolean getNextPosition(final Function1D<DoubleMatrix1D, DoubleMatrix1D> function, final DoubleMatrix2D estimate, final DataBundle data) {
  final DoubleMatrix1D p = _directionFunction.getDirection(estimate, data.getY());
  if (data.getLambda0() < 1.0) {
    data.setLambda0(1.0);
  } else {
    data.setLambda0(data.getLambda0() * BETA);
  }
  updatePosition(p, function, data);
  final double g1 = data.getG1();
  // the function is invalid at the new position, try to recover
  if (!Doubles.isFinite(g1)) {
    bisectBacktrack(p, function, data);
  }
  if (data.getG1() > data.getG0() / (1 + ALPHA * data.getLambda0())) {
    quadraticBacktrack(p, function, data);
    int count = 0;
    while (data.getG1() > data.getG0() / (1 + ALPHA * data.getLambda0())) {
      if (count > 5) {
        return false;
      }
      cubicBacktrack(p, function, data);
      count++;
    }
  }
  final DoubleMatrix1D deltaX = data.getDeltaX();
  final DoubleMatrix1D deltaY = data.getDeltaY();
  data.setG0(data.getG1());
  data.setX((DoubleMatrix1D) _algebra.add(data.getX(), deltaX));
  data.setY((DoubleMatrix1D) _algebra.add(data.getY(), deltaY));
  return true;
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:32,代碼來源:NewtonVectorRootFinder.java

示例6: nextNormal

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * Generates a random value for the normal distribution with the mean equal to {@code mu} and standard deviation
 * equal to {@code sigma}.
 *
 * @param mu    the mean of the distribution
 * @param sigma the standard deviation of the distribution
 * @return a random value for the given normal distribution
 */
public static double nextNormal(final RandomGenerator rng, final double mu, final double sigma) {
    final NormalDistribution normalDistribution =
            new NormalDistribution(rng, mu, sigma, NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
    while (true) {
        final double sample = normalDistribution.sample();
        if (!Doubles.isFinite(sample)) {
            logger.warn("Discarding non finite sample from normal distribution (mu={}, sigma={}): {}",
                    mu, sigma, sample);
            continue;
        }
        return sample;
    }
}
 
開發者ID:asoem,項目名稱:greyfish,代碼行數:22,代碼來源:RandomGenerators.java

示例7: jsonArrayContains

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@Nullable
@ScalarFunction
@SqlType(StandardTypes.BOOLEAN)
public static Boolean jsonArrayContains(@SqlType(StandardTypes.JSON) Slice json, @SqlType(StandardTypes.DOUBLE) double value)
{
    if (!Doubles.isFinite(value)) {
        return false;
    }

    try (JsonParser parser = JSON_FACTORY.createParser(json.getInput())) {
        if (parser.nextToken() != START_ARRAY) {
            return null;
        }

        while (true) {
            JsonToken token = parser.nextToken();
            if (token == null) {
                return null;
            }
            if (token == END_ARRAY) {
                return false;
            }
            parser.skipChildren();

            // noinspection FloatingPointEquality
            if ((token == VALUE_NUMBER_FLOAT) && (parser.getDoubleValue() == value) &&
                    (Doubles.isFinite(parser.getDoubleValue()))) {
                return true;
            }
        }
    }
    catch (IOException e) {
        return null;
    }
}
 
開發者ID:y-lan,項目名稱:presto,代碼行數:36,代碼來源:JsonFunctions.java

示例8: isFinite

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@Description("test if value is finite")
@ScalarFunction
@SqlType(StandardTypes.BOOLEAN)
public static boolean isFinite(@SqlType(StandardTypes.DOUBLE) double num)
{
    return Doubles.isFinite(num);
}
 
開發者ID:y-lan,項目名稱:presto,代碼行數:8,代碼來源:MathFunctions.java

示例9: value

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * @return The size value, or {@code defaultValue} if infinite or unknown.
 */
public double value(double defaultValue) {
    if (!Doubles.isFinite(value)) {
        return defaultValue;
    }
    return value;
}
 
開發者ID:anonl,項目名稱:nvlist,代碼行數:10,代碼來源:LayoutSize.java

示例10: func_183006_b

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
private boolean func_183006_b(C03PacketPlayer p_183006_1_)
{
    return !Doubles.isFinite(p_183006_1_.getPositionX()) || !Doubles.isFinite(p_183006_1_.getPositionY()) || !Doubles.isFinite(p_183006_1_.getPositionZ()) || !Floats.isFinite(p_183006_1_.getPitch()) || !Floats.isFinite(p_183006_1_.getYaw());
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:5,代碼來源:NetHandlerPlayServer.java

示例11: isMovePlayerPacketInvalid

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
private static boolean isMovePlayerPacketInvalid(CPacketPlayer packetIn)
{
    return Doubles.isFinite(packetIn.getX(0.0D)) && Doubles.isFinite(packetIn.getY(0.0D)) && Doubles.isFinite(packetIn.getZ(0.0D)) && Floats.isFinite(packetIn.getPitch(0.0F)) && Floats.isFinite(packetIn.getYaw(0.0F)) ? false : Math.abs(packetIn.getX(0.0D)) <= 3.0E7D && Math.abs(packetIn.getX(0.0D)) <= 3.0E7D;
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:5,代碼來源:NetHandlerPlayServer.java

示例12: isMoveVehiclePacketInvalid

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
private static boolean isMoveVehiclePacketInvalid(CPacketVehicleMove packetIn)
{
    return !Doubles.isFinite(packetIn.getX()) || !Doubles.isFinite(packetIn.getY()) || !Doubles.isFinite(packetIn.getZ()) || !Floats.isFinite(packetIn.getPitch()) || !Floats.isFinite(packetIn.getYaw());
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:5,代碼來源:NetHandlerPlayServer.java

示例13: isMovePlayerPacketInvalid

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
private static boolean isMovePlayerPacketInvalid(CPacketPlayer packetIn)
{
    return Doubles.isFinite(packetIn.getX(0.0D)) && Doubles.isFinite(packetIn.getY(0.0D)) && Doubles.isFinite(packetIn.getZ(0.0D)) && Floats.isFinite(packetIn.getPitch(0.0F)) && Floats.isFinite(packetIn.getYaw(0.0F)) ? false : Math.abs(packetIn.getX(0.0D)) <= 3.0E7D && Math.abs(packetIn.getZ(0.0D)) <= 3.0E7D;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:5,代碼來源:NetHandlerPlayServer.java

示例14: isValidBAF

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
private static boolean isValidBAF(@NotNull final AmberBAF baf) {
    return Doubles.isFinite(baf.tumorBAF());
}
 
開發者ID:hartwigmedical,項目名稱:hmftools,代碼行數:4,代碼來源:BAFFactory.java

示例15: isMovePlayerPacketInvalid

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
private static boolean isMovePlayerPacketInvalid(CPacketPlayer packetIn) {
	if (Doubles.isFinite(packetIn.getX(0.0D)) && Doubles.isFinite(packetIn.getY(0.0D)) && Doubles.isFinite(packetIn.getZ(0.0D)) && Floats.isFinite(packetIn.getPitch(0.0F)) && Floats.isFinite(packetIn.getYaw(0.0F)))
		return Math.abs(packetIn.getX(0.0D)) > 3.0E7D || Math.abs(packetIn.getY(0.0D)) > 3.0E7D || Math.abs(packetIn.getZ(0.0D)) > 3.0E7D;
	else 
		return true;
}
 
開發者ID:MrNobody98,項目名稱:morecommands,代碼行數:7,代碼來源:PatchNetHandlerPlayServer.java


注:本文中的com.google.common.primitives.Doubles.isFinite方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。