-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Symmetric(A::Symmetric) should be a no-op? #423
Comments
This is not intentional so a PR would great. I think the second version is the right direction. We'll have to make a decision about aliasing though. Your version will alias the output depending on the value of |
Not sure I understood you correctly, but will the second version not always alias the julia> A = [1. 2; 3 4]; ASym = Symmetric(A);
julia> pointer(Symmetric(ASym, :U).data)
Ptr{Float64} @0x00007f73837f6890
julia> pointer(Symmetric(ASym, :L).data)
Ptr{Float64} @0x00007f73837f6890
I agree, so my new proposal would be the following: Symmetric(A::Symmetric) = A
Symmetric(A::Symmetric, uplo::Symbol) = A.uplo == char_uplo(uplo) ? A : throw(ArgumentError("something")) Will submit a PR soonish. |
You are right. I misread it. Btw, you can use the unexported |
Yea, that would have been cleaner, but would not work with for example |
I've wondered for a while whether |
@andyferris That has the unfortunate consequence of compiling two copies of each function for |
I don't think it is worth it. The example here is very much a corner case. I don't think we have seen examples of more common use cases where it would be useful to dispatch on |
It could help slightly for StaticArrays, I suppose. However, in that case a symmetric matrix that is more compact (only storing the necessary numbers) would be a bit better, if we are worried about this level of optimization. |
I find it surprising that this is the case for
Symmetric
(andHermitian
):instead of just
Symmetric{Float64,Array{Float64,2}}
. Is this behaviour ever useful?The simplest solution would be to define these:
and just ignore the
uplo
. A more general fix would be the following, but that will sometimes create a newSymmetric
/Hermitian
instance, depending on the inputuplo
:The text was updated successfully, but these errors were encountered: