Given the matrix x
, for each row \(x_{[i]} = [x_1, \dots, x_k]\) (with \(i=1,\dots,n\)), the log-sum-exp (LSE) function calculates
$$
\text{LSE}(x_{[i]}) = \log \sum_{j=1}^k \exp(x_j + v_j) = m + \log \sum_{j=1}^k \exp(x_j + v_j - m)
$$
where \(m = \max(x_1+v_1, \dots, x_k+v_k)\).