Skip to content

Commit 204ccb7

Browse files
authored
A few Kronecker fixes (#133)
1 parent 9a366ad commit 204ccb7

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "LinearMaps"
22
uuid = "7a12625a-238d-50fd-b39a-03d52299707e"
3-
version = "3.1.0"
3+
version = "3.2.0"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

docs/src/history.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Version history
22

3+
## What's new in v3.2
4+
5+
* In-place left-multiplication `mul!(Y, X, A::LinearMap)` is now allowed for
6+
`X::AbstractMatrix` and implemented via the adjoint equation `Y' = A'X'`.
7+
38
## What's new in v3.1
49

510
* In Julia v1.3 and above, `LinearMap`-typed objects are callable on `AbstractVector`s:

src/kronecker.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ Base.kron(A::KroneckerMap, B::LinearMap) =
5252
KroneckerMap{promote_type(eltype(A), eltype(B))}(tuple(A.maps..., B))
5353
Base.kron(A::KroneckerMap, B::KroneckerMap) =
5454
KroneckerMap{promote_type(eltype(A), eltype(B))}(tuple(A.maps..., B.maps...))
55+
# hoist out scalings
5556
Base.kron(A::ScaledMap, B::LinearMap) = A.λ * kron(A.lmap, B)
56-
Base.kron(A::LinearMap{<:RealOrComplex}, B::ScaledMap) = B.λ * kron(A, B.lmap)
57+
Base.kron(A::LinearMap, B::ScaledMap) = kron(A, B.lmap) * B.λ
5758
Base.kron(A::ScaledMap, B::ScaledMap) = (A.λ * B.λ) * kron(A.lmap, B.lmap)
59+
# disambiguation
60+
Base.kron(A::ScaledMap, B::KroneckerMap) = A.λ * kron(A.lmap, B)
61+
Base.kron(A::KroneckerMap, B::ScaledMap) = kron(A, B.lmap) * B.λ
62+
# generic definitions
5863
Base.kron(A::LinearMap, B::LinearMap, C::LinearMap, Ds::LinearMap...) =
5964
kron(kron(A, B), C, Ds...)
6065
Base.kron(A::AbstractMatrix, B::LinearMap) = kron(LinearMap(A), B)

test/kronecker.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ using Test, LinearMaps, LinearAlgebra, SparseArrays
1212
@test kron(3LA, LB) isa LinearMaps.ScaledMap
1313
@test kron(3LA, 2LB) isa LinearMaps.ScaledMap
1414
@test kron(3LA, 2LB).λ == 6
15+
@test kron(kron(LA, LA), 2LB) isa LinearMaps.ScaledMap
16+
@test kron(3LA, kron(LB, LB)) isa LinearMaps.ScaledMap
1517
@test_throws ErrorException LinearMaps.KroneckerMap{Float64}((LA, LB))
1618
@test occursin("6×6 LinearMaps.KroneckerMap{$(eltype(LK))}", sprint((t, s) -> show(t, "text/plain", s), LK))
1719
@test @inferred size(LK) == size(K)

test/wrappedmap.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ using Test, LinearMaps, LinearAlgebra
66
SA = A'A + I
77
SB = B'B + I
88
L = @inferred LinearMap{Float64}(A)
9+
@test summary(L) == "10×20 LinearMaps.WrappedMap{Float64}"
910
@test occursin("10×20 LinearMaps.WrappedMap{Float64}", sprint((t, s) -> show(t, "text/plain", s), L))
1011
MA = @inferred LinearMap(SA)
1112
MB = @inferred LinearMap(SB)

0 commit comments

Comments
 (0)