complex_gen_matrix_log computes the principal matrix logarithm, , of a complex matrix , with no eigenvalues on the closed negative real line.

For full information please refer to the NAG Library document for f01fj

acomplex, array-like, shape

The matrix .

acomplex, ndarray, shape

The principal matrix logarithm, , unless = 2, in which case a non-principal logarithm is returned.

(errno )

On entry, .

Constraint: .

(errno )

is singular so the logarithm cannot be computed.

(errno )

An unexpected internal error has occurred. Please contact NAG.

(errno )

was found to have eigenvalues on the negative real line. The principal logarithm is not defined in this case, so a non-principal logarithm was returned.

(errno )

The arithmetic precision is higher than that used for the Padé approximant computed matrix logarithm.


Any nonsingular matrix has infinitely many logarithms. For a matrix with no eigenvalues on the closed negative real line, the principal logarithm is the unique logarithm whose spectrum lies in the strip . If is nonsingular but has eigenvalues on the negative real line, the principal logarithm is not defined, but complex_gen_matrix_log will return a non-principal logarithm.

is computed using the inverse scaling and squaring algorithm for the matrix logarithm described in Al–Mohy and Higham (2011).


Al–Mohy, A H and Higham, N J, 2011, Improved inverse scaling and squaring algorithms for the matrix logarithm, SIAM J. Sci. Comput. (34(4)), C152–C169

Higham, N J, 2008, Functions of Matrices: Theory and Computation, SIAM, Philadelphia, PA, USA