# LinearAlgebra.eigen does not accept adjoint matrices ?

Since julia 0.7, the following code

``````using LinearAlgebra
A = randn(10,10)
E = eigen(A')
``````

returns an error

``````ERROR: MethodError: no method matching eigen(::Adjoint{Float64,Array{Float64,2}})
``````

This looks like a bug to me but maybe this is by design ?

If so, is there a smarter workaround than using the Matrix function ? As in

``````E = eigen(Matrix(A'))
``````

which is quite unnatural in my opinion. It looks like it may also ruin any possible optimization for special matrices, (e.g. Sparse, Diagonal, Bidiagonal, etc).

Re: special matrices: you can use `copy`:

``````julia> using LinearAlgebra

julia> Matrix(Diagonal([1, 2])')
2×2 Array{Int64,2}:
1  0
0  2

julia> copy(Diagonal([1, 2])')
2×2 Diagonal{Int64,Array{Int64,1}}:
1  ⋅
⋅  2
``````

But shouldn’t it fall back on some method for `AbstractArray`?

1 Like

Yes, probably.

Thanks. That seems to sort out the optimzation issue.

Not really the ugliness though…

Duplicate. (my reply was stuck in new user limbo)

What do you think the implementation should be? Maybe indeed just

``````LinearAlgebra.eigen(x::Union{Transpose{T, A}, Adjoint{T, A}}) where {T, A<:AbstractMatrix} = eigen(copy(x))
``````

You could add some tests and submit a PR to JuliaLang/julia.

I’d be happy to do it but I am a newcomer to julia and I am not sure how to do these things properly. I will have a look at the `eigen.jl` test file and see if I can write something not too stupid.

In the meantime I can open an issue referencing your code suggestion. It may be a good idea anyway as I would not be surprised if Adjoint types broke some other LinearAlgebra functions.

Sounds good. For context, `transpose` and `adjoint` have only recently become lazy (the `Adjoint` and `Transpose` types are new in 0.7), which is why there might still be a few missing methods for these types.

I have submitted Issue #28714 on this topic.

1 Like