-
-
Notifications
You must be signed in to change notification settings - Fork 22
Adding (SymTri)Diagonal, Symmetric or Hermitian matrices together #439
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
Comments
If you'd like to open a PR to do this, sounds reasonable to me. If you're unsure of what the resultant types should be or the rationale, you can add "RFC" to the title (request for comment). @andreasnoack, @Sacha0, or @fredrikekre could probably give you some guidance if you'd like. |
+1, this is on my I think we can do better than julia> foo(A, B) = Symmetric(A + B);
julia> bar(A, B) = Symmetric(A.data + B.data);
julia> N = 100; A = rand(N, N); S = Symmetric(A);
julia> @btime foo($S, $S);
51.371 μs (3 allocations: 78.23 KiB)
julia> @btime bar($S, $S);
5.989 μs (3 allocations: 78.23 KiB)
julia> N = 1000; A = rand(N, N); S = Symmetric(A);
julia> @btime foo($S, $S);
4.455 ms (3 allocations: 7.63 MiB)
julia> @btime bar($S, $S);
1.009 ms (3 allocations: 7.63 MiB) Will you submit a PR? |
Yeah, the |
function +(A::Symmetric, B::Symmetric)
if A.uplo == 'U'
if B.uplo == 'U'
return Symmetric(A.data + B.data, :U)
else # B.uplo == 'L'
return Symmetric(A.data + B.data.', :U)
end
else # A.uplo == 'L'
if B.uplo == 'L'
return Symmetric(A.data + B.data, :L)
else # B.uplo == 'U'
return Symmetric(A.data + B.data.', :L)
end
end
end But then we have to think about JuliaLang/julia#22396 (comment) I think, e.g. if the |
The transpose in the last case should still be on B. |
Yea, updated. |
I personally do not have too much use for block matrices, but the transpose would need to be recursive in that case. I believe the plan (#20978) was to add a recursive transpose method and have the |
For a start we can limit this to |
Is is this feature still considered? that would be awesome to get it implemented! |
Yes, this seems like it can be considered a minor change. |
This was first fixed in JuliaLang/julia#29500 (v1.2), and most recently touched in JuliaLang/julia#35325 (v1.5). |
Sorry, the combinations with |
Currently adding e.g. two Symmetric matrices together results in a regular array. It would seem appropriate to add special methods:
I hope I haven't made any mistakes with the above...
If that proposal is accepted, would the following style of definition be ok?
The text was updated successfully, but these errors were encountered: