java.lang.Math.expm1()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中java.lang.Math.expm1()方法的一些代码示例,展示了Math.expm1()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Math.expm1()方法的具体详情如下:
包路径:java.lang.Math
类名称:Math
方法名:expm1

Math.expm1介绍

[英]Returns the closest double approximation of e d - 1. If the argument is very close to 0, it is much more accurate to use expm1(d)+1 than exp(d) (due to cancellation of significant digits). The returned result is within 1 ulp (unit in the last place) of the real result.

For any finite input, the result is not less than -1.0. If the real result is within 0.5 ulp of -1, -1.0 is returned.

Special cases:

  • expm1(+0.0) = +0.0
  • expm1(-0.0) = -0.0
  • expm1(+infinity) = +infinity
  • expm1(-infinity) = -1.0
  • expm1(NaN) = NaN
    [中]返回e d-1的最接近的双近似值。如果参数非常接近于0,则使用expm1(d)+1比exp(d)准确得多(由于有效数字的取消)。返回的结果在实际结果的1 ulp(最后一位的单位)范围内。
    对于任何有限输入,结果不小于-1.0。如果实际结果在-1的0.5 ulp范围内,则返回-1.0。
    特殊情况:
    *expm1(+0.0)=+0.0
    *expm1(-0.0)=-0.0
    *expm1(+无穷大)=+无穷大
    *expm1(-无穷大)=-1.0
    *expm1(NaN)=NaN

代码示例

代码示例来源:origin: apache/incubator-druid

@Override
 protected ExprEval eval(double param)
 {
  return ExprEval.of(Math.expm1(param));
 }
}

代码示例来源:origin: DataSketches/sketches-core

/**
 * Important note: do not change anything in the following function.
 * It has been carefully designed and tested for numerical accuracy.
 * In particular, the use of log1p and expm1 is critically important.
 * @param kf the value of k as a double
 * @param nf the value of n as a double
 * @param col the given column
 * @return the quantity qnj
 */
static double qnj(final double kf, final double nf, final int col) {
 final double tmp1 = -1.0 / (kf * (Math.pow(2.0, col)));
 final double tmp2 = Math.log1p(tmp1);
 return (-1.0 * (Math.expm1(nf * tmp2)));
}

代码示例来源:origin: com.github.haifengl/smile-math

/**
 * Returns e<sup>x</sup>-1.
 */
public static double expm1(double x) {
  return java.lang.Math.expm1(x);
}

代码示例来源:origin: net.objecthunter/exp4j

@Override
  public double apply(double... args) {
    return Math.expm1(args[0]);
  }
};

代码示例来源:origin: org.apache.commons/math

/** {@inheritDoc} */
@Override
public RealVector mapExpm1ToSelf() {
  for (int i = 0; i < data.length; i++) {
    data[i] = Math.expm1(data[i]);
  }
  return this;
}

代码示例来源:origin: org.apache.commons/math

/** {@inheritDoc} */
  @Override
  public double value(double d) {
    return Math.expm1(d);
  }
};

代码示例来源:origin: jpmml/jpmml-evaluator

@Override
  public Double evaluate(Number value){
    return Math.expm1(value.doubleValue());
  }
};

代码示例来源:origin: ca.umontreal.iro/ssj

protected void initArrays(int d) {
 double dt, c;
 for (int j = 0; j < d; j++) {
   dt = t[j+1] - t[j];
   c = -Math.expm1(-alpha * dt)*sigma*sigma/(4.0*alpha);
   parc[j] = c;
   parlam[j] = Math.exp(-alpha * dt) / c;
 }
}

代码示例来源:origin: geogebra/geogebra

/**
 * {@inheritDoc}
 *
 * For scale {@code m} and shape {@code s}, the variance is
 * {@code (exp(s^2) - 1) * exp(2 * m + s^2)}.
 */
public double getNumericalVariance() {
  final double s = shape;
  final double ss = s * s;
  return (Math.expm1(ss)) * Math.exp(2 * scale + ss);
}

代码示例来源:origin: pravega/pravega

private double calculateExponential(double result) {
  if (!logarithmicWeighting) {
    return result;
  } 
  
  return Math.signum(result) * (Math.expm1(Math.abs(result)));
}

代码示例来源:origin: OpenGamma/Strata

/**
 * This is the Taylor expansion of $$\frac{\exp(x)-1}{x}$$ - note for $$|x| > 10^{-10}$$ the expansion is note used .
 * 
 * @param x  the value
 * @return the result 
 */
public static double epsilon(double x) {
 if (Math.abs(x) > 1e-10) {
  return Math.expm1(x) / x;
 }
 return taylor(x, COEFF1);
}

代码示例来源:origin: ca.umontreal.iro/ssj

private static double invGaver (int n, double u) {
 // Gaver-Kafadar normal approximation for the inverse
 // \cite{tGAV84a}
 double z = NormalDist.inverseF01 (u);
 double q = z / (n - 1.0);
 double v = q * q * (n - 1.5);
 double t = Math.sqrt(n * Math.expm1(v));
 if (u >= 0.5)
   return t;
 else
   return -t;
}

代码示例来源:origin: OpenGamma/Strata

/**
 * This is the Taylor expansion of the first derivative of $$\frac{\exp(x)-1}{x}$$.
 * 
 * @param x  the value
 * @return the result 
 */
public static double epsilonP(double x) {
 if (Math.abs(x) > 1e-7) {
  return ((x - 1) * Math.expm1(x) + x) / x / x;
 }
 return taylor(x, COEFF2);
}

代码示例来源:origin: org.python/jython

public static double expm1(double v) {
  if (Double.POSITIVE_INFINITY == v) {
    return v;
  }
  double result = Math.expm1(v);
  if (Double.isInfinite(result)) {
    throw Py.OverflowError(Double.toString(v));
  }
  return result;
}

代码示例来源:origin: geogebra/geogebra

/** {@inheritDoc}
 * @since 3.2
 */
public Decimal64 expm1() {
  return new Decimal64(Math.expm1(value));
}

代码示例来源:origin: org.apache.druid/druid-common

@Override
 protected ExprEval eval(double param)
 {
  return ExprEval.of(Math.expm1(param));
 }
}

代码示例来源:origin: uk.org.retep.tools/math

@Override
public Object expm1( final MonadicOp op )
    throws MathematicsException
{
  return Math.expm1( visitNumber( op.getValue() ).doubleValue() );
}

代码示例来源:origin: net.imglib2/imglib2-script

@Override
  public final double eval() {
    return Math.expm1(a().eval());
  }
}

代码示例来源:origin: algorithmfoundry/Foundry

@Override
public double getVariance()
{
  double exp1 = this.getLogNormalVariance();
  double exp2 = 2.0 * this.getLogNormalMean() + this.getLogNormalVariance();
  // (Math.exp(exp1)-1)*Math.exp(exp2)
  return (Math.expm1( exp1 ) * Math.exp( exp2 ));
}

代码示例来源:origin: gov.sandia.foundry/gov-sandia-cognition-learning-core

@Override
public double getVariance()
{
  double exp1 = this.getLogNormalVariance();
  double exp2 = 2.0 * this.getLogNormalMean() + this.getLogNormalVariance();
  // (Math.exp(exp1)-1)*Math.exp(exp2)
  return (Math.expm1( exp1 ) * Math.exp( exp2 ));
}

相关文章