Mercurial > repos > public > sbplib_julia
comparison test/testLazyTensors.jl @ 452:aeda2698166d feature/inflated_tensormapping
Add tullio as a test dependency and add a test for apply
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 19 Oct 2020 22:34:58 +0200 |
parents | 6cf234eef780 |
children | c1ae837f1a2e |
comparison
equal
deleted
inserted
replaced
451:6cf234eef780 | 452:aeda2698166d |
---|---|
1 using Test | 1 using Test |
2 using Sbplib.LazyTensors | 2 using Sbplib.LazyTensors |
3 using Sbplib.RegionIndices | 3 using Sbplib.RegionIndices |
4 | |
5 using Tullio | |
4 | 6 |
5 @testset "LazyTensors" begin | 7 @testset "LazyTensors" begin |
6 | 8 |
7 @testset "Generic Mapping methods" begin | 9 @testset "Generic Mapping methods" begin |
8 struct DummyMapping{T,R,D} <: TensorMapping{T,R,D} end | 10 struct DummyMapping{T,R,D} <: TensorMapping{T,R,D} end |
306 @inferred range_size(I) | 308 @inferred range_size(I) |
307 end | 309 end |
308 | 310 |
309 @testset "InflatedTensorMapping" begin | 311 @testset "InflatedTensorMapping" begin |
310 I(sz...) = IdentityMapping(sz...) | 312 I(sz...) = IdentityMapping(sz...) |
311 A = LazyLinearMap(rand(4,2),(1,),(2,)) | 313 |
312 B = LazyLinearMap(rand(4,2,3),(1,2),(3,)) | 314 Ã = rand(4,2) |
313 C = LazyLinearMap(rand(4,2,3),(1,),(2,3)) | 315 B̃ = rand(4,2,3) |
316 C̃ = rand(4,2,3) | |
317 | |
318 A = LazyLinearMap(Ã,(1,),(2,)) | |
319 B = LazyLinearMap(B̃,(1,2),(3,)) | |
320 C = LazyLinearMap(C̃,(1,),(2,3)) | |
314 | 321 |
315 @test InflatedTensorMapping(I(3,2), A, I(4)) isa TensorMapping{Float64, 4, 4} | 322 @test InflatedTensorMapping(I(3,2), A, I(4)) isa TensorMapping{Float64, 4, 4} |
316 @test InflatedTensorMapping(I(3,2), B, I(4)) isa TensorMapping{Float64, 5, 4} | 323 @test InflatedTensorMapping(I(3,2), B, I(4)) isa TensorMapping{Float64, 5, 4} |
317 @test InflatedTensorMapping(I(3), C, I(2,3)) isa TensorMapping{Float64, 4, 5} | 324 @test InflatedTensorMapping(I(3), C, I(2,3)) isa TensorMapping{Float64, 4, 5} |
318 | 325 |
326 @test domain_size(InflatedTensorMapping(I(3), C, I(2,3))) == (3,2,3,2,3) | 333 @test domain_size(InflatedTensorMapping(I(3), C, I(2,3))) == (3,2,3,2,3) |
327 | 334 |
328 @inferred range_size(InflatedTensorMapping(I(3,2), A, I(4))) == (3,2,4,4) | 335 @inferred range_size(InflatedTensorMapping(I(3,2), A, I(4))) == (3,2,4,4) |
329 @inferred domain_size(InflatedTensorMapping(I(3,2), A, I(4))) == (3,2,2,4) | 336 @inferred domain_size(InflatedTensorMapping(I(3,2), A, I(4))) == (3,2,2,4) |
330 | 337 |
331 | 338 tm = InflatedTensorMapping(I(3,2), A, I(4)) |
332 end | 339 v = rand(domain_size(tm)...) |
333 | 340 |
334 end | 341 @tullio IAIv[a,b,c,d] := Ã[c,i]*v[a,b,i,d] |
342 @test tm*v ≈ IAIv rtol=1e-14 | |
343 | |
344 end | |
345 | |
346 end |