Restrict binary ops for Diagonal and Symmetric to Number eltypes (#55251)
The `(::Diagonal) + (::Symmetric)` and analogous methods were
specialized in https://github.com/JuliaLang/julia/pull/35333 to return a
`Symmetric`, but these only work if the `Diagonal` is also symmetric.
This typically holds for arrays of numbers, but may not hold for
block-diagonal and other types for which symmetry isn't guaranteed. This
PR restricts the methods to arrays of `Number`s.
Fixes, e.g.:
```julia
julia> using StaticArrays, LinearAlgebra
julia> D = Diagonal(fill(SMatrix{2,2}(1:4), 2))
2×2 Diagonal{SMatrix{2, 2, Int64, 4}, Vector{SMatrix{2, 2, Int64, 4}}}:
[1 3; 2 4] ⋅
⋅ [1 3; 2 4]
julia> S = Symmetric(D)
2×2 Symmetric{AbstractMatrix, Diagonal{SMatrix{2, 2, Int64, 4}, Vector{SMatrix{2, 2, Int64, 4}}}}:
[1 3; 3 4] ⋅
⋅ [1 3; 3 4]
julia> S + D
2×2 Symmetric{AbstractMatrix, Diagonal{SMatrix{2, 2, Int64, 4}, Vector{SMatrix{2, 2, Int64, 4}}}}:
[2 6; 6 8] ⋅
⋅ [2 6; 6 8]
julia> S[1,1] + D[1,1]
2×2 SMatrix{2, 2, Int64, 4} with indices SOneTo(2)×SOneTo(2):
2 6
5 8
julia> (S + D)[1,1] == S[1,1] + D[1,1]
false
```
After this,
```julia
julia> S + D
2×2 Matrix{AbstractMatrix{Int64}}:
[2 6; 5 8] [0 0; 0 0]
[0 0; 0 0] [2 6; 5 8]
```
Even with `Number`s as elements, there might be an issue with `NaN`s
along the diagonal as `!issymmetric(NaN)`, but that may be a different
PR.