-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix constructors of Symmetric and Hermitian #21622
Fix constructors of Symmetric and Hermitian #21622
Conversation
if A.uplo == char_uplo(uplo) | ||
return A | ||
else | ||
throw(ArgumentError("Cannot construct Symmetric; uplo doesn't match")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestions for better messages here? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just ignore the uplo argument? Presumably, if you're building a symmetric matrix from an already symmetric matrix, taking the lower or upper triangle should not matter since they are the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is unlikely that people will hit this exception on purpose, i.e. where they want to flip the storage. We can revisit if it is really an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @fredrikekre! :)
@@ -41,6 +41,15 @@ julia> Slower = Symmetric(A, :L) | |||
Note that `Supper` will not be equal to `Slower` unless `A` is itself symmetric (e.g. if `A == A.'`). | |||
""" | |||
Symmetric(A::AbstractMatrix, uplo::Symbol=:U) = (checksquare(A); Symmetric{eltype(A),typeof(A)}(A, char_uplo(uplo))) | |||
Symmetric(A::Symmetric) = A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny bit inconsistent that here the default uplo matches that of the input, whereas on all other types it defaults to upper
Fix JuliaLang/LinearAlgebra.jl#423