Skip to content

Commit 6d7e3f7

Browse files
committed
Simplify multiple dispatch
1 parent 710a0d3 commit 6d7e3f7

18 files changed

+159
-202
lines changed

docs/src/custom.jl

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ Base.size(A::MyFillMap) = A.size
3535
# on the level of `mul!` etc. Factoring out dimension checking is done to minimise overhead
3636
# caused by repetitive checking.
3737

38-
function LinearMaps._unsafe_mul!(y::AbstractVecOrMat, A::MyFillMap, x::AbstractVector)
38+
# !!! note
39+
# Multiple dispatch at the `_unsafe_mul!` level happens via the second (the map type)
40+
# and the third arguments (`AbstractVector` or `AbstractMatrix`, see the
41+
# [Application to matrices](@ref) section below). For that reason, the output argument
42+
# can remain type-unbound.
43+
44+
function LinearMaps._unsafe_mul!(y, A::MyFillMap, x::AbstractVector)
3945
return fill!(y, iszero(A.λ) ? zero(eltype(y)) : A.λ*sum(x))
4046
end
4147

@@ -45,7 +51,8 @@ end
4551
# * in-place multiplication with vectors `mul!(y, A, x)`,
4652
# * in-place multiply-and-add with vectors `mul!(y, A, x, α, β)`,
4753
# * in-place multiplication and multiply-and-add with matrices `mul!(Y, A, X, α, β)`,
48-
# * conversion to a (sparse) matrix `Matrix(A)` and `sparse(A)`.
54+
# * conversion to a (sparse) matrix `Matrix(A)` and `sparse(A)`,
55+
# * complete slicing of columns (and rows if the adjoint action is defined).
4956

5057
A = MyFillMap(5.0, (3, 3)); x = ones(3); sum(x)
5158

@@ -80,20 +87,14 @@ using BenchmarkTools
8087

8188
# The second benchmark indicates the allocation of an intermediate vector `z`
8289
# which stores the result of `A*x` before it gets scaled and added to (the scaled)
83-
# `y = zeros(3)`. For that reason, it is beneficial to provide a custom "5-arg `mul!`"
84-
# if you can avoid the allocation of an intermediate vector. To indicate that there
85-
# exists an allocation-free implementation, you should set the `MulStyle` trait,
86-
# whose default is `ThreeArg()`.
90+
# `y = zeros(3)`. For that reason, it is beneficial to provide a custom "5-arg
91+
# `_unsafe_mul!`" if you can avoid the allocation of an intermediate vector. To indicate
92+
# that there exists an allocation-free implementation of multiply-and-add, you should set
93+
# the `MulStyle` trait, whose default is `ThreeArg()`, to `FiveArg()`.
8794

8895
LinearMaps.MulStyle(A::MyFillMap) = FiveArg()
8996

90-
function LinearMaps._unsafe_mul!(
91-
y::AbstractVecOrMat,
92-
A::MyFillMap,
93-
x::AbstractVector,
94-
α::Number,
95-
β::Number
96-
)
97+
function LinearMaps._unsafe_mul!(y, A::MyFillMap, x::AbstractVector, α, β)
9798
if iszero(α)
9899
!isone(β) && rmul!(y, β)
99100
return y
@@ -159,7 +160,7 @@ try MyFillMap(5.0, (3, 4))' * ones(3) catch e println(e) end
159160
# wrapped map types; for instance,
160161

161162
function LinearMaps._unsafe_mul!(
162-
y::AbstractVecOrMat,
163+
y,
163164
transA::LinearMaps.TransposeMap{<:Any,<:MyFillMap},
164165
x::AbstractVector
165166
)
@@ -183,7 +184,7 @@ MyFillMap(5.0, (3, 4))' * ones(3)
183184
Base.delete_method(
184185
first(methods(
185186
LinearMaps._unsafe_mul!,
186-
(AbstractVecOrMat, LinearMaps.TransposeMap{<:Any,<:MyFillMap}, AbstractVector))
187+
(Any, LinearMaps.TransposeMap{<:Any,<:MyFillMap}, AbstractVector))
187188
)
188189
)
189190

@@ -222,13 +223,13 @@ mul!(similar(x)', x', A)
222223
# Calling the in-place multiplication function `mul!(Y, A, X)` for matrices,
223224
# however, does compute the columnwise action of `A` on `X` and stores the
224225
# result in `Y`. In case there is a more efficient implementation for the
225-
# matrix application, you can provide `mul!` methods with signature
226-
# `mul!(Y::AbstractMatrix, A::MyFillMap, X::AbstractMatrix)`, and, depending
226+
# matrix application, you can provide `_unsafe_mul!` methods with signature
227+
# `_unsafe_mul!(Y, A::MyFillMap, X::AbstractMatrix)`, and, depending
227228
# on the chosen path to handle adjoints/transposes, corresponding methods
228229
# for wrapped maps of type `AdjointMap` or `TransposeMap`, plus potentially
229230
# corresponding 5-arg `mul!` methods. This may seem like a lot of methods to
230231
# be implemented, but note that adding such methods is only necessary/recommended
231-
# for performance.
232+
# for increased performance.
232233

233234
# ## Computing a matrix representation
234235

@@ -250,7 +251,7 @@ M = Matrix{eltype(F)}(undef, size(F))
250251
# for instance (as before, size checks need not be included here since they are handled by
251252
# the corresponding `LinearAlgebra.mul!` method):
252253

253-
LinearMaps._unsafe_mul!(M::AbstractMatrix, A::MyFillMap, s::Number) = fill!(M, A.λ*s)
254+
LinearMaps._unsafe_mul!(M, A::MyFillMap, s::Number) = fill!(M, A.λ*s)
254255
@benchmark Matrix($F)
255256

256257
#-

docs/src/history.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
For custom `LinearMap` subtypes, there are now two options:
117117
1. In case your type is invariant under adjoint/transposition (i.e.,
118118
`adjoint(L::MyLinearMap)::MyLinearMap` similar to, for instance,
119-
`LinearCombination`s or `CompositeMap`s, `At_mul_B!` and `Ac_mul_B!` do
119+
`LinearCombination`s or `CompositeMap`s), `At_mul_B!` and `Ac_mul_B!` do
120120
not require any replacement! Rather, multiplication by `L'` is, in this case,
121121
handled by `mul!(y, L::MyLinearMap, x[, α, β])`.
122122
2. Otherwise, you will need to define `mul!` methods with the signature

docs/src/types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Base.:*(::AbstractMatrix,::LinearMap)
116116
LinearAlgebra.mul!(::AbstractVecOrMat,::LinearMap,::AbstractVector)
117117
LinearAlgebra.mul!(::AbstractVecOrMat,::LinearMap,::AbstractVector,::Number,::Number)
118118
LinearAlgebra.mul!(::AbstractMatrix,::AbstractMatrix,::LinearMap)
119+
LinearAlgebra.mul!(::AbstractMatrix,::AbstractMatrix,::LinearMap,::Number,::Number)
119120
LinearAlgebra.mul!(::AbstractVecOrMat,::LinearMap,::Number)
120121
LinearAlgebra.mul!(::AbstractMatrix,::LinearMap,::Number,::Number,::Number)
121122
*(::LinearAlgebra.AdjointAbsVec,::LinearMap)

src/LinearMaps.jl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ abstract type LinearMap{T} end
1717

1818
const MapOrVecOrMat{T} = Union{LinearMap{T}, AbstractVecOrMat{T}}
1919
const MapOrMatrix{T} = Union{LinearMap{T}, AbstractMatrix{T}}
20+
const TransposeAbsVecOrMat{T} = Transpose{T,<:AbstractVecOrMat}
2021
const RealOrComplex = Union{Real, Complex}
2122

2223
const LinearMapTuple = Tuple{Vararg{LinearMap}}
@@ -78,9 +79,9 @@ function check_dim_mul(C, A, B)
7879
end
7980

8081
_front(As::Tuple) = Base.front(As)
81-
_front(As::AbstractVector) = @inbounds @views As[1:end-1]
82+
_front(As::AbstractVector) = @inbounds @views As[begin:end-1]
8283
_tail(As::Tuple) = Base.tail(As)
83-
_tail(As::AbstractVector) = @inbounds @views As[2:end]
84+
_tail(As::AbstractVector) = @inbounds @views As[begin+1:end]
8485

8586
_combine(A::LinearMap, B::LinearMap) = tuple(A, B)
8687
_combine(A::LinearMap, Bs::LinearMapTuple) = tuple(A, Bs...)
@@ -258,15 +259,13 @@ end
258259

259260
_unsafe_mul!(y, A::MapOrVecOrMat, x) = mul!(y, A, x)
260261
_unsafe_mul!(y, A::AbstractVecOrMat, x, α, β) = mul!(y, A, x, α, β)
261-
_unsafe_mul!(y::AbstractVecOrMat, A::LinearMap, x::AbstractVector, α, β) =
262-
_generic_map_mul!(y, A, x, α, β)
263-
_unsafe_mul!(y::AbstractMatrix, A::LinearMap, x::AbstractMatrix) =
264-
_generic_map_mul!(y, A, x)
265-
_unsafe_mul!(y::AbstractMatrix, A::LinearMap, x::AbstractMatrix, α::Number, β::Number) =
266-
_generic_map_mul!(y, A, x, α, β)
267-
_unsafe_mul!(Y::AbstractMatrix, A::LinearMap, s::Number) = _generic_map_mul!(Y, A, s)
268-
_unsafe_mul!(Y::AbstractMatrix, A::LinearMap, s::Number, α::Number, β::Number) =
269-
_generic_map_mul!(Y, A, s, α, β)
262+
_unsafe_mul!(X, Y::AbstractMatrix, A::AbstractVecOrMat) = mul!(X, Y, A)
263+
_unsafe_mul!(X, Y::AbstractMatrix, A::AbstractVecOrMat, α, β) = mul!(X, Y, A, α, β)
264+
_unsafe_mul!(y, A::LinearMap, x::AbstractVector, α, β) = _generic_map_mul!(y, A, x, α, β)
265+
_unsafe_mul!(y, A::LinearMap, x::AbstractMatrix) = _generic_map_mul!(y, A, x)
266+
_unsafe_mul!(y, A::LinearMap, x::AbstractMatrix, α, β) = _generic_map_mul!(y, A, x, α, β)
267+
_unsafe_mul!(Y, A::LinearMap, s::Number) = _generic_map_mul!(Y, A, s)
268+
_unsafe_mul!(Y, A::LinearMap, s::Number, α, β) = _generic_map_mul!(Y, A, s, α, β)
270269

271270
function _generic_map_mul!(y, A, x::AbstractVector, α, β)
272271
# this function needs to call mul! for, e.g., AdjointMap{...,<:CustomMap}
@@ -330,9 +329,9 @@ function _generic_map_mul!(Y, A, s::Number, α, β)
330329
return Y
331330
end
332331

333-
include("left.jl") # left multiplication by a transpose or adjoint vector
334332
include("transpose.jl") # transposing linear maps
335333
include("wrappedmap.jl") # wrap a matrix of linear map in a new type, thereby allowing to alter its properties
334+
include("left.jl") # left multiplication by a transpose or adjoint vector
336335
include("uniformscalingmap.jl") # the uniform scaling map, to be able to make linear combinations of LinearMap objects and multiples of I
337336
include("linearcombination.jl") # defining linear combinations of linear maps
338337
include("scaledmap.jl") # multiply by a (real or complex) scalar

src/blockmap.jl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,13 @@ end
427427
# multiplication with vectors & matrices
428428
############
429429

430-
for (In, Out) in ((AbstractVector, AbstractVecOrMat), (AbstractMatrix, AbstractMatrix))
430+
for In in (AbstractVector, AbstractMatrix)
431431
@eval begin
432-
function _unsafe_mul!(y::$Out, A::BlockMap, x::$In)
432+
function _unsafe_mul!(y, A::BlockMap, x::$In)
433433
require_one_based_indexing(y, x)
434434
return _blockmul!(y, A, x, true, false)
435435
end
436-
function _unsafe_mul!(y::$Out, A::BlockMap, x::$In, α::Number, β::Number)
436+
function _unsafe_mul!(y, A::BlockMap, x::$In, α, β)
437437
require_one_based_indexing(y, x)
438438
return _blockmul!(y, A, x, α, β)
439439
end
@@ -442,11 +442,11 @@ for (In, Out) in ((AbstractVector, AbstractVecOrMat), (AbstractMatrix, AbstractM
442442
for (MT, transform) in ((:TransposeMap, :transpose), (:AdjointMap, :adjoint))
443443
@eval begin
444444
MapType = $MT{<:Any, <:BlockMap}
445-
function _unsafe_mul!(y::$Out, wrapA::MapType, x::$In)
445+
function _unsafe_mul!(y, wrapA::MapType, x::$In)
446446
require_one_based_indexing(y, x)
447447
return _transblockmul!(y, wrapA.lmap, x, true, false, $transform)
448448
end
449-
function _unsafe_mul!(y::$Out, wrapA::MapType, x::$In, α::Number, β::Number)
449+
function _unsafe_mul!(y, wrapA::MapType, x::$In, α, β)
450450
require_one_based_indexing(y, x)
451451
return _transblockmul!(y, wrapA.lmap, x, α, β, $transform)
452452
end
@@ -458,14 +458,13 @@ end
458458
# multiplication with a scalar
459459
############
460460

461-
function _unsafe_mul!(Y::AbstractMatrix, A::BlockMap, s::Number, α::Number=true, β::Number=false)
461+
function _unsafe_mul!(Y, A::BlockMap, s::Number, α=true, β=false)
462462
require_one_based_indexing(Y, s)
463463
return _blockmul!(Y, A, s, α, β)
464464
end
465465
for (MT, transform) in ((:TransposeMap, :transpose), (:AdjointMap, :adjoint))
466466
@eval begin
467-
function _unsafe_mul!(Y::AbstractMatrix, wrapA::$MT{<:Any, <:BlockMap}, s::Number,
468-
α::Number=true, β::Number=false)
467+
function _unsafe_mul!(Y, wrapA::$MT{<:Any, <:BlockMap}, s::Number, α=true, β=false)
469468
require_one_based_indexing(Y)
470469
return _transblockmul!(Y, wrapA.lmap, s, α, β, $transform)
471470
end
@@ -557,13 +556,13 @@ LinearAlgebra.transpose(A::BlockDiagonalMap{T}) where {T} =
557556
Base.:(==)(A::BlockDiagonalMap, B::BlockDiagonalMap) =
558557
(eltype(A) == eltype(B) && all(A.maps .== B.maps))
559558

560-
for (In, Out) in ((AbstractVector, AbstractVecOrMat), (AbstractMatrix, AbstractMatrix), (Number, AbstractMatrix))
559+
for In in (AbstractVector, AbstractMatrix, Number)
561560
@eval begin
562-
function _unsafe_mul!(y::$Out, A::BlockDiagonalMap, x::$In)
561+
function _unsafe_mul!(y, A::BlockDiagonalMap, x::$In)
563562
require_one_based_indexing(y, x)
564563
return _blockscaling!(y, A, x)
565564
end
566-
function _unsafe_mul!(y::$Out, A::BlockDiagonalMap, x::$In, α::Number, β::Number)
565+
function _unsafe_mul!(y, A::BlockDiagonalMap, x::$In, α, β)
567566
require_one_based_indexing(y, x)
568567
return _blockscaling!(y, A, x, α, β)
569568
end

src/composition.jl

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,15 @@ Base.:(==)(A::CompositeMap, B::CompositeMap) =
165165
(eltype(A) == eltype(B) && all(A.maps .== B.maps))
166166

167167
# multiplication with vectors/matrices
168-
_unsafe_mul!(y::AbstractVecOrMat, A::CompositeMap, x::AbstractVector) =
169-
_compositemul!(y, A, x)
170-
_unsafe_mul!(y::AbstractMatrix, A::CompositeMap, x::AbstractMatrix) =
171-
_compositemul!(y, A, x)
168+
_unsafe_mul!(y, A::CompositeMap, x::AbstractVector) = _compositemul!(y, A, x)
169+
_unsafe_mul!(y, A::CompositeMap, x::AbstractMatrix) = _compositemul!(y, A, x)
172170

173-
function _compositemul!(y::AbstractVecOrMat,
174-
A::CompositeMap{<:Any,<:Tuple{LinearMap}},
175-
x::AbstractVecOrMat,
171+
function _compositemul!(y, A::CompositeMap{<:Any,<:Tuple{LinearMap}}, x,
176172
source = nothing,
177173
dest = nothing)
178174
return _unsafe_mul!(y, A.maps[1], x)
179175
end
180-
function _compositemul!(y::AbstractVecOrMat,
181-
A::CompositeMap{<:Any,<:Tuple{LinearMap,LinearMap}},
182-
x::AbstractVecOrMat,
176+
function _compositemul!(y, A::CompositeMap{<:Any,<:Tuple{LinearMap,LinearMap}}, x,
183177
source = similar(y, (size(A.maps[1],1), size(x)[2:end]...)),
184178
dest = nothing)
185179
_unsafe_mul!(source, A.maps[1], x)
@@ -204,9 +198,7 @@ function _resize(dest::AbstractMatrix, sz::Tuple{<:Integer,<:Integer})
204198
similar(dest, sz)
205199
end
206200

207-
function _compositemul!(y::AbstractVecOrMat,
208-
A::CompositeMap{<:Any,<:LinearMapTuple},
209-
x::AbstractVecOrMat,
201+
function _compositemul!(y, A::CompositeMap{<:Any,<:LinearMapTuple}, x,
210202
source = similar(y, (size(A.maps[1],1), size(x)[2:end]...)),
211203
dest = similar(y, (size(A.maps[2],1), size(x)[2:end]...)))
212204
N = length(A.maps)
@@ -220,9 +212,7 @@ function _compositemul!(y::AbstractVecOrMat,
220212
return y
221213
end
222214

223-
function _compositemul!(y::AbstractVecOrMat,
224-
A::CompositeMap{<:Any,<:LinearMapVector},
225-
x::AbstractVecOrMat)
215+
function _compositemul!(y, A::CompositeMap{<:Any,<:LinearMapVector}, x)
226216
N = length(A.maps)
227217
if N == 1
228218
return _unsafe_mul!(y, A.maps[1], x)
@@ -233,17 +223,13 @@ function _compositemul!(y::AbstractVecOrMat,
233223
end
234224
end
235225

236-
function _compositemul2!(y::AbstractVecOrMat,
237-
A::CompositeMap{<:Any,<:LinearMapVector},
238-
x::AbstractVecOrMat,
226+
function _compositemul2!(y, A::CompositeMap{<:Any,<:LinearMapVector}, x,
239227
source = similar(y, (size(A.maps[1],1), size(x)[2:end]...)))
240228
_unsafe_mul!(source, A.maps[1], x)
241229
_unsafe_mul!(y, A.maps[2], source)
242230
return y
243231
end
244-
function _compositemulN!(y::AbstractVecOrMat,
245-
A::CompositeMap{<:Any,<:LinearMapVector},
246-
x::AbstractVecOrMat,
232+
function _compositemulN!(y, A::CompositeMap{<:Any,<:LinearMapVector}, x,
247233
source = similar(y, (size(A.maps[1],1), size(x)[2:end]...)),
248234
dest = similar(y, (size(A.maps[2],1), size(x)[2:end]...)))
249235
N = length(A.maps)

src/embeddedmap.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,25 @@ Base.:(==)(A::EmbeddedMap, B::EmbeddedMap) =
6969
LinearAlgebra.adjoint(A::EmbeddedMap) = EmbeddedMap(adjoint(A.lmap), reverse(A.dims), A.cols, A.rows)
7070
LinearAlgebra.transpose(A::EmbeddedMap) = EmbeddedMap(transpose(A.lmap), reverse(A.dims), A.cols, A.rows)
7171

72-
for (In, Out) in ((AbstractVector, AbstractVecOrMat), (AbstractMatrix, AbstractMatrix))
73-
@eval function _unsafe_mul!(y::$Out, A::EmbeddedMap, x::$In)
72+
for In in (AbstractVector, AbstractMatrix)
73+
@eval function _unsafe_mul!(y, A::EmbeddedMap, x::$In)
7474
fill!(y, zero(eltype(y)))
7575
_unsafe_mul!(selectdim(y, 1, A.rows), A.lmap, selectdim(x, 1, A.cols))
7676
return y
7777
end
78-
@eval function _unsafe_mul!(y::$Out, A::EmbeddedMap, x::$In, alpha::Number, beta::Number)
79-
LinearAlgebra._rmul_or_fill!(y, beta)
80-
_unsafe_mul!(selectdim(y, 1, A.rows), A.lmap, selectdim(x, 1, A.cols), alpha, !iszero(beta))
78+
@eval function _unsafe_mul!(y, A::EmbeddedMap, x::$In, α, β)
79+
LinearAlgebra._rmul_or_fill!(y, β)
80+
_unsafe_mul!(selectdim(y, 1, A.rows), A.lmap, selectdim(x, 1, A.cols), α, !iszero(β))
8181
return y
8282
end
8383
end
8484

85-
function _unsafe_mul!(Y::AbstractMatrix, A::EmbeddedMap, x::Number)
85+
function _unsafe_mul!(Y, A::EmbeddedMap, x::Number)
8686
fill!(Y, zero(eltype(Y)))
8787
_unsafe_mul!(view(Y, A.rows, A.cols), A.lmap, x)
8888
return Y
8989
end
90-
function _unsafe_mul!(Y::AbstractMatrix, A::EmbeddedMap, x::Number, α::Number, β::Number)
90+
function _unsafe_mul!(Y, A::EmbeddedMap, x::Number, α, β)
9191
LinearAlgebra._rmul_or_fill!(Y, β)
9292
_unsafe_mul!(view(Y, A.rows, A.cols), A.lmap, x, α, !iszero(β))
9393
return Y

src/fillmap.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ function Base.:(*)(A::FillMap, x::AbstractVector)
3232
return fill(iszero(A.λ) ? zero(T) : A.λ*sum(x), A.size[1])
3333
end
3434

35-
function _unsafe_mul!(y::AbstractVecOrMat, A::FillMap, x::AbstractVector)
35+
function _unsafe_mul!(y, A::FillMap, x::AbstractVector)
3636
return fill!(y, iszero(A.λ) ? zero(eltype(y)) : A.λ*sum(x))
3737
end
3838

39-
_unsafe_mul!(Y::AbstractMatrix, A::FillMap, x::Number) = fill!(Y, A.λ*x)
40-
function _unsafe_mul!(Y::AbstractMatrix, A::FillMap, x::Number, α::Number, β::Number)
39+
_unsafe_mul!(Y, A::FillMap, x::Number) = fill!(Y, A.λ*x)
40+
function _unsafe_mul!(Y, A::FillMap, x::Number, α, β)
4141
LinearAlgebra._rmul_or_fill!(Y, β)
4242
Y .+= A.λ*x*α
4343
return Y
4444
end
4545

46-
function _unsafe_mul!(y::AbstractVecOrMat, A::FillMap, x::AbstractVector, α::Number, β::Number)
46+
function _unsafe_mul!(y, A::FillMap, x::AbstractVector, α, β)
4747
if iszero(α)
4848
!isone(β) && rmul!(y, β)
4949
else

src/functionmap.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ function Base.:(*)(A::TransposeFunctionMap, x::AbstractVector)
110110
end
111111
end
112112

113-
function _unsafe_mul!(y::AbstractVecOrMat, A::FunctionMap, x::AbstractVector)
113+
function _unsafe_mul!(y, A::FunctionMap, x::AbstractVector)
114114
ismutating(A) ? A.f(y, x) : copyto!(y, A.f(x))
115115
return y
116116
end
117117

118-
function _unsafe_mul!(y::AbstractVecOrMat, At::TransposeFunctionMap, x::AbstractVector)
118+
function _unsafe_mul!(y, At::TransposeFunctionMap, x::AbstractVector)
119119
A = At.lmap
120120
(issymmetric(A) || (isreal(A) && ishermitian(A))) && return _unsafe_mul!(y, A, x)
121121
if A.fc !== nothing
@@ -136,7 +136,7 @@ function _unsafe_mul!(y::AbstractVecOrMat, At::TransposeFunctionMap, x::Abstract
136136
end
137137
end
138138

139-
function _unsafe_mul!(y::AbstractVecOrMat, Ac::AdjointFunctionMap, x::AbstractVector)
139+
function _unsafe_mul!(y, Ac::AdjointFunctionMap, x::AbstractVector)
140140
A = Ac.lmap
141141
ishermitian(A) && return _unsafe_mul!(y, A, x)
142142
if A.fc !== nothing

src/inversemap.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ LinearAlgebra.ishermitian(imap::InverseMap) = ishermitian(imap.A)
4949
LinearAlgebra.isposdef(imap::InverseMap) = isposdef(imap.A)
5050

5151
# Two separate methods to deal with method ambiguities
52-
function _unsafe_mul!(y::AbstractVector, imap::InverseMap, x::AbstractVector)
52+
function _unsafe_mul!(y, imap::InverseMap, x::AbstractVector)
5353
imap.ldiv!(y, imap.A, x)
5454
return y
5555
end
56-
function _unsafe_mul!(y::AbstractMatrix, imap::InverseMap, x::AbstractMatrix)
56+
function _unsafe_mul!(y, imap::InverseMap, x::AbstractMatrix)
5757
imap.ldiv!(y, imap.A, x)
5858
return y
5959
end

0 commit comments

Comments
 (0)