When supplied range conflicts with un-shifted index...
Hey,
the following one:
julia> using Tullio
julia> y = ^C
julia> y = (1:10) .* (1:10)'
10×10 Matrix{Int64}:
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
julia> f(x) = (@tullio res[i, j] := x[i, j+1] (i in 1:5, j in 1:5))
f (generic function with 1 method)
julia> f(y)
ERROR: "range of index i must agree"
Stacktrace:
[1] ℳ𝒶𝓀ℯ
@ ~/.julia/packages/Tullio/bgqFi/src/macro.jl:968 [inlined]
[2] (::Tullio.Eval{var"#ℳ𝒶𝓀ℯ#180"{var"#𝒜𝒸𝓉!#177"}, var"#735#∇ℳ𝒶𝓀ℯ#179"{var"#∇𝒜𝒸𝓉!#178"}})(args::Matrix{Int64})
@ Tullio ~/.julia/packages/Tullio/bgqFi/src/eval.jl:20
[3] f(x::Matrix{Int64})
@ Main ./REPL[119]:1
[4] top-level scope
@ REPL[120]:1
julia> f(x) = (@tullio res[i, j] := x[i+0, j+1] (i in 1:5, j in 1:5))
f (generic function with 1 method)
julia> f(y)
5×5 Matrix{Int64}:
2 3 4 5 6
4 6 8 10 12
6 9 12 15 18
8 12 16 20 24
10 15 20 25 30
What is the reason that we need the artificial +0? My goal was to calculate only a subset of the initial x
Thanks,
Felix
Every index is in one of two modes: The strict one demands that all match, and the other takes the intersection. The second is applied to any index with a shift.
I'm not sure that's the perfect solution. It means you get an error if you do matrix multiplication and get the sizes wrong, I think it would be pretty surprising to silently take the smallest size there. But when you write x[i+1] - x[i] the obvious behaviour is all values legal for both terms. It could also be a global effect, not per-index.
I also wondered whether explicit ranges should have higher priority, but right now they don't. I guess this is the opposite direction to your complaint, I feel it's a little odd that this disobeys an explicit command:
julia> @tullio a[i] := (1:3)[i+1] i in 1:5
2-element Vector{Int64}:
2
3