Skip to content

Commit 7d52dcb

Browse files
authored
feat: subgroup enumeration with no subgroups (#1670)
1 parent ab9b6d2 commit 7d52dcb

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ If your research depends on computations done with Hecke, please consider giving
4646
- Claus Fieker, William Hart, Tommy Hofmann and Fredrik Johansson, [Nemo/Hecke: Computer Algebra and Number Theory Packages
4747
for the Julia Programming Language](https://doi.acm.org/10.1145/3087604.3087611). In: Proceedings of ISSAC '17, pages 157–164, New York, NY, USA, 2017. ACM.
4848

49-
```bib
49+
```
5050
@inproceedings{nemo,
5151
author = {Fieker, Claus and Hart, William and Hofmann, Tommy and Johansson, Fredrik},
5252
title = {Nemo/Hecke: Computer Algebra and Number Theory Packages for the Julia Programming Language},

src/GrpAb/SubgroupEnum.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,13 @@ end
875875
# Same as above but now allow a function to be applied to the output
876876
function _subgroups(G::FinGenAbGroup; subtype = [-1], quotype = [-1], order = -1,
877877
index = -1, fun = sub)
878+
if !is_divisible_by(Hecke.order(G), order) || # the -1 default is ok
879+
!is_divisible_by(Hecke.order(G), index) ||
880+
(subtype != [-1] && !has_quotient(G, subtype)) ||
881+
(quotype != [-1] && !has_quotient(G, quotype))
882+
return ()
883+
end
884+
878885
return ( fun(G, convert(Vector{FinGenAbGroupElem}, z)) for z in _subgroups_gens(G, subtype, quotype, order, index))
879886
end
880887

@@ -919,14 +926,6 @@ function subgroups(G::FinGenAbGroup; subtype = :all,
919926

920927
options = Int16[ subtype != :all, quotype != :all, order != -1, index != -1]
921928

922-
if mod(Hecke.order(G), index) != 0
923-
error("Index must divide the group order")
924-
end
925-
926-
if mod(Hecke.order(G), order) != 0
927-
error("Index must divide the group order")
928-
end
929-
930929
if sum(options) > 1
931930
error("Currently only one non-default parameter is supported.")
932931
end

test/GrpAb/SubgroupEnum.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,15 @@
220220
@test all([order(t[1]) == 7*3 for t in T])
221221
end
222222
end
223+
224+
# test for no subgroups
225+
226+
G = abelian_group([9, 3, 3])
227+
@test length(collect(subgroups(G; index = 2))) == 0
228+
@test length(collect(subgroups(G; order = 10001323))) == 0
229+
@test length(collect(subgroups(G; subtype = [6, 6, 6]))) == 0
230+
@test length(collect(subgroups(G; quotype = [6, 6, 6]))) == 0
231+
232+
G = abelian_group([2])
233+
@test length(collect(subgroups(G; quotype = [3]))) == 0
223234
end

0 commit comments

Comments
 (0)