mcabbott / mcabbott/TensorCast.jl
Hope to close the both side indices check
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 142
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the nested @cast expansion in the reported example and locate the coexistence-of-indices check that raises the error. Compare the desired reduction with the first working example; done should allow the nested form to evaluate for varying k,l while preserving the intended sum over i and the resulting matrix shape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100