Mercurial > repos > public > sbplib_julia
diff test/testLazyTensors.jl @ 524:41c1760a7770 feature/inflated_tensormapping_transpose
Merge refactor/inflated_tensormapping_tests
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 25 Nov 2020 15:10:46 +0100 |
parents | fe86ac896377 390901860b0a |
children | be152486d136 |
line wrap: on
line diff
--- a/test/testLazyTensors.jl Mon Nov 23 21:30:11 2020 +0100 +++ b/test/testLazyTensors.jl Wed Nov 25 15:10:46 2020 +0100 @@ -364,23 +364,51 @@ end @testset "Application" begin - # Test InflatedTensorMapping mapping w. before and after - 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 + tests = [ + ( + InflatedTensorMapping(I(3,2), A, I(4)), + (v-> @tullio res[a,b,c,d] := Ã[c,i]*v[a,b,i,d]), + ), + ( + InflatedTensorMapping(I(3,2), B, I(4)), + (v-> @tullio res[a,b,c,d,e] := B̃[c,d,i]*v[a,b,i,e]), + ), + ( + InflatedTensorMapping(I(3,2), C, I(4)), + (v-> @tullio res[a,b,c,d] := C̃[c,i,j]*v[a,b,i,j,d]), + ), + ( + InflatedTensorMapping(I(3,2), A), + (v-> @tullio res[a,b,c] := Ã[c,i]*v[a,b,i]), + ), + ( + InflatedTensorMapping(I(3,2), B), + (v-> @tullio res[a,b,c,d] := B̃[c,d,i]*v[a,b,i]), + ), + ( + InflatedTensorMapping(I(3,2), C), + (v-> @tullio res[a,b,c] := C̃[c,i,j]*v[a,b,i,j]), + ), + ( + InflatedTensorMapping(A,I(4)), + (v-> @tullio res[a,b] := Ã[a,i]*v[i,b]), + ), + ( + InflatedTensorMapping(B,I(4)), + (v-> @tullio res[a,b,c] := B̃[a,b,i]*v[i,c]), + ), + ( + InflatedTensorMapping(C,I(4)), + (v-> @tullio res[a,b] := C̃[a,i,j]*v[i,j,b]), + ), + ] - # Test InflatedTensorMapping mapping w. before - tm = InflatedTensorMapping(I(3,2), A) - v = rand(domain_size(tm)...) - @tullio IAIv[a,b,c] := Ã[c,i]*v[a,b,i] - @test tm*v ≈ IAIv rtol=1e-14 - - # Test InflatedTensorMapping mapping w. after - tm = InflatedTensorMapping(A,I(4)) - v = rand(domain_size(tm)...) - @tullio IAIv[c,d] := Ã[c,i]*v[i,d] - @test tm*v ≈ IAIv rtol=1e-14 + for i ∈ 1:length(tests) + tm = tests[i][1] + v = rand(domain_size(tm)...) + true_value = tests[i][2](v) + @test tm*v ≈ true_value rtol=1e-14 + end @testset "Inference of application" begin struct ScalingOperator{T,D} <: TensorMapping{T,D,D}