Skip to content

Commit df9ccd3

Browse files
authored
Define MulStyle(::ScaledMap) in terms of wrapped map (#179)
1 parent aa54eb3 commit df9ccd3

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
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.6.1"
3+
version = "3.6.2"
44

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

src/scaledmap.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ LinearAlgebra.issymmetric(A::ScaledMap) = issymmetric(A.lmap)
2424
LinearAlgebra.ishermitian(A::ScaledMap) = isreal(A.λ) && ishermitian(A.lmap)
2525
LinearAlgebra.isposdef(A::ScaledMap) = isposdef(A.λ) && isposdef(A.lmap)
2626

27+
MulStyle(A::ScaledMap) = MulStyle(A.lmap)
28+
2729
Base.transpose(A::ScaledMap) = A.λ * transpose(A.lmap)
2830
Base.adjoint(A::ScaledMap) = conj(A.λ) * adjoint(A.lmap)
2931

test/scaledmap.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ using Test, LinearMaps, LinearAlgebra
1717
@test @inferred ishermitian(B) == ishermitian(A)
1818
@test @inferred isposdef(B) == isposdef(A)
1919
@test @inferred transpose(B) == α * transpose(A)
20+
A! = LinearMap((y, x) -> cumsum!(y, x), N)
21+
L = 0.5A! + 0.5A! + 1.0A!
22+
@test LinearMaps.MulStyle(L) === LinearMaps.ThreeArg()
23+
L*x; y = similar(x)
24+
@test mul!(y, L, x) 2cumsum(x)
25+
LM = 0.5LinearMap(AM) + 0.5LinearMap(AM) + 1.0LinearMap(AM)
26+
@test LM*x 2cumsum(x)
27+
@test LinearMaps.MulStyle(LM) === LinearMaps.FiveArg()
28+
@test iszero(@allocated mul!(y, LM, x))
2029

2130
@test B == A * α
2231
@test B * x == α * (A * x)

test/uniformscalingmap.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ using Test, LinearMaps, LinearAlgebra
2121
@test @inferred isposdef(Id)
2222
@test Id * v == v
2323
@test (2 * M' + 3 * I) * v == 2 * A'v + 3v
24-
@test (3 * I + 2 * M') * v == 2 * A'v + 3v
24+
@test (3 * I + 2 * M') * v 3v + 2 * A'v rtol=2eps()
2525
@test (2 * M' - 3 * I) * v == 2 * A'v - 3v
26-
@test (3 * I - 2 * M') * v == -2 * A'v + 3v
27-
@test (3 * I - 2 * M') * v == -2 * A'v + 3v
26+
@test (3 * I - 2 * M') * v 3v - 2 * A'v rtol=2eps()
2827
@test transpose(LinearMap(2 * M' + 3 * I)) * v transpose(2 * A' + 3 * I) * v
2928
@test LinearMap(2 * M' + 0I)' * v (2 * A')' * v
3029
for λ in (0, 1, rand()), α in (0, 1, rand()), β in (0, 1, rand()), sz in (m, (m,5))

0 commit comments

Comments
 (0)