Example usage for com.google.common.primitives Doubles isFinite

List of usage examples for com.google.common.primitives Doubles isFinite

Introduction

In this page you can find the example usage for com.google.common.primitives Doubles isFinite.

Prototype

public static boolean isFinite(double value) 

Source Link

Document

Returns true if value represents a real number.

Usage

From source file:com.github.rinde.rinsim.geom.LengthData.java

/**
 * Create a new {@link LengthData} instance using the specified length.
 * @param length The length of the connection.
 * @return A new instance./*w ww .  ja  v a2  s  .  c  o  m*/
 */
public static LengthData create(double length) {
    checkArgument(length >= 0d && Doubles.isFinite(length),
            "Only positive values are allowed for length, it is: %s.", length);
    return new AutoValue_LengthData(Optional.of(length));
}

From source file:com.cloudera.oryx.common.LangUtils.java

/**
 * @see #parseFloat(String)/* w  w w  . j  av a2s  . c  om*/
 */
public static double parseDouble(String s) {
    double value = Double.parseDouble(s);
    Preconditions.checkArgument(Doubles.isFinite(value), "Bad value: %s", value);
    return value;
}

From source file:com.opengamma.analytics.financial.model.option.pricing.tree.SupershareOptionFunctionProvider.java

/**
 * @param timeToExpiry Time to expiry//  w w  w.  jav a 2s . co  m
 * @param lowerBound Lower bound, KL
 * @param upperBound Upper bound, KH
 * @param steps Number of steps
 */
public SupershareOptionFunctionProvider(final double timeToExpiry, final double lowerBound,
        final double upperBound, final int steps) {
    super(lowerBound, timeToExpiry, steps, true);
    ArgumentChecker.isTrue(upperBound > 0., "upperBound should be positive");
    ArgumentChecker.isTrue(Doubles.isFinite(upperBound), "upperBound should be finite");
    ArgumentChecker.isTrue(upperBound > lowerBound, "upperBound should be larger than lowerBound");
    _upperBound = upperBound;
}

From source file:com.opengamma.analytics.financial.model.option.pricing.tree.PoweredOptionFunctionProvider.java

/**
 * @param strike Strike price, K//from www .  ja  v  a 2  s. c  om
 * @param timeToExpiry Time to expiry
 * @param steps Number of steps
 * @param isCall True if call, false if put
 * @param power Power, i
 */
public PoweredOptionFunctionProvider(final double strike, final double timeToExpiry, final int steps,
        final boolean isCall, final double power) {
    super(strike, timeToExpiry, steps, isCall);
    ArgumentChecker.isTrue(power > 0., "power should be positive");
    ArgumentChecker.isTrue(Doubles.isFinite(power), "power should be finite");
    _power = power;
}

From source file:com.opengamma.analytics.financial.model.option.pricing.tree.AsymmetricPowerOptionFunctionProvider.java

/**
 * @param strike Strike price, K//from   ww w. j  av  a  2 s. com
 * @param timeToExpiry Time to expiry
 * @param steps Number of steps
 * @param isCall True if call, false if put
 * @param power Power, i
 */
public AsymmetricPowerOptionFunctionProvider(final double strike, final double timeToExpiry, final int steps,
        final boolean isCall, final double power) {
    super(strike, timeToExpiry, steps, isCall);
    ArgumentChecker.isTrue(power > 0., "power should be positive");
    ArgumentChecker.isTrue(Doubles.isFinite(power), "power should be finite");
    _power = power;
}

From source file:com.opengamma.analytics.financial.model.option.pricing.tree.OptionFunctionProvider1D.java

/**
 * Superclass constructor //www.  j  a v a2 s  .  c  o  m
 * @param strike Strike price
 * @param timeToExpiry Time to expiry
 * @param steps Number of steps
 * @param isCall True if call, false if put
 */
public OptionFunctionProvider1D(final double strike, final double timeToExpiry, final int steps,
        final boolean isCall) {
    ArgumentChecker.isTrue(strike > 0., "strike should be positive");
    ArgumentChecker.isTrue(Doubles.isFinite(strike), "strike should be finite");
    ArgumentChecker.isTrue(timeToExpiry > 0., "timeToExpiry should be positive");
    ArgumentChecker.isTrue(Doubles.isFinite(timeToExpiry), "timeToExpiry should be finite");
    ArgumentChecker.isTrue(steps > 2, "The number of steps should be greater than 2");

    _strike = strike;
    _timeToExpiry = timeToExpiry;
    _steps = steps;
    _sign = isCall ? 1. : -1.;
}

From source file:com.opengamma.analytics.financial.model.option.pricing.tree.OptionFunctionProvider2D.java

/**
 * @param strike Strike price//from  ww w.  java 2s.  c o  m
 * @param timeToExpiry Time to expiry
 * @param steps Number of steps
 * @param isCall True if call, false if put
 */
public OptionFunctionProvider2D(final double strike, final double timeToExpiry, final int steps,
        final boolean isCall) {
    ArgumentChecker.isTrue(strike >= 0., "strike should be positive");
    ArgumentChecker.isTrue(Doubles.isFinite(strike), "strike should be finite");
    ArgumentChecker.isTrue(timeToExpiry > 0., "timeToExpiry should be positive");
    ArgumentChecker.isTrue(Doubles.isFinite(timeToExpiry), "timeToExpiry should be finite");
    ArgumentChecker.isTrue(steps > 2, "The number of steps should be greater than 2");

    _strike = strike;
    _timeToExpiry = timeToExpiry;
    _steps = steps;
    _sign = isCall ? 1. : -1.;
}

From source file:com.opengamma.analytics.financial.model.option.pricing.tree.AmericanExchangeOptionFunctionProvider.java

/**
 * @param timeToExpiry Time to expiry//from  w w w.j  a  va2s  . co m
 * @param steps Number of steps
 * @param quantity1 Quantity of asset 1
 * @param quantity2 Quantity of asset 2
 */
public AmericanExchangeOptionFunctionProvider(final double timeToExpiry, final int steps,
        final double quantity1, final double quantity2) {
    super(0., timeToExpiry, steps, true);
    ArgumentChecker.isTrue(quantity1 > 0., "quantity1 should be positive");
    ArgumentChecker.isTrue(Doubles.isFinite(quantity1), "quantity1 should be finite");
    ArgumentChecker.isTrue(quantity2 > 0., "quantity2 should be positive");
    ArgumentChecker.isTrue(Doubles.isFinite(quantity2), "quantity2 should be finite");

    _quantity1 = quantity1;
    _quantity2 = quantity2;
}

From source file:com.opengamma.analytics.financial.model.option.pricing.tree.GapOptionFunctionProvider.java

/**
 * @param strike Strike price, K1//from  w w w  .  java 2 s  .  co m
 * @param timeToExpiry Time to expiry
 * @param steps Number of steps
 * @param isCall True if call, false if put
 * @param payoffStrike Payoff-strike, K2
 */
public GapOptionFunctionProvider(final double strike, final double timeToExpiry, final int steps,
        final boolean isCall, final double payoffStrike) {
    super(strike, timeToExpiry, steps, isCall);
    ArgumentChecker.isTrue(payoffStrike > 0., "payoffStrike should be positive");
    ArgumentChecker.isTrue(Doubles.isFinite(payoffStrike), "payoffStrike should be finite");
    _payoffStrike = payoffStrike;
}

From source file:com.opengamma.analytics.financial.model.option.pricing.tree.TwoAssetCorrelationOptionFunctionProvider.java

/**
 * @param strike1 Strike price for asset 1, X1
 * @param strike2 Strike price for asset 2, X2
 * @param timeToExpiry Time to expiry//from www .  java  2 s  . co  m
 * @param steps Number of steps
 * @param isCall True if call, false if put
 */
public TwoAssetCorrelationOptionFunctionProvider(final double strike1, final double strike2,
        final double timeToExpiry, final int steps, final boolean isCall) {
    super(strike1, timeToExpiry, steps, isCall);
    ArgumentChecker.isTrue(strike2 > 0., "strike2 should be positive");
    ArgumentChecker.isTrue(Doubles.isFinite(strike2), "strike2 should be finite");
    _strike2 = strike2;
}