MCPcopy Create free account
hub / github.com/RealTimeGenomics/rtg-tools / log

Method log

src/main/java/com/rtg/util/MathUtils.java:286–296  ·  view source on GitHub ↗

Compute an approximation to the natural logarithm. Assumes parameter is positive and finite. @param x parameter @return ln(x)

(final double x)

Source from the content-addressed store, hash-verified

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.

Callers 15

testLogMethod · 0.95
testDefaultPriorsMethod · 0.45
testLogBinomialPMethod · 0.45
testLogBinomialMethod · 0.45
testLogFactorialMethod · 0.45
testLogExpPlus1Method · 0.45
testLogExpMinus1Method · 0.45
CanvasXpressFunction · 0.45
ProteinScoringMatrixMethod · 0.45
setupAlleleFrequencyMethod · 0.45

Calls

no outgoing calls

Tested by 8

testLogMethod · 0.76
testDefaultPriorsMethod · 0.36
testLogBinomialPMethod · 0.36
testLogBinomialMethod · 0.36
testLogFactorialMethod · 0.36
testLogExpPlus1Method · 0.36
testLogExpMinus1Method · 0.36