diff test/testLazyTensors.jl @ 444:b685eadc349a

Merge in feature/lazy_identity. Adds type IdentityMapping
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 20 Oct 2020 09:07:15 +0200
parents e70e47fbfa7c
children ac6d22570a08
line wrap: on
line diff
--- a/test/testLazyTensors.jl	Mon Oct 19 21:09:11 2020 +0200
+++ b/test/testLazyTensors.jl	Tue Oct 20 09:07:15 2020 +0200
@@ -281,4 +281,29 @@
 
 end
 
+
+@testset "IdentityMapping" begin
+    @test IdentityMapping{Float64}((4,5)) isa IdentityMapping{T,2} where T
+    @test IdentityMapping{Float64}((4,5)) isa TensorMapping{T,2,2} where T
+    @test IdentityMapping{Float64}((4,5)) == IdentityMapping{Float64}(4,5)
+
+    @test IdentityMapping(3,2) isa IdentityMapping{Float64,2}
+
+    for sz ∈ [(4,5),(3,),(5,6,4)]
+        I = IdentityMapping{Float64}(sz)
+        v = rand(sz...)
+        @test I*v == v
+        @test I'*v == v
+
+        @test range_size(I) == sz
+        @test domain_size(I) == sz
+    end
+
+    I = IdentityMapping{Float64}((4,5))
+    v = rand(4,5)
+    @inferred (I*v)[3,2]
+    @inferred (I'*v)[3,2]
+    @inferred range_size(I)
 end
+
+end