# Why full(Hermitian{Sparse}) is not Hermitian?

**URL:** <https://discourse.julialang.org/t/why-full-hermitian-sparse-is-not-hermitian/9756>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 16, 2018, 12:31pm UTC](https://discourse.julialang.org/t/why-full-hermitian-sparse-is-not-hermitian/9756 "2018-03-16T12:31:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [March 16, 2018, 12:31pm UTC](https://discourse.julialang.org/t/why-full-hermitian-sparse-is-not-hermitian/9756/1 "2018-03-16T12:31:07Z")

</div>

The following snippet:

```julia
M = Hermitian(speye(10))
full(M)

```

does not return an Hermitian matrix. Is there a reason for this?

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [March 16, 2018, 3:37pm UTC](https://discourse.julialang.org/t/why-full-hermitian-sparse-is-not-hermitian/9756/2 "2018-03-16T15:37:17Z")

</div>

On my installation of `v0.6.2` it is Hermitian.

```julia
julia> ishermitian(full(Hermitian(speye(10))))
true

```

And the object returned is the identity matrix as a `Matrix` of type `Float64`.  
Are you using an old version of Julia ?

---

<div class="post-metadata">

**Author:** ![pablosanjose](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pablosanjose/32/7006_2.png) [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Post date:** [March 16, 2018, 3:42pm UTC](https://discourse.julialang.org/t/why-full-hermitian-sparse-is-not-hermitian/9756/3 "2018-03-16T15:42:55Z")

</div>

I believe @e3c6 might be referring to the _type_ not being `Hermitian`, but rather `Array`.

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [March 16, 2018, 3:50pm UTC](https://discourse.julialang.org/t/why-full-hermitian-sparse-is-not-hermitian/9756/4 "2018-03-16T15:50:00Z")

</div>

I mean the type.

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [March 16, 2018, 5:04pm UTC](https://discourse.julialang.org/t/why-full-hermitian-sparse-is-not-hermitian/9756/5 "2018-03-16T17:04:45Z")

</div>

Oh, that makes sense. Good question. The documentation for `full` doesn’t even mention methods for particular matrix types.

---

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [March 16, 2018, 7:00pm UTC](https://discourse.julialang.org/t/why-full-hermitian-sparse-is-not-hermitian/9756/6 "2018-03-16T19:00:51Z")

</div>

Isn’t the point of `full` to give a full array? (That is, an array where every element corresponds to it’s own location in memory.) For example, one might call `full` on a Hermitian matrix before modifying an off-diagonal element.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [March 16, 2018, 7:01pm UTC](https://discourse.julialang.org/t/why-full-hermitian-sparse-is-not-hermitian/9756/7 "2018-03-16T19:01:42Z")

</div>

`full` has been deprecated for this very reason. What does it mean? Does it give a dense `Hermitian` matrix in this case? Or a plain old `Array`? Both the meaning and use cases are quite unclear.

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [March 16, 2018, 10:03pm UTC](https://discourse.julialang.org/t/why-full-hermitian-sparse-is-not-hermitian/9756/8 "2018-03-16T22:03:30Z")

</div>

Looking at the code in _LinearAlgebra_ briefly, it seems that `full(m)` when applied to a “special” matrix type means "convert to a representation as an `Array{T,2}`, where `T` is the element type of the source matrix. That’s not inherently ambiguous. But, `full` is ambiguous because the name doesn’t signal its behavior and it doesn’t seem to be documented. `full` is also redundant because one should be able to (and can) use `Matrix(m)` or `Array(m)`. These are also better because its clear what they will return. There is probably a reason why a convenience function to convert from a `Hermitian` with sparse data, to one with dense data is not provided. Instead, given `msp = Hermitian(sparse(1.0I,3,3))`, you have to do  
`mdense = Hermitian(Matrix(msp))`. If there is no clear use case, and no one asks for it, better not to introduce such a convenience function.
