Simple helper method to transform an {@code Object} into a {@code double}. The method returns {@code NaN}, if
the value cannot be transformed.

@param val the value to transform

@return the created double
556904
protected double toDouble(final Object val) {

        if (val == null) {
            return Double.NaN;
        } else if (Double.class.isInstance(val)) {
            return Double.class.cast(val);
        } else if (Number.class.isInstance(val)) {
            return Number.class.cast(val).doubleValue();
        } else if (double.class.isInstance(val)) {
            return double.class.cast(val);
        } else if (long.class.isInstance(val)) {
            return long.class.cast(val);
        } else if (int.class.isInstance(val)) {
            return int.class.cast(val);
        } else if (byte.class.isInstance(val)) {
            return byte.class.cast(val);
        } else if (float.class.isInstance(val)) {
            return float.class.cast(val);
        } else {
            return Double.NaN;
        }
    }
379675
public Double convertToDouble(String value) {
        Double result = null;
        if (value != null) {
            result = Double.valueOf(value);
        }
        return result;
    }
416620
public static String toDecimal(Object value, String defaultValue) {
	double res = toDoubleValue(value, true, Double.NaN);
	if (Double.isNaN(res)) return defaultValue;
	return toDecimal(res);
    }
1159983
public void divide(double val) {
        for (int c = 0; c < this.values.length; c++) {
            divideValue(c, val);
        }
    }
345146
public T scale( double val ) {
        T ret = createLike();
        ops.scale(mat,val,ret.getMatrix());
        return ret;
    }
837820
public Object negate(Object val) {
    if (val instanceof Integer) {
      int valueAsInt = ((Integer) val).intValue();
      return Integer.valueOf(-valueAsInt);
    }
    else if (val instanceof Double) {
      double valueAsDouble = ((Double) val).doubleValue();
      return new Double(-valueAsDouble);
    }
    else if (val instanceof Long) {
      long valueAsLong = -((Long) val).longValue();
      return Long.valueOf(valueAsLong);
    }
    else if (val instanceof BigDecimal) {
      BigDecimal valueAsBigD = (BigDecimal) val;
      return valueAsBigD.negate();
    }
    else if (val instanceof BigInteger) {
      BigInteger valueAsBigI = (BigInteger) val;
      return valueAsBigI.negate();
    }
    else if (val instanceof Float) {
      float valueAsFloat = ((Float) val).floatValue();
      return new Float(-valueAsFloat);
    }
    else if (val instanceof Short) {
      short valueAsShort = ((Short) val).shortValue();
      return Short.valueOf((short) -valueAsShort);
    }
    else if (val instanceof Byte) {
      byte valueAsByte = ((Byte) val).byteValue();
      return Byte.valueOf((byte) -valueAsByte);
    }
    else if (val instanceof Boolean) {
      return ((Boolean) val).booleanValue() ? Boolean.FALSE : Boolean.TRUE;
    }
    throw new ArithmeticException("Object negation:(" + val + ")");
  }
1009808
public double getDouble(String property) {
    return getProperty(property, value -> {
      try {
        return Double.valueOf(value);
      } catch (NumberFormatException e) {
        throw new ConfigurationException("malformed property value: " + property + " must be a double");
      }
    });
  }
691727
public BigDecimal toBigDecimal(Object val) {
    if (val instanceof BigDecimal) {
      return roundBigDecimal((BigDecimal) val);
    }
    else if (val == null) {
      return BigDecimal.ZERO;
    }
    else if (val instanceof String) {
      String string = ((String) val).trim();
      if ("".equals(string)) {
        return BigDecimal.ZERO;
      }
      return roundBigDecimal(new BigDecimal(string, getMathContext()));
    }
    else if (val instanceof Double) {
      if (!Double.isNaN(((Double) val).doubleValue())) {
        return roundBigDecimal(new BigDecimal(val.toString(), getMathContext()));
      }
      else {
        return BigDecimal.ZERO;
      }
    }
    else if (val instanceof Number) {
      return roundBigDecimal(new BigDecimal(val.toString(), getMathContext()));
    }
    else if (val instanceof Character) {
      int i = ((Character) val).charValue();
      return new BigDecimal(i);
    }

    throw new ArithmeticException("BigDecimal coercion: " + val.getClass().getName() + ":(" + val + ")");
  }
930018
public JcNumber mult(JcNumber val) {
		JcNumber ret = new JcNumber(val, this, OPERATOR.Number.MULT);
		QueryRecorder.recordInvocationConditional(this, "mult", ret, QueryRecorder.placeHolder(val));
		return ret;
	}
1230842
public static Double toDouble(Object value, Double defaultValue) {
		return convert(Double.class, value, defaultValue);
	}
1040609
public static double getDouble(JsonObject object, String field, double defaultValue) {
        final JsonValue value = object.get(field);
        if (value == null || value.isNull()) {
            return defaultValue;
        } else {
            return value.asDouble();
        }
    }
1201042
public int toInteger(Object val) {
    if (val == null) {
      return 0;
    }
    else if (val instanceof Double) {
      if (!Double.isNaN(((Double) val).doubleValue())) {
        return 0;
      }
      else {
        return ((Double) val).intValue();
      }
    }
    else if (val instanceof Number) {
      return ((Number) val).intValue();
    }
    else if (val instanceof String) {
      if ("".equals(val)) {
        return 0;
      }
      return Integer.parseInt((String) val);
    }
    else if (val instanceof Boolean) {
      return ((Boolean) val).booleanValue() ? 1 : 0;
    }
    else if (val instanceof Character) {
      return ((Character) val).charValue();
    }

    throw new ArithmeticException("Integer coercion: " + val.getClass().getName() + ":(" + val + ")");
  }
391050
@Pure
	public static double max(double... values) {
		if (values == null || values.length == 0) {
			return Double.NaN;
		}
		double max = values[0];
		for (final double v : values) {
			if (v > max) {
				max = v;
			}
		}
		return max;
	}
333201
public static double getDouble(JsonObject object, String field) {
        final JsonValue value = object.get(field);
        throwExceptionIfNull(value, field);
        return value.asDouble();
    }
876978
public Rational multiply(final int val) {
        BigInteger tmp = BigInteger.valueOf(val);
        return multiply(tmp);
    }
180012
public static Double readDouble(String value, Double defaultValue) {
		if (!StringUtils.hasText(value)) return defaultValue;
		
		return Double.valueOf(value);
	}
1171498
@Override
    public INDArray scalar(double value) {
        if (Nd4j.dataType() == DataType.DOUBLE)
            return create(new double[] {value}, new int[0], new int[0], 0);
        else
            return scalar((float) value);
    }