Skip to content

Commit

Permalink
provide fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarrasch committed Jun 24, 2024
1 parent 456eabf commit 365c2e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/LinearMaps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ _combine(As::LinearMapVector, Bs::LinearMapTuple) = Base.vect(As..., Bs...)
_combine(As::LinearMapTuple, Bs::LinearMapVector) = Base.vect(As..., Bs...)
_combine(As::LinearMapVector, Bs::LinearMapVector) = Base.vect(As..., Bs...)

_reverse!(As::LinearMapTuple) = reverse(As)
_reverse!(As::LinearMapVector) = reverse!(As)

# The (internal) multiplication logic is as follows:
# - `*(A, x)` calls `mul!(y, A, x)` for appropriately-sized y
# - `mul!` checks consistency of the sizes, and calls `_unsafe_mul!`,
Expand Down
10 changes: 5 additions & 5 deletions src/composition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ end
CompositeMap{T}(maps::As) where {T, As<:LinearMapTupleOrVector} = CompositeMap{T, As}(maps)

Base.mapreduce(::typeof(identity), ::typeof(Base.mul_prod), maps::LinearMapTupleOrVector) =
CompositeMap{promote_type(map(eltype, maps)...)}(reverse(maps))
CompositeMap{promote_type(map(eltype, maps)...)}(_reverse!(maps))
Base.mapreduce(::typeof(identity), ::typeof(Base.mul_prod), maps::AbstractVector{<:LinearMap{T}}) where {T} =
CompositeMap{T}(reverse(maps))
CompositeMap{T}(reverse!(maps))

MulStyle(A::CompositeMap) = MulStyle(A.maps...) === TwoArg() ? TwoArg() : ThreeArg()

Expand Down Expand Up @@ -158,9 +158,9 @@ Base.:(*)(A₁::CompositeMap, A₂::ScaledMap) = (A₁ * A₂.lmap) * A₂.λ

# special transposition behavior
LinearAlgebra.transpose(A::CompositeMap{T}) where {T} =
CompositeMap{T}(map(transpose, reverse(A.maps)))
CompositeMap{T}(map(transpose, _reverse!(A.maps)))
LinearAlgebra.adjoint(A::CompositeMap{T}) where {T} =
CompositeMap{T}(map(adjoint, reverse(A.maps)))
CompositeMap{T}(map(adjoint, _reverse!(A.maps)))

# comparison of CompositeMap objects
Base.:(==)(A::CompositeMap, B::CompositeMap) =
Expand All @@ -169,7 +169,7 @@ Base.:(==)(A::CompositeMap, B::CompositeMap) =
# multiplication with vectors/matrices
function Base.:(*)(A::CompositeMap, x::AbstractVector)
MulStyle(A) === TwoArg() ?
foldr(*, reverse(A.maps), init=x) :
foldr(*, _reverse!(A.maps), init=x) :
invoke(*, Tuple{LinearMap, AbstractVector}, A, x)
end

Expand Down
2 changes: 1 addition & 1 deletion src/kronecker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ function _unsafe_mul!(y,
Bs1, Bs2 = _front(Bs), _tail(Bs)
apply = all(_iscompatible, zip(As1, As2)) && all(_iscompatible, zip(Bs1, Bs2))
if apply
_unsafe_mul!(y, kron(prod(As), prod(Bs)), x)
_unsafe_mul!(y, kron(prod(_reverse!(As)), prod(_reverse!(Bs))), x)
else
_unsafe_mul!(y, CompositeMap{T}(map(LinearMap, L.maps)), x)
end
Expand Down

0 comments on commit 365c2e3

Please sign in to comment.