comparison 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
comparison
equal deleted inserted replaced
423:10a67ac48d6e 429:46acb2560451
257 @test B̃*v ≈ B[1,:,1]*v[1,1] + B[2,:,1]*v[2,1] + B[3,:,1]*v[3,1] + 257 @test B̃*v ≈ B[1,:,1]*v[1,1] + B[2,:,1]*v[2,1] + B[3,:,1]*v[3,1] +
258 B[1,:,2]v[1,2] + B[2,:,2]*v[2,2] + B[3,:,2]*v[3,2] atol=5e-13 258 B[1,:,2]v[1,2] + B[2,:,2]*v[2,2] + B[3,:,2]*v[3,2] atol=5e-13
259 259
260 end 260 end
261 261
262 end 262
263 @testset "LazyIdentity" begin
264 @test LazyIdentity{Float64}((4,5)) isa LazyIdentity{T,2} where T
265 @test LazyIdentity{Float64}((4,5)) isa TensorMapping{T,2,2} where T
266 A = rand(3,4)
267 Ã = LazyLinearMap(A, (1,), (2,))
268 v = rand(4)
269
270 for sz ∈ [(4,5),(3,),(5,6,4)]
271 I = LazyIdentity{Float64}(sz)
272 v = rand(sz...)
273 @test I*v == v
274 @test I'*v == v
275
276 @test range_size(I) == sz
277 @test domain_size(I) == sz
278 end
279
280 I = LazyIdentity{Float64}((4,5))
281 v = rand(4,5)
282 @inferred (I*v)[3,2]
283 @inferred range_size(I)
284 end
285
286 end