Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions test/blockmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,9 @@ using LinearMaps: FiveArg
@test mul!(copy(v), LinearMap(transform(L)), u, α, β) ≈ transform(M)*u*α + v*β
if transform != adjoint
transL = transform(L)
alloc = @allocated similar(v)
if L == L2 && α != false
@test_broken (@allocated mul!(v, transL, u, α, β)) <= alloc
else
@test (@allocated mul!(v, transL, u, α, β)) <= alloc
end
similar(v)
alloc = @allocations similar(v)
@test (@allocations mul!(v, transL, u, α, β)) <= alloc broken=(L == L2 && α != false)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/functionmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ using Test, LinearMaps, LinearAlgebra
@test mul!(copy(v), LinearMap(transform(CS!)), u, α, β) ≈ transform(M)*u*α + v*β
if transform != transpose
transCS! = transform(CS!)
alloc = @allocated similar(v)
@test (@allocated mul!(v, transCS!, u, α, β)) <= alloc
alloc = @allocations similar(v)
@test (@allocations mul!(v, transCS!, u, α, β)) <= alloc + 1
end
end
end
Expand Down
18 changes: 9 additions & 9 deletions test/linearcombination.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ using LinearMaps: FiveArg, LinearMapTuple, LinearMapVector, FunctionMap
mul!(u, CS!, v)
@test (@allocated mul!(u, CS!, v)) == 0
n = 10
alloc = @allocated similar(v)
alloc = (@allocations similar(v)) + 1
Loop = @inferred CS + CS + CS
@test Loop * v ≈ 3cumsum(v)
@test (CS + CR + CS) * v ≈ 3cumsum(v)
@test (@allocated Loop * v) <= 3alloc
@test (@allocations Loop * v) <= 3alloc
Loop = @inferred CS + CS; Loop * v
@test (@allocated Loop * v) <= 2alloc
@test (@allocations Loop * v) <= 2alloc
Lmix = @inferred CS + CS + CS!; Lmix * v
@test (@allocated Lmix * v) <= 3alloc
@test (@allocations Lmix * v) <= 3alloc
Lmix = @inferred CS + CS + CS!; Lmix * v
@test (@allocated Lmix * v) <= 3alloc
@test (@allocations Lmix * v) <= 3alloc
Lmix = @inferred CS! + (CS + CS); Lmix * v
@test (@allocated Lmix * v) <= 3alloc
@test (@allocations Lmix * v) <= 3alloc
L = @inferred sum(ntuple(_ -> CS!, n))
@test (@inferred sum(L.maps::LinearMapTuple)) == L
Lv = @inferred LinearMaps.LinearCombination{ComplexF64}(fill(CS!, n))
Expand Down Expand Up @@ -60,11 +60,11 @@ using LinearMaps: FiveArg, LinearMapTuple, LinearMapVector, FunctionMap
@test occursin("10×10 $LinearMaps.LinearCombination{$(eltype(L))}", sprint((t, s) -> show(t, "text/plain", s), L+CS!))
@test mul!(u, L, v) ≈ n * cumsum(v)
@test mul!(u, Lv, v) ≈ n * cumsum(v)
alloc = @allocated similar(u)
alloc = (@allocations similar(u)) + 1
mul!(u, L, v, 2, 2)
@test (@allocated mul!(u, L, v, 2, 2)) <= alloc
@test (@allocations mul!(u, L, v, 2, 2)) <= alloc
mul!(u, Lv, v, 2, 2)
@test (@allocated mul!(u, Lv, v, 2, 2)) <= alloc
@test (@allocations mul!(u, Lv, v, 2, 2)) <= alloc
for α in (false, true, rand(ComplexF64)), β in (false, true, rand(ComplexF64))
for transform in (identity, adjoint, transpose)
@test mul!(copy(u), transform(L), v, α, β) ≈ transform(M)*v*α + u*β
Expand Down
5 changes: 2 additions & 3 deletions test/scaledmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ using Test, LinearMaps, LinearAlgebra
λ = 4.2
B0 = @inferred λ * A0
B1 = @inferred λ * A1
for (A, alloc) in ((A0, 1), (A1, 0), (B0, 1), (B1, 0), (A0', 3), (A1', 0), (B0', 3), (B1', 0))
for (A, alloc) in ((A0, 3), (A1, 0), (B0, 3), (B1, 0), (A0', 9), (A1', 0), (B0', 9), (B1', 0))
x = rand(N)
y = similar(x)
allocsize = @allocated similar(y)
mul!(y, A, x)
@test (@allocated mul!(y, A, x)) == alloc*allocsize
@test (@allocations mul!(y, A, x)) <= alloc
end
end
Loading