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 method ambiguity for qr (#931) and lingering ambiguities for lu #932

Merged
merged 3 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix qr method ambiguities (#931) and lingering lu ambiguities (#920)
  • Loading branch information
thchr committed Jul 1, 2021
commit 33b641d3f47ee50c4bd184acb17843ab97589350
7 changes: 5 additions & 2 deletions src/lu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ end

@static if VERSION >= v"1.7-DEV"
# disambiguation
function lu(A::StaticMatrix{N,N}, pivot::Val{true}) where {N}
Base.@invoke lu(A::StaticMatrix{N,N} where N, pivot::Union{Val{false},Val{true}})
for p in (:true, :false)
@eval function lu(A::StaticMatrix{N,N}, pivot::Val{$p}; check = true) where {N}
Base.@invoke lu(A::StaticMatrix{N,N} where N,
pivot::Union{Val{false},Val{true}}; check)
end
end
end

Expand Down
9 changes: 9 additions & 0 deletions src/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ true
end
end

@static if VERSION >= v"1.7-DEV"
# disambiguation
for p in (:true, :false)
@eval function qr(A::StaticMatrix, pivot::Val{$p})
Base.@invoke qr(A::StaticMatrix, pivot::Union{Val{false},Val{true}})
end
end
end

function identity_perm(R::StaticMatrix{N,M,T}) where {N,M,T}
return similar_type(R, Int, Size((M,)))(ntuple(x -> x, Val{M}()))
end
Expand Down
10 changes: 10 additions & 0 deletions test/lu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ end
@test_throws SingularException lu(A)
@test !issuccess(lu(A; check = false))
end

@testset "LU method ambiguity" begin
# Issue #920; just test that methods do not throw an ambiguity error when called
A = @SMatrix [1.0 2.0; 3.0 4.0]
@test isa(lu(A), StaticArrays.LU)
@test isa(lu(A, Val(true)), StaticArrays.LU)
@test isa(lu(A, Val(false)), StaticArrays.LU)
@test isa(lu(A; check=false), StaticArrays.LU)
@test isa(lu(A; check=true), StaticArrays.LU)
end
8 changes: 8 additions & 0 deletions test/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,11 @@ Random.seed!(42)
test_qr(arr)
end
end

@testset "QR method ambiguity" begin
# Issue #931; just test that methods do not throw an ambiguity error when called
A = @SMatrix [1.0 2.0 3.0; 4.0 5.0 6.0]
@test isa(qr(A), StaticArrays.QR)
@test isa(qr(A, Val(true)), StaticArrays.QR)
@test isa(qr(A, Val(false)), StaticArrays.QR)
end