As reported in the following post, eigen can be called with a sortby argument to provide the output in a different order, e.g. in descending order of the eigenvalues’ real part instead of the default.
However, this does not work if the input is a matrix of StaticArrays, e.g.:
According to the error message, this seems to be a limitation of the type SMatrix, but perhaps also of the LinearAlgebra module in the way it generalizes the behavior of AbstractMatrix.
So, should this be reported in StaticArrays.jl or rather in julialang? Or perhaps in none of them, because this is an unavoidable limitation (e.g. due to the unmutability of SMatrix)?
Some special matrix types (e.g. Diagonal or SymTridiagonal) may implement their own sorting convention and not accept a sortby keyword.
So, it’s not a bug, but more a missing feature — you could request it at StaticArrays.jl.
It should definitely be possible to implement. immutability is not an issue — the whole point of StaticArrays is that it is cheap to work “out-of-place” (which doesn’t actually allocate on the heap), so it can just call sort.
Note also that for non-Hermitian arrays, eigen on SMatrix just case the generic Matrix function and converts back to SMatrix, so it could pass through the sortby keyword. By the same token, however, there is no performance advantage to using SMatrix in this case. (That being said, if you are calling eigen on arbitrary non-normal matrices you might want to re-think your overall approach.)