Mercurial > repos > public > sbplib_julia
comparison test/testLazyTensors.jl @ 412:d94891b8dfca feature/tensor_composition
Start implementing TensorComposition
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 15 Oct 2020 22:05:22 +0200 |
parents | 3b4b1758a8ad |
children | 814865d40f48 |
comparison
equal
deleted
inserted
replaced
410:26e186b565b3 | 412:d94891b8dfca |
---|---|
211 @test_throws BoundsError LazyFunctionArray((i,j)->i*j, (3,2))[4,2] | 211 @test_throws BoundsError LazyFunctionArray((i,j)->i*j, (3,2))[4,2] |
212 @test_throws BoundsError LazyFunctionArray((i,j)->i*j, (3,2))[2,3] | 212 @test_throws BoundsError LazyFunctionArray((i,j)->i*j, (3,2))[2,3] |
213 | 213 |
214 end | 214 end |
215 | 215 |
216 @testset "TensorMappingComposition" begin | |
217 A = rand(2,3) | |
218 B = rand(3,4) | |
219 | |
220 Ã = LazyLinearMap(A, (1,), (2,)) | |
221 B̃ = LazyLinearMap(B, (1,), (2,)) | |
222 | |
223 @test Ã∘B̃ isa TensorMappingComposition | |
224 @test range_size(Ã∘B̃) == (2,) | |
225 @test domain_size(Ã∘B̃) == (4,) | |
226 # @test_throws DimensionMismatch B̃∘Ã | |
227 | |
228 v = rand(4) | |
229 @test Ã∘B̃*v ≈ A*B*v | |
230 | |
231 v = rand(2) | |
232 @test_broken (Ã∘B̃)'*v ≈ B'*A'*v | |
233 end | |
234 | |
216 @testset "LazyLinearMap" begin | 235 @testset "LazyLinearMap" begin |
217 # Test a standard matrix-vector product | 236 # Test a standard matrix-vector product |
218 # mapping vectors of size 4 to vectors of size 3. | 237 # mapping vectors of size 4 to vectors of size 3. |
219 A = rand(3,4) | 238 A = rand(3,4) |
220 Ã = LazyLinearMap(A, (1,), (2,)) | 239 Ã = LazyLinearMap(A, (1,), (2,)) |