Mercurial > repos > public > sbplib_julia
diff test/testLazyTensors.jl @ 452:aeda2698166d feature/inflated_tensormapping
Add tullio as a test dependency and add a test for apply
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 19 Oct 2020 22:34:58 +0200 |
parents | 6cf234eef780 |
children | c1ae837f1a2e |
line wrap: on
line diff
--- a/test/testLazyTensors.jl Mon Oct 19 22:03:59 2020 +0200 +++ b/test/testLazyTensors.jl Mon Oct 19 22:34:58 2020 +0200 @@ -2,6 +2,8 @@ using Sbplib.LazyTensors using Sbplib.RegionIndices +using Tullio + @testset "LazyTensors" begin @testset "Generic Mapping methods" begin @@ -308,9 +310,14 @@ @testset "InflatedTensorMapping" begin I(sz...) = IdentityMapping(sz...) - A = LazyLinearMap(rand(4,2),(1,),(2,)) - B = LazyLinearMap(rand(4,2,3),(1,2),(3,)) - C = LazyLinearMap(rand(4,2,3),(1,),(2,3)) + + Ã = rand(4,2) + B̃ = rand(4,2,3) + C̃ = rand(4,2,3) + + A = LazyLinearMap(Ã,(1,),(2,)) + B = LazyLinearMap(B̃,(1,2),(3,)) + C = LazyLinearMap(C̃,(1,),(2,3)) @test InflatedTensorMapping(I(3,2), A, I(4)) isa TensorMapping{Float64, 4, 4} @test InflatedTensorMapping(I(3,2), B, I(4)) isa TensorMapping{Float64, 5, 4} @@ -328,6 +335,11 @@ @inferred range_size(InflatedTensorMapping(I(3,2), A, I(4))) == (3,2,4,4) @inferred domain_size(InflatedTensorMapping(I(3,2), A, I(4))) == (3,2,2,4) + tm = InflatedTensorMapping(I(3,2), A, I(4)) + v = rand(domain_size(tm)...) + + @tullio IAIv[a,b,c,d] := Ã[c,i]*v[a,b,i,d] + @test tm*v ≈ IAIv rtol=1e-14 end