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

Reuse du2 of Tridiagonal matrix for pivoting in lu! if extant #47564

Merged
merged 4 commits into from
Nov 28, 2022

Conversation

brenhinkeller
Copy link
Contributor

The LinearAlgebra.Tridiagonal type contains an optional upper second diagonal for pivoting

julia> using LinearAlgebra

julia> a = Tridiagonal(ones(9), ones(10), ones(9));

julia> isdefined(a, :du2)
false

julia> b = Tridiagonal(ones(9), ones(10), ones(9), ones(8));

julia> isdefined(b, :du2)
true

However lu! currently does not use this, and instead just allocates a new one even if it already exists.

This PR has lu!(A::Tridiagonal, ...) check if the second upper diagonal is already defined and of the proper size and type, and uses it if so.

This can be a nontrivial speedup and reduction in allocations if lu! is used in a hot loop.

@brenhinkeller
Copy link
Contributor Author

brenhinkeller commented Nov 14, 2022

Oh, or should this be opened against https://github.com/JuliaLang/LinearAlgebra.jl instead?
edit: looks like this is the right place for now

@dkarrasch dkarrasch added the linear algebra Linear algebra label Nov 14, 2022
@brenhinkeller brenhinkeller added the performance Must go faster label Nov 16, 2022
@brenhinkeller brenhinkeller added the merge me PR is reviewed. Merge when all tests are passing label Nov 25, 2022
@fredrikekre fredrikekre merged commit 20d13da into JuliaLang:master Nov 28, 2022
@brenhinkeller brenhinkeller removed the merge me PR is reviewed. Merge when all tests are passing label Nov 28, 2022
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.

3 participants