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

copytrito! for triangular matrices #56620

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

jishnub
Copy link
Contributor

@jishnub jishnub commented Nov 20, 2024

This does two things:

  1. Forward copytrito! for triangular matrices to the parent in case the specified uplo corresponds to the stored part. This works because these matrices share their elements with the parents for the stored part.
  2. Make copytrito! only copy the diagonal if the uplo corresponds to the non-stored part.

This makes copytrito! involving a triangular matrix equivalent to that involving its parent if the filled part is copied, and O(N) otherwise.

Examples of improvements in performance:

julia> using LinearAlgebra

julia> A1 = UpperTriangular(rand(400,400));

julia> A2 = similar(A1);

julia> @btime copytrito!($A2, $A1, 'U');
  70.753 μs (0 allocations: 0 bytes) # nightly v"1.12.0-DEV.1657"
  26.143 μs (0 allocations: 0 bytes) # this PR

julia> @btime copytrito!(parent($A2), $A1, 'U');
  56.025 μs (0 allocations: 0 bytes) # nightly
  26.633 μs (0 allocations: 0 bytes) # this PR

@jishnub jishnub added performance Must go faster linear algebra Linear algebra labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant