当前位置: 首页>>代码示例>>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;未经允许,请勿转载。