# LinearAlgebra.eigen does not accept adjoint matrices ?

**URL:** https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410
**Category:** General Usage
**Created:** [August 13, 2018, 10:02pm UTC](https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410 "2018-08-13T22:02:51Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![kragol](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kragol/32/10204_2.png) [@kragol](https://discourse.julialang.org/u/kragol)
#### Post date: [August 13, 2018, 10:02pm UTC](https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410/1 "2018-08-13T22:02:51Z")

</div>

Since julia 0.7, the following code

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

```

returns an error

```julia
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

```julia
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).

---

<div class="post-metadata">

### Author: ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)
#### Post date: [August 13, 2018, 10:06pm UTC](https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410/2 "2018-08-13T22:06:18Z")

</div>

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

```julia
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

```

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [August 13, 2018, 10:32pm UTC](https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410/3 "2018-08-13T22:32:03Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)
#### Post date: [August 13, 2018, 10:33pm UTC](https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410/4 "2018-08-13T22:33:25Z")

</div>

Yes, probably.

---

<div class="post-metadata">

### Author: ![kragol](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kragol/32/10204_2.png) [@kragol](https://discourse.julialang.org/u/kragol)
#### Post date: [August 14, 2018, 12:59am UTC](https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410/5 "2018-08-14T00:59:51Z")

</div>

Thanks. That seems to sort out the optimzation issue.

Not really the ugliness though…

---

<div class="post-metadata">

### Author: ![kragol](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kragol/32/10204_2.png) [@kragol](https://discourse.julialang.org/u/kragol)
#### Post date: [August 14, 2018, 12:59am UTC](https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410/6 "2018-08-14T00:59:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)
#### Post date: [August 14, 2018, 1:11pm UTC](https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410/7 "2018-08-14T13:11:41Z")

</div>

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

```julia
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.

---

<div class="post-metadata">

### Author: ![kragol](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kragol/32/10204_2.png) [@kragol](https://discourse.julialang.org/u/kragol)
#### Post date: [August 16, 2018, 12:24pm UTC](https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410/8 "2018-08-16T12:24:27Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)
#### Post date: [August 16, 2018, 1:55pm UTC](https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410/9 "2018-08-16T13:55:33Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![kragol](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kragol/32/10204_2.png) [@kragol](https://discourse.julialang.org/u/kragol)
#### Post date: [August 16, 2018, 11:14pm UTC](https://discourse.julialang.org/t/linearalgebra-eigen-does-not-accept-adjoint-matrices/13410/10 "2018-08-16T23:14:29Z")

</div>

I have submitted [Issue #28714](https://github.com/JuliaLang/julia/issues/28714) on this topic.
