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

allow specifying index type for CachedExtensionHomomorphism #65

Merged
merged 2 commits into from
Nov 15, 2023

Conversation

kalmarek
Copy link
Owner

Problem:
No way to create CachedExtensionHomomorphism with specified index type. For large basis this could lead to hard to fix errors (without diving deep into the package).

Before:

julia> ehom = SymbolicWedderburn.CachedExtensionHomomorphism(G,action,words)
ERROR: "index type UInt16 is to small for basis of length 88572"
Stacktrace:
 [1] Basis
   @ ~/.julia/packages/StarAlgebras/0yFWh/src/bases.jl:9 [inlined]
 [2] ExtensionHomomorphism
   @ ~/.julia/dev/SymbolicWedderburn/src/ext_homomorphisms.jl:57 [inlined]
 [3] SymbolicWedderburn.CachedExtensionHomomorphism(::Type{Int16}, G::PermGroup{Perm{UInt16}, …}, action::OnLetters, basis::Vector{Word{Symbol}}; precompute::Bool)
   @ SymbolicWedderburn ~/.julia/dev/SymbolicWedderburn/src/ext_homomorphisms.jl:87
 [4] SymbolicWedderburn.CachedExtensionHomomorphism(::Type{Int16}, G::PermGroup{Perm{UInt16}, …}, action::OnLetters, basis::Vector{Word{Symbol}})
   @ SymbolicWedderburn ~/.julia/dev/SymbolicWedderburn/src/ext_homomorphisms.jl:80
 [5] top-level scope
   @ REPL[42]:1

After:

julia> ehom = SymbolicWedderburn.CachedExtensionHomomorphism(Int32, G,action,words);

julia> SW.induce(ehom, one(G))
()

julia> typeof(ans)
Perm{Int32}

CC: @laurentbartholdi

Copy link

codecov bot commented Nov 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e710eda) 87.50% compared to head (01f4f03) 87.69%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #65      +/-   ##
==========================================
+ Coverage   87.50%   87.69%   +0.19%     
==========================================
  Files          20       20              
  Lines        1328     1333       +5     
==========================================
+ Hits         1162     1169       +7     
+ Misses        166      164       -2     
Flag Coverage Δ
unittests 87.69% <100.00%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@laurentbartholdi
Copy link

This works now fine for "CachedExtensionHomomorphism".

However, the all-in-one "sabasis = SymbolicWedderburn.symmetry_adapted_basis(UInt32, G, action, words)" does not work -- I suspect actually the "UInt32" is interpreted as a type for the scalars in the resulting basis, not a type for the permutations.

In fact, I can't see any situation in which UInt16 is better than UInt32 for permutations. If they fit in a UInt16, then unless you're programming a Commodore 64 you'll have plenty of free memory so UInt32 would also work. On the other hand there may be cases in which the user would like UInt64, but then leave it to them.

@kalmarek
Copy link
Owner Author

@laurentbartholdi The proper solution should be that the index type is inferrable from G and action.

@kalmarek
Copy link
Owner Author

Well, that's exactly what we need to do then ;)

@laurentbartholdi it's not only about the memory, but rather lookup (=hashing speed) in the dictionary

Copy link

@laurentbartholdi laurentbartholdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are broken, but the code itself seems very good to me.

…user-definable)

* also bump the default to UInt32, as we are hitting the limits
of UInt16 already ;)
@kalmarek kalmarek force-pushed the mk/fix_chached_ext_index_type branch from e944128 to 01f4f03 Compare November 15, 2023 14:09
@kalmarek kalmarek merged commit 5ef402d into master Nov 15, 2023
20 checks passed
@kalmarek kalmarek deleted the mk/fix_chached_ext_index_type branch November 15, 2023 15:26
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.

2 participants