comparison 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
comparison
equal deleted inserted replaced
438:907b0510699f 444:b685eadc349a
279 @test B̃*v ≈ B[1,:,1]*v[1,1] + B[2,:,1]*v[2,1] + B[3,:,1]*v[3,1] + 279 @test B̃*v ≈ B[1,:,1]*v[1,1] + B[2,:,1]*v[2,1] + B[3,:,1]*v[3,1] +
280 B[1,:,2]v[1,2] + B[2,:,2]*v[2,2] + B[3,:,2]*v[3,2] atol=5e-13 280 B[1,:,2]v[1,2] + B[2,:,2]*v[2,2] + B[3,:,2]*v[3,2] atol=5e-13
281 281
282 end 282 end
283 283
284 end 284
285 @testset "IdentityMapping" begin
286 @test IdentityMapping{Float64}((4,5)) isa IdentityMapping{T,2} where T
287 @test IdentityMapping{Float64}((4,5)) isa TensorMapping{T,2,2} where T
288 @test IdentityMapping{Float64}((4,5)) == IdentityMapping{Float64}(4,5)
289
290 @test IdentityMapping(3,2) isa IdentityMapping{Float64,2}
291
292 for sz ∈ [(4,5),(3,),(5,6,4)]
293 I = IdentityMapping{Float64}(sz)
294 v = rand(sz...)
295 @test I*v == v
296 @test I'*v == v
297
298 @test range_size(I) == sz
299 @test domain_size(I) == sz
300 end
301
302 I = IdentityMapping{Float64}((4,5))
303 v = rand(4,5)
304 @inferred (I*v)[3,2]
305 @inferred (I'*v)[3,2]
306 @inferred range_size(I)
307 end
308
309 end