Skip to content

Adjust to the fact that similar(v) does not allocate #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion test/blockmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ 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)
alloc = sizeof(v) + 64
if L == L2 && α != false
@test_broken (@allocated mul!(v, transL, u, α, β)) <= alloc
else
Expand Down
2 changes: 1 addition & 1 deletion test/functionmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ 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)
alloc = sizeof(v) + 64
@test (@allocated mul!(v, transCS!, u, α, β)) <= alloc
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/linearcombination.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using LinearMaps: FiveArg, LinearMapTuple, LinearMapVector, FunctionMap
mul!(u, CS!, v)
@test (@allocated mul!(u, CS!, v)) == 0
n = 10
alloc = @allocated similar(v)
alloc = sizeof(v) + 64
Loop = @inferred CS + CS + CS
@test Loop * v ≈ 3cumsum(v)
@test (CS + CR + CS) * v ≈ 3cumsum(v)
Expand Down Expand Up @@ -60,7 +60,7 @@ 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 = sizeof(u) + 64
mul!(u, L, v, 2, 2)
@test (@allocated mul!(u, L, v, 2, 2)) <= alloc
mul!(u, Lv, v, 2, 2)
Expand Down
2 changes: 1 addition & 1 deletion test/scaledmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ using Test, LinearMaps, LinearAlgebra
for (A, alloc) in ((A0, 1), (A1, 0), (B0, 1), (B1, 0), (A0', 3), (A1', 0), (B0', 3), (B1', 0))
x = rand(N)
y = similar(x)
allocsize = @allocated similar(y)
allocsize = sizeof(y)+72
mul!(y, A, x)
@test (@allocated mul!(y, A, x)) == alloc*allocsize
end
Expand Down
Loading