Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to extract block by specifying sector of each index for (N,0) or (0,N) tensors #182

Closed
Yue-Zhengyuan opened this issue Dec 4, 2024 · 5 comments

Comments

@Yue-Zhengyuan
Copy link

For a TensorMap with N1 > 0 codomain indices and N2 > 0 domain indices, I can extract its blocks by specifying the sector of each index:

using TensorKit
V = U1Space(0 => 2, 1 => 2, -1 => 2)
a = TensorMap(randn, Float64, V, V)
I = sectortype(a)
a[(I(1), I(-1))]

Output:

2×2 StridedViews.StridedView{Float64, 2, Vector{Float64}, typeof(identity)}:
 -1.29546  -0.115814
  1.63631  -0.808197

However, if I permute all indices to codomain (or domain), this no longer works:

a2 = permute(a, ((1,2), ()))
a2[(I(1), I(-1))]

I get the error:

MethodError: no method matching FusionTree(::Tuple{}, ::U1Irrep, ::Tuple{})
The type `FusionTree` exists, but no method is defined for this combination of argument types when trying to construct it.
@Jutho
Copy link
Owner

Jutho commented Dec 6, 2024

Thanks for catching this. I can reproduce and will fix this asap.

@Jutho Jutho mentioned this issue Dec 8, 2024
@Jutho
Copy link
Owner

Jutho commented Dec 8, 2024

This is fixed on master, we will tag a new patch release asap.

@Jutho Jutho closed this as completed Dec 8, 2024
@Yue-Zhengyuan
Copy link
Author

Thanks for the fix! I'd appreciate it if the fix can also be backported to version 0.12? PEPSKit and MPSKit haven't been updated to work with version 0.13.

I need this fix mainly to convert blocks of a TensorMap to a list of ordinary arrays readable by other people's non-Julia programs. Usually people don't distinguish between domain and codomain indices, so I decided to permute all of them to the codomain (as a Tensor), which is also how I found the bug in the first place.

@lkdvos
Copy link
Collaborator

lkdvos commented Dec 9, 2024

One possible way to get around this would be to do something like:

for (f1, f2) in fusiontrees(a2)
    if f1.uncoupled == (I(-1), I(1))
         @show a2[f1, f2]
    end
end

The trick is that this bypasses that step of constructing the fusiontrees by starting from them, and checking if the uncoupled charges are the ones you are looking for.
Would that be sufficient for your current use-case?

@Yue-Zhengyuan
Copy link
Author

@lkdvos This seems to work for both 0.12 and 0.13. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants