comparison test/LazyTensors/lazy_tensor_operations_test.jl @ 938:4a9a96d51940 bugfix/tensor_application_1d_cartesian_index

Fix dispatch issue when indexing a 1D TensorApplication with a CartiesianIndex
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 09 Mar 2022 11:19:17 +0100
parents de2df1214394
children 86889fc5b63f
comparison
equal deleted inserted replaced
921:de1625deb27e 938:4a9a96d51940
45 @test (m*m*v)[6] == (:apply,m*v,(6,)) 45 @test (m*m*v)[6] == (:apply,m*v,(6,))
46 @test_broken BoundsError == (m*m*v)[0] 46 @test_broken BoundsError == (m*m*v)[0]
47 @test_broken BoundsError == (m*m*v)[7] 47 @test_broken BoundsError == (m*m*v)[7]
48 @test_throws MethodError m*m 48 @test_throws MethodError m*m
49 49
50 @test (m*v)[CartesianIndex(2)] == (:apply,v,(2,))
51 @test (m*m*v)[CartesianIndex(2)] == (:apply,m*v,(2,))
52
50 m = SizeDoublingMapping{Int, 2, 1}((3,)) 53 m = SizeDoublingMapping{Int, 2, 1}((3,))
51 @test_throws MethodError m*ones(Int,2,2) 54 @test_throws MethodError m*ones(Int,2,2)
52 @test_throws MethodError m*m*v 55 @test_throws MethodError m*m*v
53 56
54 m = SizeDoublingMapping{Float64, 2, 2}((3,3)) 57 m = SizeDoublingMapping{Float64, 2, 2}((3,3))
55 v = ones(3,3) 58 v = ones(3,3)
56 @test size(m*v) == 2 .*size(v) 59 @test size(m*v) == 2 .*size(v)
57 @test (m*v)[1,2] == (:apply,v,(1,2)) 60 @test (m*v)[1,2] == (:apply,v,(1,2))
61
62 @test (m*v)[CartesianIndex(2,3)] == (:apply,v,(2,3))
63 @test (m*m*v)[CartesianIndex(4,3)] == (:apply,m*v,(4,3))
58 64
59 struct ScalingOperator{T,D} <: TensorMapping{T,D,D} 65 struct ScalingOperator{T,D} <: TensorMapping{T,D,D}
60 λ::T 66 λ::T
61 size::NTuple{D,Int} 67 size::NTuple{D,Int}
62 end 68 end