comparison test/testLazyTensors.jl @ 415:814865d40f48 feature/tensor_composition

Merge in default
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 16 Oct 2020 09:34:50 +0200
parents d94891b8dfca 4aa59af074ef
children ebc9b2383dae
comparison
equal deleted inserted replaced
412:d94891b8dfca 415:814865d40f48
236 # Test a standard matrix-vector product 236 # Test a standard matrix-vector product
237 # mapping vectors of size 4 to vectors of size 3. 237 # mapping vectors of size 4 to vectors of size 3.
238 A = rand(3,4) 238 A = rand(3,4)
239 Ã = LazyLinearMap(A, (1,), (2,)) 239 Ã = LazyLinearMap(A, (1,), (2,))
240 v = rand(4) 240 v = rand(4)
241 w = rand(3)
241 242
242 @test à isa LazyLinearMap{T,1,1} where T 243 @test à isa LazyLinearMap{T,1,1} where T
243 @test à isa TensorMapping{T,1,1} where T 244 @test à isa TensorMapping{T,1,1} where T
244 @test range_size(Ã) == (3,) 245 @test range_size(Ã) == (3,)
245 @test domain_size(Ã) == (4,) 246 @test domain_size(Ã) == (4,)
246 247
247 @test Ã*ones(4) ≈ A*ones(4) atol=5e-13 248 @test Ã*ones(4) ≈ A*ones(4) atol=5e-13
248 @test Ã*v ≈ A*v atol=5e-13 249 @test Ã*v ≈ A*v atol=5e-13
250 @test Ã'*w ≈ A'*w
249 251
250 A = rand(2,3,4) 252 A = rand(2,3,4)
251 @test_throws DomainError LazyLinearMap(A, (3,1), (2,)) 253 @test_throws DomainError LazyLinearMap(A, (3,1), (2,))
252 254
253 # Test more exotic mappings 255 # Test more exotic mappings