Skip to content

Commit 33b641d

Browse files
committed
fix qr method ambiguities (#931) and lingering lu ambiguities (#920)
1 parent 1a06987 commit 33b641d

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

src/lu.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ end
4545

4646
@static if VERSION >= v"1.7-DEV"
4747
# disambiguation
48-
function lu(A::StaticMatrix{N,N}, pivot::Val{true}) where {N}
49-
Base.@invoke lu(A::StaticMatrix{N,N} where N, pivot::Union{Val{false},Val{true}})
48+
for p in (:true, :false)
49+
@eval function lu(A::StaticMatrix{N,N}, pivot::Val{$p}; check = true) where {N}
50+
Base.@invoke lu(A::StaticMatrix{N,N} where N,
51+
pivot::Union{Val{false},Val{true}}; check)
52+
end
5053
end
5154
end
5255

src/qr.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ true
4747
end
4848
end
4949

50+
@static if VERSION >= v"1.7-DEV"
51+
# disambiguation
52+
for p in (:true, :false)
53+
@eval function qr(A::StaticMatrix, pivot::Val{$p})
54+
Base.@invoke qr(A::StaticMatrix, pivot::Union{Val{false},Val{true}})
55+
end
56+
end
57+
end
58+
5059
function identity_perm(R::StaticMatrix{N,M,T}) where {N,M,T}
5160
return similar_type(R, Int, Size((M,)))(ntuple(x -> x, Val{M}()))
5261
end

test/lu.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ end
6565
@test_throws SingularException lu(A)
6666
@test !issuccess(lu(A; check = false))
6767
end
68+
69+
@testset "LU method ambiguity" begin
70+
# Issue #920; just test that methods do not throw an ambiguity error when called
71+
A = @SMatrix [1.0 2.0; 3.0 4.0]
72+
@test isa(lu(A), StaticArrays.LU)
73+
@test isa(lu(A, Val(true)), StaticArrays.LU)
74+
@test isa(lu(A, Val(false)), StaticArrays.LU)
75+
@test isa(lu(A; check=false), StaticArrays.LU)
76+
@test isa(lu(A; check=true), StaticArrays.LU)
77+
end

test/qr.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ Random.seed!(42)
6060
test_qr(arr)
6161
end
6262
end
63+
64+
@testset "QR method ambiguity" begin
65+
# Issue #931; just test that methods do not throw an ambiguity error when called
66+
A = @SMatrix [1.0 2.0 3.0; 4.0 5.0 6.0]
67+
@test isa(qr(A), StaticArrays.QR)
68+
@test isa(qr(A, Val(true)), StaticArrays.QR)
69+
@test isa(qr(A, Val(false)), StaticArrays.QR)
70+
end

0 commit comments

Comments
 (0)