It’s my first time with Tullio, so my problem may look very basic. Here is a minimal example that provides the error "expected integers!"
:
using Tullio
m,r = 5,5
rr = div(r*(r-1),2)
A = rand(m,rr)
B = rand(m,r)
C = similar(B)
jbar = Vector{Vector{Int}}(undef,r)
jtild = Vector{Vector{Int}}(undef,r)
for j in 1:r
jbar[j] = vcat(1:j-1,j+1:r)
jtild[j] = vcat([(k-1)*r-div(k*(k+1),2)+j for k in 1:j-1],[(j-1)*r-div(j*(j-1),2)+k for k = 1:(r-j)])
end
@tullio C[i,j] = dot(A[i,jtild[j]],B[i,jbar[j]])
I then replaced the @tullio
line with @tullio C[i,j] = A[i,jtild[j][k]]*B[i,jbar[j][k]]
but I have the error UndefVarError: j not defined
.
edit:
The following code works, but I don’t understand why the previous one wouldn’t.
using Tullio
m,r = 5,5
rr = div(r*(r-1),2)
A = rand(m,rr)
B = rand(m,r)
C = similar(B)
jbar = Matrix{Int}(undef,r-1,r)
jtild = Matrix{Int}(undef,r-1,r)
for j in 1:r
jbar[:,j] = vcat(1:j-1,j+1:r)
jtild[:,j] = vcat([(k-1)*r-div(k*(k+1),2)+j for k in 1:j-1],[(j-1)*r-div(j*(j-1),2)+k for k = 1:(r-j)])
end
@tullio C[i,j] = A[i,jtild[k,j]]*B[i,jbar[k,j]]