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 missing copyto! methods for triangular matrix types #54763

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

jishnub
Copy link
Contributor

@jishnub jishnub commented Jun 11, 2024

The _copyto! methods were not defined for all combinations, and copyto! was also too permissive (it accepted mismatched uplos). This PR adds the missing methods, and updates the specialized copyto! such that it only accepts combinations with matching uplos. The other cases will be handled by the fallback method.

Fixes, e.g.:

julia> using LinearAlgebra

julia> A = [1 2; 3 4];

julia> copyto!(UpperTriangular(A), UnitUpperTriangular(A))
ERROR: MethodError: no method matching _copyto!(::UpperTriangular{Int64, Matrix{Int64}}, ::UnitUpperTriangular{Int64, Matrix{Int64}})
The function `_copyto!` exists, but no method is defined for this combination of argument types.
[...]

After this,

julia> copyto!(UpperTriangular(A), UnitUpperTriangular(A))
2×2 UpperTriangular{Int64, Matrix{Int64}}:
 1  2
   1

@jishnub jishnub added domain:linear algebra Linear algebra domain:arrays [a, r, r, a, y, s] labels Jun 11, 2024
@jishnub jishnub requested a review from dkarrasch June 13, 2024 09:37
@jishnub jishnub merged commit c8a90cc into master Jun 13, 2024
10 checks passed
@jishnub jishnub deleted the jishnub/tricopytomethods branch June 13, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:arrays [a, r, r, a, y, s] domain:linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants