diff test/testLazyTensors.jl @ 436:cffdac9c612d bugfix/tensor_application_multiplication

Close branch before merge
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 19 Oct 2020 20:54:23 +0200
parents 3796e296fe64 6737e769a1ca
children 00c317c9ccfb
line wrap: on
line diff
--- a/test/testLazyTensors.jl	Sun Oct 18 22:12:30 2020 +0200
+++ b/test/testLazyTensors.jl	Mon Oct 19 20:54:23 2020 +0200
@@ -214,6 +214,27 @@
 
 end
 
+@testset "TensorMappingComposition" begin
+    A = rand(2,3)
+    B = rand(3,4)
+
+    Ã = LazyLinearMap(A, (1,), (2,))
+    B̃ = LazyLinearMap(B, (1,), (2,))
+
+    @test Ã∘B̃ isa TensorMappingComposition
+    @test range_size(Ã∘B̃) == (2,)
+    @test domain_size(Ã∘B̃) == (4,)
+    @test_throws DimensionMismatch B̃∘Ã
+
+    # @test @inbounds B̃∘Ã # Should not error even though dimensions don't match. (Since ]test runs with forced boundschecking this is currently not testable 2020-10-16)
+
+    v = rand(4)
+    @test Ã∘B̃*v ≈ A*B*v rtol=1e-14
+
+    v = rand(2)
+    @test (Ã∘B̃)'*v ≈ B'*A'*v rtol=1e-14
+end
+
 @testset "LazyLinearMap" begin
     # Test a standard matrix-vector product
     # mapping vectors of size 4 to vectors of size 3.