comparison test/testLazyTensors.jl @ 434:648a36ebac99 feature/lazy_identity

Change name from LazyIdentity to IdentityMapping
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 19 Oct 2020 09:51:56 +0200
parents 7327a3e41df0
children 1db5ec38955e
comparison
equal deleted inserted replaced
433:7327a3e41df0 434:648a36ebac99
279 B[1,:,2]v[1,2] + B[2,:,2]*v[2,2] + B[3,:,2]*v[3,2] atol=5e-13 279 B[1,:,2]v[1,2] + B[2,:,2]*v[2,2] + B[3,:,2]*v[3,2] atol=5e-13
280 280
281 end 281 end
282 282
283 283
284 @testset "LazyIdentity" begin 284 @testset "IdentityMapping" begin
285 @test LazyIdentity{Float64}((4,5)) isa LazyIdentity{T,2} where T 285 @test IdentityMapping{Float64}((4,5)) isa IdentityMapping{T,2} where T
286 @test LazyIdentity{Float64}((4,5)) isa TensorMapping{T,2,2} where T 286 @test IdentityMapping{Float64}((4,5)) isa TensorMapping{T,2,2} where T
287 287
288 for sz ∈ [(4,5),(3,),(5,6,4)] 288 for sz ∈ [(4,5),(3,),(5,6,4)]
289 I = LazyIdentity{Float64}(sz) 289 I = IdentityMapping{Float64}(sz)
290 v = rand(sz...) 290 v = rand(sz...)
291 @test I*v == v 291 @test I*v == v
292 @test I'*v == v 292 @test I'*v == v
293 293
294 @test range_size(I) == sz 294 @test range_size(I) == sz
295 @test domain_size(I) == sz 295 @test domain_size(I) == sz
296 end 296 end
297 297
298 I = LazyIdentity{Float64}((4,5)) 298 I = IdentityMapping{Float64}((4,5))
299 v = rand(4,5) 299 v = rand(4,5)
300 @inferred (I*v)[3,2] 300 @inferred (I*v)[3,2]
301 @test_broken @inferred (I'*v)[3,2] # TODO: Should fix the index typing before investigating this 301 @test_broken @inferred (I'*v)[3,2] # TODO: Should fix the index typing before investigating this
302 @inferred range_size(I) 302 @inferred range_size(I)
303 end 303 end