Mercurial > repos > public > sbplib_julia
diff test/testLazyTensors.jl @ 392:418cfd945715 feature/lazy_linear_map
Fix bug in range_size and domain_size for LazyLinearMap and expand the test
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 02 Oct 2020 13:43:36 +0200 |
parents | 8414c2334393 |
children | b14eacf823b6 |
line wrap: on
line diff
--- a/test/testLazyTensors.jl Wed Sep 30 21:15:42 2020 +0200 +++ b/test/testLazyTensors.jl Fri Oct 02 13:43:36 2020 +0200 @@ -193,8 +193,6 @@ @test_throws DimensionMismatch v1 + v2 end -end - @testset "LazyFunctionArray" begin @test LazyFunctionArray(i->i^2, (3,)) == [1,4,9] @@ -217,17 +215,24 @@ @testset "LazyLinearMap" begin A = rand(3,4) - B = rand(3,4,2) + B = rand(3,4,2) v = rand(4) - @test LazyLinearMap(A, (1,), (2,)) isa LazyLinearMap{T,1,1} where T - @test LazyLinearMap(A, (1,), (2,)) isa TensorMapping{T,1,1} where T - @test LazyLinearMap(B, (1,2), (3,)) isa TensorMapping{T,2,1} where T - @test LazyLinearMap(B, (2), (3,1)) isa TensorMapping{T,1,2} where T + à = LazyLinearMap(A, (1,), (2,)) + @test à isa LazyLinearMap{T,1,1} where T + @test à isa TensorMapping{T,1,1} where T + + @test Ã*ones(4) ≈ A*ones(4) atol=5e-13 + @test Ã*v ≈ A*v atol=5e-13 + B̃_21 = LazyLinearMap(B, (1,2), (3,)) + B̃_12 = LazyLinearMap(B, (2,), (3,1)) + @test B̃_21 isa TensorMapping{T,2,1} where T + @test B̃_12 isa TensorMapping{T,1,2} where T + @test B̃_21*ones(2) ≈ B[:,:,1] + B[:,:,2] atol=5e-13 + @test B̃_12*ones(3,2) ≈ B[1,:,1] + B[2,:,1] + B[3,:,1] + + B[1,:,2] + B[2,:,2] + B[3,:,2] atol=5e-13 - @test LazyLinearMap(A, (1,), (2,))*ones(4) == A*ones(4) - @test LazyLinearMap(A, (1,), (2,))*v == A*v end end