Skip to content

Commit e67c389

Browse files
committed
fix ambiguity misery
1 parent 55229b8 commit e67c389

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

test/linearmap.jl

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module LinearMaps
33
export LinearMap
44

55
using MatrixAlgebraKit
6-
using MatrixAlgebraKit: AbstractAlgorithm, DiagonalAlgorithm, GLA_QRIteration
6+
using MatrixAlgebraKit: AbstractAlgorithm
77
using GenericLinearAlgebra
88
import MatrixAlgebraKit as MAK
99

@@ -31,18 +31,17 @@ module LinearMaps
3131
MAK.check_input($f!, parent(A), parent.(F), alg)
3232
@eval MAK.initialize_output(::typeof($f!), A::LinearMap, alg::AbstractAlgorithm) =
3333
LinearMap.(MAK.initialize_output($f!, parent(A), alg))
34-
@eval MAK.initialize_output(::typeof($f!), A::LinearMap, alg::GLA_QRIteration) =
35-
(nothing, nothing, nothing)
36-
@eval MAK.$f!(A::LinearMap, F, alg::AbstractAlgorithm) =
37-
LinearMap.(MAK.$f!(parent(A), parent.(F), alg))
38-
@eval MAK.$f!(A::LinearMap, F, alg::GLA_QRIteration) =
39-
LinearMap.(MAK.$f!(parent(A), F, alg))
40-
@eval MAK.check_input(::typeof($f!), A::LinearMap, F, alg::DiagonalAlgorithm) =
41-
MAK.check_input($f!, parent(A), parent.(F), alg)
42-
@eval MAK.initialize_output(::typeof($f!), A::LinearMap, alg::DiagonalAlgorithm) =
43-
LinearMap.(MAK.initialize_output($f!, parent(A), alg))
44-
@eval MAK.$f!(A::LinearMap, F, alg::DiagonalAlgorithm) =
45-
LinearMap.(MAK.$f!(parent(A), parent.(F), alg))
34+
end
35+
36+
# Define svd_compact! and svd_full! for LinearMap with concrete algorithm types to avoid
37+
# ambiguity with methods like `svd_compact!(A, USVᴴ, alg::SafeDivideAndConquer)`.
38+
# Using AbstractAlgorithm here would be ambiguous since neither A-type nor alg-type would
39+
# be strictly more specific.
40+
for f! in (:svd_compact!, :svd_full!)
41+
for Alg in (:SafeDivideAndConquer, :DivideAndConquer, :QRIteration, :Bisection, :Jacobi, :SVDPolar)
42+
@eval MAK.$f!(A::LinearMap, USVᴴ, alg::MAK.$Alg) =
43+
LinearMap.(MAK.$f!(parent(A), parent.(USVᴴ), alg))
44+
end
4645
end
4746

4847
for f in (:qr, :lq, :svd)

0 commit comments

Comments
 (0)