|
138 | 138 | @test ldiv!(op, u) ≈ (α * D) \ v |
139 | 139 | end |
140 | 140 |
|
| 141 | +function apply_op!(H, du, u, p, t) |
| 142 | + H(du, u, p, t) |
| 143 | + return nothing |
| 144 | +end |
| 145 | + |
141 | 146 | @testset "AddedOperator" begin |
142 | 147 | A = rand(N, N) |> MatrixOperator |
143 | 148 | B = rand(N, N) |> MatrixOperator |
|
187 | 192 |
|
188 | 193 | # Allocations Tests |
189 | 194 |
|
190 | | - allocs_tot = @allocations mul!(v, op, u) # warmup |
191 | | - allocs_tot = @allocations mul!(v, op, u) |
192 | | - @test allocs_tot == 1 # BenchmarkTools.jl returns 0 instead of 1 |
193 | | - allocs_tot = @allocations mul!(v, op, u, α, β) # warmup |
194 | | - allocs_tot = @allocations mul!(v, op, u, α, β) |
195 | | - @test allocs_tot == 1 # BenchmarkTools.jl returns 0 instead of 1 |
| 195 | + allocs_tot = @allocations apply_op!(op, v, u, (), 1.0) # warmup |
| 196 | + allocs_tot = @allocations apply_op!(op, v, u, (), 1.0) |
| 197 | + @test allocs_tot <= 1 # BenchmarkTools.jl returns 0 instead of 1 |
196 | 198 |
|
197 | 199 | ## Time-Dependent Coefficients |
198 | 200 |
|
@@ -222,12 +224,12 @@ end |
222 | 224 | p = (ω = 0.1,) |
223 | 225 | t = 0.1 |
224 | 226 |
|
225 | | - allocs_sparse = @allocations H_sparse(du, u, p, t) # warmup |
226 | | - allocs_sparse = @allocations H_sparse(du, u, p, t) |
227 | | - allocs_dense = @allocations H_dense(du, u, p, t) # warmup |
228 | | - allocs_dense = @allocations H_dense(du, u, p, t) |
229 | | - @test allocs_sparse == 1 # BenchmarkTools.jl returns 0 instead of 1 |
230 | | - @test allocs_dense == 1 # BenchmarkTools.jl returns 0 instead of 1 |
| 227 | + allocs_sparse = @allocations apply_op!(H_sparse, du, u, p, t) # warmup |
| 228 | + allocs_sparse = @allocations apply_op!(H_sparse, du, u, p, t) |
| 229 | + allocs_dense = @allocations apply_op!(H_dense, du, u, p, t) # warmup |
| 230 | + allocs_dense = @allocations apply_op!(H_dense, du, u, p, t) |
| 231 | + @test allocs_sparse <= 1 # BenchmarkTools.jl returns 0 instead of 1 |
| 232 | + @test allocs_dense <= 1 # BenchmarkTools.jl returns 0 instead of 1 |
231 | 233 | end |
232 | 234 | end |
233 | 235 |
|
|
0 commit comments