I think this is the last matrix function still missing from LinearAlgebra, in the sense that it is both common enough to belong in the standard library and nontrivial enough to deserve a dedicated implementation.
In principle one can define it equally well as abs(A) = sqrt(A'A) or abs(A) = sqrt(A*A'), but the convention is that the former is used; this fits with the convention of writing the polar decomposition as A ≈ U * abs(A) instead of A ≈ abs(A) * U.
The definition is however not a good way to compute it. In the Hermitian case one can simply compute the eigendecomposition and take the absolute value of the eigenvalues; in the general (even non-square) case, probably the best way to compute is via the singular value decomposition: let u, s, v = svd(A), then abs(A) = v' * Diagonal(s) * v. See discussion at https://discourse.julialang.org/t/absolute-value-of-a-matrix/98301
I think this is the last matrix function still missing from
LinearAlgebra, in the sense that it is both common enough to belong in the standard library and nontrivial enough to deserve a dedicated implementation.In principle one can define it equally well as
abs(A) = sqrt(A'A)orabs(A) = sqrt(A*A'), but the convention is that the former is used; this fits with the convention of writing the polar decomposition asA ≈ U * abs(A)instead ofA ≈ abs(A) * U.The definition is however not a good way to compute it. In the Hermitian case one can simply compute the eigendecomposition and take the absolute value of the eigenvalues; in the general (even non-square) case, probably the best way to compute is via the singular value decomposition: let
u, s, v = svd(A), thenabs(A) = v' * Diagonal(s) * v. See discussion at https://discourse.julialang.org/t/absolute-value-of-a-matrix/98301