Most scientific libraries (e.g. numpy/scipy) provide a numerically stable implementation of log1p(x) = log(1 + x) which yields sensible values, even when x is so small in magnitude that floating point arithmetic leads to rounding errors for naive implementations.
Is there an equivalent implementation for the log-determinant of matrices to evaluate log(det(identity + A)), where A is an n by n matrix, and identity is the n by n identity matrix. For example, if A = alpha * identity is a diagonal matrix with alpha on the diagonal, the expression becomes log(det(identity * (1 + alpha)))=n * log1p(alpha). However, a general method for evaluating the expression (i.e. arbitrary A) evades me.