addLogVector: Add a vector of log values.

View source: R/addLog.R

addLogVectorR Documentation

Add a vector of log values.

Description

When a summation must be taken on a vector of numbers that are on the log scale, transforming them back to the non-log scale and taking the sum is slow. This function takes the exp() of the values only when neccessary.

Usage

  addLogVector(x)

Arguments

x

Numeric vector containing values on a log scale to be summed on the untransformed scale.

Details

This function checks to see if the difference between the maximum values and the remaining values is less than the machine precision. If it is, then the exp() is taken for those values that differ by less than the machine precision, they are summed and returned to a log scale. If the maximum value is differs from the other values by greater than the machine precision, then return the maximum value.

Value

Numeric value containing the sum of the values on a log scale.

Author(s)

Daniel Gatti

See Also

addLog

Examples

  addLogVector(log(1:10))

dmgatti/DOQTL documentation built on April 7, 2024, 10:35 p.m.