Skip to content

Conversation

lkdvos
Copy link
Member

@lkdvos lkdvos commented Oct 8, 2025

It seems to have finally happened, someone has a use for ZNIrrep{N>64}.
Not calling any names, (uhum, @AFeuerpfeil, uhum).

I took the time to refactor to unsigned integers, and additionally to properly do modular arithmetic when overflow can occur, this might be overkill but now we can do ZNIrrep{256} with 8 bits.

I have no clue whether or not this counts as breaking though?

Copy link

codecov bot commented Oct 8, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/irreps/znirrep.jl 87.50% 5 Missing ⚠️
Files with missing lines Coverage Δ
src/TensorKitSectors.jl 16.66% <ø> (ø)
src/irreps/znirrep.jl 85.71% <87.50%> (-14.29%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Jutho
Copy link
Member

Jutho commented Oct 9, 2025

Have you checked the show methods after this change? I think I opted for signed integers because the unsigned integers are printed in hexadecimal representation, which is not very nice. For me it is also fine to just change from Int8 to Int(64). I don't think this will be the major cost in a typical tensor network algorithm.

@AFeuerpfeil
Copy link

AFeuerpfeil commented Oct 9, 2025

In case printing is the only issue, would it be possible to use a reinterpret(signed(T),x::T) in the print function or would that break some code like the HalfInt of the SU(2) symmetry?

@Jutho
Copy link
Member

Jutho commented Oct 9, 2025

That will fail if you are really using N close to typemax(T).

Technically, it might be correct for exactly N = typemax(T) +1, since you would get just negatively printed charges, i.e. the charges would be printed as being in the range $$[-N/2, +N/2)$$. But I don't think that is really the behaviour that we want. Also, that only works for exactly N==typemax(T) + 1. If N is somewhere in between typemax(signed(T)) and typemax(T) the negative numbers would be wrong.

@lkdvos
Copy link
Member Author

lkdvos commented Oct 9, 2025

I'll fix the printing, note that I already included an accessor function charge that simply returns the Int version, the hope would be to hide the storage as an implementation detail and otherwise just make it give you Int. I like the idea that the fusiontrees and caches are a bit smaller, and clog the cache lines slightly less, even though I fully agree this will never matter

@lkdvos lkdvos merged commit 23380cd into main Oct 9, 2025
5 of 8 checks passed
@lkdvos lkdvos deleted the ld-largeN branch October 9, 2025 13:53
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

Successfully merging this pull request may close these issues.

3 participants