diff test/testLazyTensors.jl @ 429:46acb2560451 feature/lazy_identity

Start implementing LazyIdentity
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 18 Oct 2020 22:30:17 +0200
parents 4aa59af074ef
children 1d6250fcf14c
line wrap: on
line diff
--- a/test/testLazyTensors.jl	Sun Oct 18 22:21:43 2020 +0200
+++ b/test/testLazyTensors.jl	Sun Oct 18 22:30:17 2020 +0200
@@ -259,4 +259,28 @@
 
 end
 
+
+@testset "LazyIdentity" begin
+    @test LazyIdentity{Float64}((4,5)) isa LazyIdentity{T,2} where T
+    @test LazyIdentity{Float64}((4,5)) isa TensorMapping{T,2,2} where T
+    A = rand(3,4)
+    Ã = LazyLinearMap(A, (1,), (2,))
+    v = rand(4)
+
+    for sz ∈ [(4,5),(3,),(5,6,4)]
+        I = LazyIdentity{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 = LazyIdentity{Float64}((4,5))
+    v = rand(4,5)
+    @inferred (I*v)[3,2]
+    @inferred range_size(I)
 end
+
+end