Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ log_sum_exp() [5/13]

template<typename T , require_all_kernel_expressions_and_none_scalar_t< T > * = nullptr>
double stan::math::log_sum_exp ( const T &  a)
inline

Return the log of the sum of the exponentiated values of the specified matrix of values.

The matrix may be a full matrix, a vector, a row vector.

The function is defined as follows to prevent overflow in exponential calculations.

\(\log \sum_{n=1}^N \exp(x_n) = \max(x) + \log \sum_{n=1}^N \exp(x_n - \max(x))\).

Template Parameters
Ttype of input vector or matrix
Parameters
[in]amatrix of specified values
Returns
the log of the sum of the exponentiated vector values

Definition at line 31 of file log_sum_exp.hpp.