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

add map_entries for matrix groups #3341

Merged
merged 2 commits into from
Feb 16, 2024

Conversation

ThomasBreuer
Copy link
Member

No description provided.

Copy link

codecov bot commented Feb 9, 2024

Codecov Report

Merging #3341 (9a08bbc) into master (e809e93) will decrease coverage by 0.02%.
Report is 7 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3341      +/-   ##
==========================================
- Coverage   82.09%   82.07%   -0.02%     
==========================================
  Files         556      556              
  Lines       74070    74226     +156     
==========================================
+ Hits        60805    60922     +117     
- Misses      13265    13304      +39     
Files Coverage Δ
src/Groups/matrices/MatGrp.jl 95.23% <100.00%> (+0.09%) ⬆️

... and 3 files with indirect coverage changes

3
```
"""
function map_entries(R::Ring, G::MatrixGroup)
Copy link
Member

Choose a reason for hiding this comment

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

There is also change_base_ring for this case, which does the same. Maybe one should call the other?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think one could just have one method of the form

map_entries(f, G::MatrixGroup)

without specifying the type of the first argument. This is how all other map_* methods usually are implemented.

Copy link
Member

Choose a reason for hiding this comment

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

@joschmitt change_base_ring seems to only cover the case where the first argument is a ring, right? Of course we can make sure one is implemented in terms of the other. The current method is

function change_base_ring(R::Ring, G::MatrixGroup)
  g = dense_matrix_type(R)[]
  for h in gens(G)
    push!(g, map_entries(R, h.elm))
  end
  return matrix_group(g)
end

which does not deal with empty generator lists. We could just change it to

change_base_ring(R::Ring, G::MatrixGroup) = map_entries(R, G)

@thofma those other map_entries methods don't need to deal with an empty list of matrices, though... But yeah one could merge the methods though one could consider the two simple methods as "optimizations" of the generic Function one? Is there any harm in having these additional methods?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, you are right. Maybe my suggestion is just to remove the restriction on the first argument and shuffle the docstring, so that it is not at the "wrong" method (at the moment the signature of the docstring and the function are not the same).

Copy link
Member

Choose a reason for hiding this comment

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

We could just change it to

change_base_ring(R::Ring, G::MatrixGroup) = map_entries(R, G)

Yes, exactly.

function map_entries(f::Function, G::MatrixGroup)
Ggens = gens(G)
if length(Ggens) == 0
o = map_entries(f, matrix(one(G)))
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it suffice to map a single entry, like

Suggested change
o = map_entries(f, matrix(one(G)))
o = f(zero(base_ring(G)))

return matrix_group(codomain(mp), degree(G), imgs)
end

function map_entries(f::Function, G::MatrixGroup)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just drop the ::Function to make it more generic "for free" ? (There are other "callable" objects which are not functions, after all)

Suggested change
function map_entries(f::Function, G::MatrixGroup)
function map_entries(f, G::MatrixGroup)

Ggens = gens(G)
if length(Ggens) == 0
o = map_entries(f, matrix(one(G)))
return matrix_group(base_ring(o), degree(G), typeof(o)[])
Copy link
Member

Choose a reason for hiding this comment

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

After discussing this: I overlooked the use of typeof(o) here. But we can avoid it:

Suggested change
return matrix_group(base_ring(o), degree(G), typeof(o)[])
return matrix_group(base_ring(o), degree(G), MatrixGroupElem[])

@fingolfin
Copy link
Member

@ThomasBreuer it shouldn't be much work to finish this up, I hope? or are there blockers / decisions to be made?

It would be nice to have this merged so I can use it.

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

Thanks!

@fingolfin
Copy link
Member

Huh, doctest failures in src/Rings/groebner.jl:1022-1042 but I don't understand how this PR could cause them?

@joschmitt
Copy link
Member

Huh, doctest failures in src/Rings/groebner.jl:1022-1042 but I don't understand how this PR could cause them?

See #3377 .

@benlorenz benlorenz closed this Feb 16, 2024
@benlorenz benlorenz reopened this Feb 16, 2024
@fingolfin fingolfin enabled auto-merge (squash) February 16, 2024 13:06
@fingolfin fingolfin merged commit eb7bbdf into oscar-system:master Feb 16, 2024
36 of 44 checks passed
@lgoettgens
Copy link
Member

This should get backported, right?

@ThomasBreuer ThomasBreuer deleted the TB_map_entries branch February 20, 2024 15:28
@lgoettgens
Copy link
Member

This should get backported, right?

Bump @fingolfin @ThomasBreuer

@fingolfin fingolfin added the backport 1.0.x Should be backported to the release 1.0 branch label Feb 20, 2024
benlorenz pushed a commit that referenced this pull request Feb 21, 2024
@benlorenz benlorenz mentioned this pull request Feb 21, 2024
33 tasks
@benlorenz benlorenz removed the backport 1.0.x Should be backported to the release 1.0 branch label Feb 21, 2024
benlorenz added a commit that referenced this pull request Feb 23, 2024
### Backported PRs

- [x] #3367
- [x] #3379 
- [x] #3369
- [x] #3291
- [x] #3325
- [x] #3350 
- [x] #3351
- [x] #3365 
- [x] #3366
- [x] #3382
- [x] #3373
- [x] #3341
- [x] #3346
- [x] #3381
- [x] #3385
- [x] #3387 
- [x] #3398 
- [x] #3399 
- [x] #3374 
- [x] #3406 
- [x] #2823
- [x] #3298
- [x] #3386 
- [x] #3412 
- [x] #3392 
- [x] #3415 
- [x] #3394
- [x] #3391
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.

6 participants