Jutho / TensorKit.jl

A Julia package for large-scale tensor computations, with a hint of category theory
MIT License
234 stars 41 forks source link

Rewrite the deduction of braidingtensor spaces #94

Closed lkdvos closed 10 months ago

lkdvos commented 11 months ago

Previously, this constructed an indexmap, but this is ambiguous if an index appears on multiple braidingtensors. This should now be fixed by contructing braidingtensors independently. Also adds a test for the case that was not caught. Fixes #93

codecov[bot] commented 11 months ago

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (518e520) 80.25% compared to head (f9c7108) 81.19%.

Files Patch % Lines
src/planar/preprocessors.jl 92.30% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #94 +/- ## ========================================== + Coverage 80.25% 81.19% +0.93% ========================================== Files 42 42 Lines 5288 5265 -23 ========================================== + Hits 4244 4275 +31 + Misses 1044 990 -54 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Gertian commented 11 months ago

MPSKit.jl doesn't compile against this.

I think the reason is that contractions such as :

@planar contractcheck = true opt=true d[f;g] := T[f;a]*B[c;d]*τ[d b;c e]*τ[e b;a g] 

result in ERROR: AssertionError: could not figure out all spaces

maartenvd commented 11 months ago

Can you explain this bit?

Previously, this constructed an indexmap, but this is ambiguous if an index appears on multiple braidingtensors.

The indexmap is always ambiguous, even when having a single braidingtensor between two regular tensors. You can find out the space by calling space(t,...) on either on the tensors, but that is not a real problem. I don't follow why chaining multiple braidingtensors together would make the indexmap more ambiguous.

lkdvos commented 11 months ago

The problem is mostly that you need to know if the connection will be made between the codomain of the braidingtensor and the domain of the regular tensor, or the other way around, in order to determine if the space needs to be dual or not. However, keeping a single indexmap for multiple braidingtensors can lead to mismatches in that regards.

if you imagine an expression tau[a b; c d] * tau[b d; e f], you would construct two braidingtensors with space V in the codomain, which leads to a space mismatch when connecting them. (V \= V')

In other words, you cannot create a global indexmap, but should really create one per braidingtensor. The way I get around this is by just going through, creating as many braidingtensors as possible, and then really instantiating them into the expression as if they were tensors, and repeating this until all indices have been resolved

lkdvos commented 10 months ago

Closed in favor of #95