changeset 451:6cf234eef780 feature/inflated_tensormapping

Add tests for constructors and size calculations
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 19 Oct 2020 22:03:59 +0200
parents ac6d22570a08
children aeda2698166d
files src/LazyTensors/lazy_tensor_operations.jl test/testLazyTensors.jl
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/LazyTensors/lazy_tensor_operations.jl	Mon Oct 19 21:42:57 2020 +0200
+++ b/src/LazyTensors/lazy_tensor_operations.jl	Mon Oct 19 22:03:59 2020 +0200
@@ -188,6 +188,7 @@
         return new{T,R,D,D_before,R_middle,D_middle,D_after, typeof(tm)}(before, tm, after)
     end
 end
+export InflatedTensorMapping
 
 # TODO: Implement constructors where one of `before` or `after` is missing
 
--- a/test/testLazyTensors.jl	Mon Oct 19 21:42:57 2020 +0200
+++ b/test/testLazyTensors.jl	Mon Oct 19 22:03:59 2020 +0200
@@ -307,6 +307,27 @@
 end
 
 @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))
+
+    @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}
+    @test InflatedTensorMapping(I(3), C, I(2,3)) isa TensorMapping{Float64, 4, 5}
+
+    @test range_size(InflatedTensorMapping(I(3,2), A, I(4))) == (3,2,4,4)
+    @test domain_size(InflatedTensorMapping(I(3,2), A, I(4))) == (3,2,2,4)
+
+    @test range_size(InflatedTensorMapping(I(3,2), B, I(4))) == (3,2,4,2,4)
+    @test domain_size(InflatedTensorMapping(I(3,2), B, I(4))) == (3,2,3,4)
+
+    @test range_size(InflatedTensorMapping(I(3), C, I(2,3))) == (3,4,2,3)
+    @test domain_size(InflatedTensorMapping(I(3), C, I(2,3))) == (3,2,3,2,3)
+
+    @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)
+
 
 end