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

◆ log_sum_exp() [4/13]

template<typename T , require_container_st< is_fvar, T > * = nullptr>
auto stan::math::log_sum_exp ( const T &  x)
inline

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

Returns the log sum of exponentials.

The matrix may be a full matrix, a vector, a row vector, or a container of these.

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]xMatrix of specified values.
Returns
The log of the sum of the exponentiated vector values.

The matrix may be a full matrix, a vector, a row vector, or a container of these.

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]xmatrix of specified values
Returns
The log of the sum of the exponentiated vector values.
Template Parameters
TType of input vector or matrix.
Parameters
xmatrix

Definition at line 53 of file log_sum_exp.hpp.