-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Allow changing arbitrary entries in symmetric/Hermitian matrices #33071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm not sure this is the right thing to do. A function that makes use of this kind of indexing would probably have to be restricted to |
See discussion in #19228 (where it was decided against this). |
I didn't know about the discussion in #19228, thanks! I have made this PR because it simply felt natural to me to be able to change non-diagonal entries of symmetric matrices by doing So the concern is that this modified An alternative could be to expose these |
I didn't really appreciate the objections to setting both sides of the diagonal simultaneously at first — I mean, I got the objection on its face that The key is that we assume So, no, I don't think we should do this. We should, however, reconsider the fact that we still return |
See JuliaLang/LinearAlgebra.jl#271 for the |
We have moved the LinearAlgebra stdlib to an external repo: https://github.com/JuliaLang/LinearAlgebra.jl @goggle If you think that this PR is still relevant, please open a new PR on the LinearAlgebra.jl repo. |
This PR enables the ability to change arbitrary entries in symmetric and Hermitian matrices, as it was previously discussed in JuliaLang/LinearAlgebra.jl#110.
I have tried to do this in the most reasonable way:
v
at(i, j)
(i != j
) means that the corresponding entry at(j, i)
gets set as well (to keep the matrix symmetric or Hermitian).A
is a symmetric (or Hermitian) block matrix and we set a diagonal elementv
at(i, j)
, we set it to the symmetric (or Hermitian) version ofv
with the sameuplo
as the underlying matrixA
. This has to be done to keep the matrixA
symmetric (or Hermitian).ArgumentError
) in the Hermitian case. Another approach would be to silently truncate the imaginary part of the value.This PR also fixes JuliaLang/LinearAlgebra.jl#646.