% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utility.R
\name{row_log_sum_exp}
\alias{row_log_sum_exp}
\title{Row-wise log-sum-exp}
\usage{
row_log_sum_exp(mat)
}
\arguments{
\item{mat}{A numeric matrix of size \eqn{n \times K}.}
}
\value{
A numeric vector of length \eqn{n} where the i-th entry is
\eqn{\log \sum_{k=1}^K \exp(mat_{ik})}. Rows containing only \code{-Inf}
return \code{-Inf}.
}
\description{
Compute the row-wise log-sum-exp of a numeric matrix in a numerically stable
way. This is used to evaluate \eqn{\log \sum_k \exp(x_{ik})} without overflow
or underflow by subtracting the row maximum before exponentiation.
}
\keyword{internal}
