You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a specific problem, I need to use nested @cast. But due to the check of coexistence of indices, I cannot accomplish this. Here is a simplified case:
using TensorCast
table=rand(2,2,2,2);
@cast testm1[i,j]:=table[i,j,1,1];
testm2 =sum(testm1,dims=1)
# 1×2 Matrix{Float64}:# 1.15043 0.772946@cast test[k,l]:=sum(@cast _[i,j]:=table[i,j,k,l],dims=1)
# ERROR: LoadError: index k appears only on the right# inner @cast _[i, j] := (table[i, j, k, l], dims) = 1
My purpose is simple, for given indices k and l, sum the result matrix with indices i,j over i, then with different k,l, we have a new matrix. The first example may clearly express my idea. However, @cast always checks index existence on both side, I can't do this. Maybe it is better to achieve this with cloing index check.
The text was updated successfully, but these errors were encountered:
Thanks. You are definitely right. Actually, I use this code just as an example. Since TensorCast also includes summation over indices, we can solve the second problem easily by @reduce. My original question also calls package Trapz to perform numerical integration over the first dimension. Just I want to simplify the process I substitute to sum to express my idea in brief.
In a specific problem, I need to use nested
@cast
. But due to the check of coexistence of indices, I cannot accomplish this. Here is a simplified case:My purpose is simple, for given indices k and l, sum the result matrix with indices i,j over i, then with different k,l, we have a new matrix. The first example may clearly express my idea. However,
@cast
always checks index existence on both side, I can't do this. Maybe it is better to achieve this with cloing index check.The text was updated successfully, but these errors were encountered: