Compute an approximation to the natural logarithm. Assumes parameter is positive and finite. @param x parameter @return ln(x)
(final double x)
| 284 | * @return <code>ln(x)</code> |
| 285 | */ |
| 286 | public static double log(final double x) { |
| 287 | assert x >= 0 && Double.isFinite(x); |
| 288 | if (x == 0.0) { |
| 289 | return Double.NEGATIVE_INFINITY; |
| 290 | } |
| 291 | final long t = Double.doubleToRawLongBits(x); |
| 292 | final long lg = (t >>> EXPONENT_OFFSET) - EXPONENT_BIAS; |
| 293 | final int mantissa = (int) (t >> (EXPONENT_OFFSET - BITS)); |
| 294 | final double mlg = LOG_TABLE[mantissa & MASK]; |
| 295 | return mlg + lg * LOG_2; |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * Get a phred-scaled quality value corresponding to the supplied error rate. |
no outgoing calls