Skip to content

Commit a50d084

Browse files
Merge pull request #138 from dkarrasch/dk/fact
Prepare for `AdjointFactorization`, multiple dispatch
2 parents d728a14 + 1c9e822 commit a50d084

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/matrix.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ function DiagonalOperator(diag::AbstractVector; update_func=DEFAULT_UPDATE_FUNC)
111111
end
112112
LinearAlgebra.Diagonal(L::MatrixOperator) = MatrixOperator(Diagonal(L.A))
113113

114+
const AdjointFact = isdefined(LinearAlgebra, :AdjointFactorization) ? LinearAlgebra.AdjointFactorization : Adjoint
115+
const TransposeFact = isdefined(LinearAlgebra, :TransposeFactorization) ? LinearAlgebra.TransposeFactorization : Transpose
116+
114117
"""
115118
InvertibleOperator(F)
116119
@@ -153,13 +156,12 @@ function Base.convert(::Type{<:Factorization}, L::InvertibleOperator{T,<:Factori
153156
L.F
154157
end
155158

156-
function Base.convert(::Type{AbstractMatrix}, L::InvertibleOperator)
157-
if L.F isa Adjoint
158-
convert(AbstractMatrix,L.F')'
159-
else
160-
convert(AbstractMatrix, L.F)
161-
end
162-
end
159+
Base.convert(::Type{AbstractMatrix}, L::InvertibleOperator) =
160+
convert(AbstractMatrix, L.F)
161+
Base.convert(::Type{AbstractMatrix}, L::InvertibleOperator{<:Any,<:Union{Adjoint,AdjointFact}}) =
162+
adjoint(convert(AbstractMatrix, adjoint(L.F)))
163+
Base.convert(::Type{AbstractMatrix}, L::InvertibleOperator{<:Any,<:Union{Transpose,TransposeFact}}) =
164+
transpose(convert(AbstractMatrix, transpose(L.F)))
163165

164166
# traits
165167
Base.size(L::InvertibleOperator) = size(L.F)

test/matrix.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,12 @@ for square in [false, true] #for K in [1, K]
231231
v2=copy(u2); @test ldiv!(opAB_F , u2) AB \ v2
232232
v3=copy(u3); @test ldiv!(opABC_F, u3) ABC \ v3
233233
else # TODO
234-
u2=rand(N2,K); @test_broken ldiv!(u2, opAB_F , v2) AB \ v2 # fails
234+
u2=rand(N2,K);
235+
if VERSION < v"1.9-"
236+
@test_broken ldiv!(u2, opAB_F , v2) AB \ v2
237+
else
238+
@test ldiv!(u2, opAB_F , v2) AB \ v2
239+
end
235240
u3=rand(N3,K); @test_broken ldiv!(u3, opABC_F, v3) ABC \ v3 # errors
236241
end
237242

0 commit comments

Comments
 (0)