diff test/testLazyTensors.jl @ 377:8414c2334393 feature/lazy_linear_map

Start implementing LazyLinearMap
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 30 Sep 2020 21:15:42 +0200
parents 241bd2512c20
children 418cfd945715
line wrap: on
line diff
--- a/test/testLazyTensors.jl	Wed Sep 30 21:09:35 2020 +0200
+++ b/test/testLazyTensors.jl	Wed Sep 30 21:15:42 2020 +0200
@@ -193,6 +193,9 @@
     @test_throws DimensionMismatch v1 + v2
 end
 
+end
+
+
 @testset "LazyFunctionArray" begin
     @test LazyFunctionArray(i->i^2, (3,)) == [1,4,9]
     @test LazyFunctionArray((i,j)->i*j, (3,2)) == [
@@ -212,4 +215,19 @@
 
 end
 
+@testset "LazyLinearMap" begin
+    A = rand(3,4)
+    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
+
+
+    @test LazyLinearMap(A, (1,), (2,))*ones(4) == A*ones(4)
+    @test LazyLinearMap(A, (1,), (2,))*v == A*v
 end
+
+end