Skip to content
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

Merged
merged 1 commit into from
Apr 29, 2017

Conversation

fredrikekre
Copy link
Member

Fix #21616

if A.uplo == char_uplo(uplo)
return A
else
throw(ArgumentError("Cannot construct Symmetric; uplo doesn't match"))
Copy link
Member Author

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? :)

Copy link
Contributor

@jebej jebej Apr 28, 2017

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

@ararslan ararslan added the domain:linear algebra Linear algebra label Apr 28, 2017
Copy link
Member

@Sacha0 Sacha0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fredrikekre! :)

@KristofferC KristofferC merged commit 66de6eb into JuliaLang:master Apr 29, 2017
@fredrikekre fredrikekre deleted the fe/symmetricsymmetric branch April 29, 2017 17:08
@@ -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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants