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



The following snippet:

M = Hermitian(speye(10))

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


On my installation of v0.6.2 it is Hermitian.

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

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


I believe @cossio might be referring to the type not being Hermitian, but rather Array.


I mean the type.


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


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.


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.


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.