Learn R Programming

matrixStats (version 0.60.0)

rowLogSumExps: Accurately computes the logarithm of the sum of exponentials across rows or columns

Description

Accurately computes the logarithm of the sum of exponentials across rows or columns.

Usage

rowLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE,
  dim. = dim(lx), ..., useNames = NA)

colLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(lx), ..., useNames = NA)

Arguments

lx

A numeric NxK matrix. Typically lx are \(log(x)\) values.

rows, cols

A vector indicating subset of rows (and/or columns) to operate over. If NULL, no subsetting is done.

na.rm

If TRUE, any missing values are ignored, otherwise not.

dim.

An integer vector of length two specifying the dimension of x, also when not a matrix.

...

Not used.

useNames

If NA, the default behavior of the function about naming support is remained. If FALSE, no naming support is done. Else if TRUE, names attributes of result are set.

Value

A numeric vector of length N (K).

Benchmarking

These methods are implemented in native code and have been optimized for speed and memory.

See Also

To calculate the same on vectors, logSumExp().