Skip to content

Inverse broken for adjoint matrices #32537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fremling opened this issue Jul 9, 2019 · 2 comments
Closed

Inverse broken for adjoint matrices #32537

fremling opened this issue Jul 9, 2019 · 2 comments

Comments

@fremling
Copy link

fremling commented Jul 9, 2019

I have noticed that the adjoint (') functionality breaks the matrix inversion (inv) unless one get's rid of the adjoint attribute (by e.g. multiplying by one).

Here is a minimal working example

function InverseOfAdjoint()
    TheMatrix = fill(im*0.0,2,2)
    TheMatrix[1,2]=im
    TheMatrix[2,1]=im

    println("TheMatrix:")
    display(TheMatrix)

    TheAdjoint=TheMatrix'
    println("TheAdjoint:")
    display(TheAdjoint)

    InverseMatrix=inv(TheMatrix)
    println("InverseMatrix:")
    display(InverseMatrix)

    InverseNumericAdjoint=inv(TheAdjoint .* 1.0)
    println("InverseNumericAdjoint:")
    display(InverseNumericAdjoint)

    InverseAdjoint=inv(TheAdjoint)
    println("InverseAdjoint:")
    display(InverseAdjoint)
end

InverseOfAdjoint()

Which cause the output:

TheMatrix:
2×2 Array{Complex{Float64},2}:
 0.0+0.0im  0.0+1.0im
 0.0+1.0im  0.0+0.0im
TheAdjoint:
2×2 Adjoint{Complex{Float64},Array{Complex{Float64},2}}:
 0.0-0.0im  0.0-1.0im
 0.0-1.0im  0.0-0.0im
InverseMatrix:
2×2 Array{Complex{Float64},2}:
 -0.0+0.0im  0.0-1.0im
  0.0-1.0im  0.0+0.0im
InverseNumericAdjoint:
2×2 Array{Complex{Float64},2}:
 0.0-0.0im  0.0+1.0im
 0.0+1.0im  0.0+0.0im
ERROR: LoadError: MethodError: no method matching adjoint(::LDLt{Complex{Float64},SymTridiagonal{Complex{Float64},Array{Complex{Float64},1}}})
Closest candidates are:
  adjoint(::Missing) at missing.jl:79
  adjoint(::Number) at number.jl:193
  adjoint(::Adjoint) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/LinearAlgebra/src/adjtrans.jl:104
  ...
Stacktrace:
 [1] factorize(::Adjoint{Complex{Float64},Array{Complex{Float64},2}}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/LinearAlgebra/src/dense.jl:1216
 [2] inv(::Adjoint{Complex{Float64},Array{Complex{Float64},2}}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/LinearAlgebra/src/generic.jl:803
 [3] InverseOfAdjoint() at MinimalExample.jl:22
 [4] top-level scope at none:0
 [5] include at ./boot.jl:317 [inlined]
 [6] include_relative(::Module, ::String) at ./loading.jl:1044
 [7] include(::Module, ::String) at ./sysimg.jl:29
 [8] include(::String) at ./client.jl:392
 [9] top-level scope at none:0
in expression starting at MinimalExample.jl:27
@pablosanjose
Copy link
Contributor

This seems to be fixed on v1.1 and later, although it does fail on v1.0

@StefanKarpinski
Copy link
Member

Yes, see #26302 and #30047. This is a feature, so not eligible for backport to the 1.0.x series.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants