matlog {complexplus} | R Documentation |
Matrix Logarithm
Description
matlog
computes the (principal) matrix logarithm of a square matrix.
Usage
matlog(A, ...)
Arguments
A |
a square matrix, real or complex. |
... |
arguments passed to or from other methods. |
Details
This function adapts function logm
from package expm
to be able to handle complex matrices, by decomposing the original matrix
into real and purely imaginary matrices and creating a real
block matrix that function logm
can successfully process.
If the original matrix is real, matlog
calls logm
directly for maximum efficiency.
Hence, for real matrices, matlog
can compute the matrix logarithm in the same instances as logm
;
for complex matrices, matlog
can compute the matrix logarithm as long as all real
eigenvalues are positive: zero eigenvalues imply singularity (and therefore the log
does not exist) and negative eigenvalues can be problematic as it may be hard and
numerically unstable to calculate Jordan blocks. See references below.
Value
The matrix logarithm of A. Method used may be chosen from the options available in logm
.
Author(s)
Albert Dorador
References
For more on the matrix logarithm, visit https://en.wikipedia.org/wiki/Logarithm_of_a_matrix
See Also
Examples
A <- matrix(c(1, 2, 2+3i, 5), ncol = 2) # complex matrix
B <- matrix(c(2, 0, 3, 4), ncol = 2) # real matrix with positive eigenvalues
matlog(A)
matlog(A, "Eigen") # uses Eigen method in function logm
matlog(B)
matlog(B, "Eigen") # uses Eigen method in function logm