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 fetching parent in symmetric algebra #56286

Merged
merged 1 commit into from
Oct 23, 2024
Merged

Conversation

jishnub
Copy link
Contributor

@jishnub jishnub commented Oct 22, 2024

We only need the parent of the result if it is a triangular matrix. For other structurally triangular matrices, such as Diagonals, we may use these directly in the Hermitian constructor.

The operation proceeds as (assuming H isa Hermitian with H.uplo == 'U'):

function +(H::Hermitian, H::Hermitian)
    U = uppertriangular(parent(H))
    Ures = U + U
    data = Ures isa UpperTriangular ? parent(Ures) : Ures # this PR
    Hermitian(data, :U)
end

This accounts for the fact that Ures may not be an UpperTriangular, as uppertriangular might be specialized by the parent. In such cases we should not extract the parent. Currently, only Diagonal specializes uppertriangular, so this issue only exists for a Hermitian or a Symmetric that wraps a Diagonal.

Fixes #56283

@jishnub jishnub added linear algebra Linear algebra backport 1.11 Change should be backported to release-1.11 arrays [a, r, r, a, y, s] labels Oct 22, 2024
@jishnub jishnub merged commit 5e4fb51 into master Oct 23, 2024
10 of 12 checks passed
@jishnub jishnub deleted the jishnub/parentof_applytri branch October 23, 2024 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s] backport 1.11 Change should be backported to release-1.11 linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scalar times Hermitian (*(x::Float64, A::Hermitian{F, Diagonal{F, Vector{F}}})) is broken
2 participants