Closed
Description
opened on Feb 17, 2017
Suppose P
is a real square diagonal matrix, then APA'
should be Hermitian with real diagonal elements. There is however a chance for some diagonal elements to have nonzero imaginary parts.
julia> using LinearAlgebra, SparseArrays
julia> m, n = 2, 3;
julia> A = randn(m,n) + im*randn(m,n);
julia> p = abs.( randn(n) );
julia> A * spdiagm(p) * A'
2×2 Array{Complex{Float64},2}:
1.34723+5.55112e-17im -0.18145+1.30975im
-0.18145-1.30975im 4.48512+2.22045e-16im
Enforcing Hermitian
(e.g. as input for cholfact
) will end up with the following error.
julia> Hermitian( A * spdiagm(p) * A' )
ERROR: ArgumentError: Cannot construct Hermitian from matrix with nonreal diagonals
in Hermitian{T,S<:AbstractArray{T,2}}(::Array{Complex{Float64},2}, ::Symbol) at ./linalg/symmetric.jl:50
in Hermitian{T,S<:AbstractArray{T,2}}(::Array{Complex{Float64},2}) at ./linalg/symmetric.jl:48
A work-around could be to re-assign the diagonal elements to their real parts, but that would also slow things down.
julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753 (2016-09-19 18:14 UTC)
Platform Info:
System: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
WORD_SIZE: 64
BLAS: libopenblas (NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: liblapack.so.3
LIBM: libopenlibm
LLVM: libLLVM-3.7.1 (ORCJIT, broadwell)
Metadata
Assignees
Labels
No labels
Activity