本文整理汇总了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});
}
}
示例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());
}
}
}
示例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);
}
示例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});
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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());
}
示例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;
}
示例14: isValidBAF
import com.google.common.primitives.Doubles; //导入方法依赖的package包/类
private static boolean isValidBAF(@NotNull final AmberBAF baf) {
return Doubles.isFinite(baf.tumorBAF());
}
示例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;
}