|
16 | 16 | @test sparse(jactestmeta(f, [1], [2])) == sparse([], [], true, 1, 1) |
17 | 17 |
|
18 | 18 | g(y,x) = y[:] .= x .+ 1 |
19 | | - #g(y,x) = y .= x .+ 1 -- memmove |
| 19 | + #g(y,x) = y .= x .+ 1 -- memove |
20 | 20 |
|
21 | | - @test sparse(jactestmeta(g, [1], [2])) == sparse([1], [1], true) |
| 21 | + @test sparse(jactestmeta(g, [1], [2])[1]) == sparse([1], [1], true) |
| 22 | + # test path of unsafe_copy from Input to Output |
| 23 | + @test sparsity!((y,x) -> y .= x, [1,2,3], [1,2,3]) == sparse([1,2,3], [1,2,3], true) |
| 24 | + # test path of unsafe_copy from Input to an intermediary |
| 25 | + @test sparsity!((y,x) -> y[1:2] .= x[2:3], [1,2,3], [1,2,3]) == sparse([1,2],[2,3],true, 3,3) |
| 26 | + |
| 27 | + using LinearAlgebra, SparsityDetection |
| 28 | + |
| 29 | + function testsparse!(out, x) |
| 30 | + A = Tridiagonal(x[2:end], x, x[1:end-1]) |
| 31 | + mul!(out, A, x) |
| 32 | + end |
| 33 | + x = [1:4;]; out = similar(x); |
| 34 | + @test sparsity!(testsparse!, out, x) == sparse([1,2,1,2,3,2,3,4,3,4], |
| 35 | + [1,1,2,2,2,3,3,3,4,4], true) |
| 36 | +end |
| 37 | + |
| 38 | +@testset "BLAS" begin |
| 39 | + function f(out,in) |
| 40 | + A = rand(length(in), length(in)) |
| 41 | + out .= A * in |
| 42 | + return nothing |
| 43 | + end |
| 44 | + |
| 45 | + x = [1.0:10;] |
| 46 | + out = similar(x) |
| 47 | + @test all(sparsity!(f, out, x) .== 1) |
22 | 48 | end |
0 commit comments