Closed marvinlenk closed 7 months ago
This looks to be related to this weird bug https://github.com/JuliaLang/LinearAlgebra.jl/issues/1064
This bug seems to exist in Julia 1.0:
julia> y = [0.279982+0.988074im 0.770011+0.870555im
0.138001+0.889728im 0.177242+0.701413im] |> Hermitian;
julia> inv(y) * y
2×2 Array{Complex{Float64},2}:
0.648315+5.55112e-17im 0.0487625+0.0551296im
0.0686912-0.0776606im 0.646396-5.55112e-17im
julia> inv(collect(y)) * y
2×2 Array{Complex{Float64},2}:
1.0-1.11022e-16im -1.20814e-17+0.0im
-1.56742e-17+2.77556e-17im 1.0+0.0im
julia> VERSION
v"1.0.5"
I get the same numbers on 1.12.0-DEV.320.
We forgot to realify the main diagonal of the underlying data storage. Fix is coming.
I noticed a problem with
Hermitian
matrices, especially the inverse of them. For any given invertible square matrixx,
x / x
andx \ x
should be the identity matrix (or at least close to it). Invoking this on aHermitian
complex matrixy = Hermitian(x)
results in a filled complex matrix, that is not even hermitian. At leasty / y
is the hermitian conjugate ofy \ y
.Using
z = hermitianpart(y)
does however give correct results forz / z
andz \ z
. Notably,z == y
andtypeof(z) == typeof(y)
istrue
. The inverse also works for Hermitian real matrices.Minimal working example:
Output is
false
forbut expected to be
true
.Output of versioninfo():