From a56518c23dbf2f96c8c8302ab83c454a90351532 Mon Sep 17 00:00:00 2001 From: Tommy Hofmann Date: Fri, 1 Nov 2024 16:30:13 +0100 Subject: [PATCH] feat: subgroup enumeration with no subgroups --- docs/src/index.md | 2 +- src/GrpAb/SubgroupEnum.jl | 15 +++++++-------- test/GrpAb/SubgroupEnum.jl | 11 +++++++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/docs/src/index.md b/docs/src/index.md index e20f63b3a5..e3c86c3b2d 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -46,7 +46,7 @@ If your research depends on computations done with Hecke, please consider giving - Claus Fieker, William Hart, Tommy Hofmann and Fredrik Johansson, [Nemo/Hecke: Computer Algebra and Number Theory Packages 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. -```bib +``` @inproceedings{nemo, author = {Fieker, Claus and Hart, William and Hofmann, Tommy and Johansson, Fredrik}, title = {Nemo/Hecke: Computer Algebra and Number Theory Packages for the Julia Programming Language}, diff --git a/src/GrpAb/SubgroupEnum.jl b/src/GrpAb/SubgroupEnum.jl index a3d93c100d..d3d8726449 100644 --- a/src/GrpAb/SubgroupEnum.jl +++ b/src/GrpAb/SubgroupEnum.jl @@ -875,6 +875,13 @@ end # Same as above but now allow a function to be applied to the output function _subgroups(G::FinGenAbGroup; subtype = [-1], quotype = [-1], order = -1, index = -1, fun = sub) + if !is_divisible_by(Hecke.order(G), order) || # the -1 default is ok + !is_divisible_by(Hecke.order(G), index) || + (subtype != [-1] && !has_quotient(G, subtype)) || + (quotype != [-1] && !has_quotient(G, quotype)) + return () + end + return ( fun(G, convert(Vector{FinGenAbGroupElem}, z)) for z in _subgroups_gens(G, subtype, quotype, order, index)) end @@ -919,14 +926,6 @@ function subgroups(G::FinGenAbGroup; subtype = :all, options = Int16[ subtype != :all, quotype != :all, order != -1, index != -1] - if mod(Hecke.order(G), index) != 0 - error("Index must divide the group order") - end - - if mod(Hecke.order(G), order) != 0 - error("Index must divide the group order") - end - if sum(options) > 1 error("Currently only one non-default parameter is supported.") end diff --git a/test/GrpAb/SubgroupEnum.jl b/test/GrpAb/SubgroupEnum.jl index 7fbee0d149..034b06f74c 100644 --- a/test/GrpAb/SubgroupEnum.jl +++ b/test/GrpAb/SubgroupEnum.jl @@ -220,4 +220,15 @@ @test all([order(t[1]) == 7*3 for t in T]) end end + + # test for no subgroups + + G = abelian_group([9, 3, 3]) + @test length(collect(subgroups(G; index = 2))) == 0 + @test length(collect(subgroups(G; order = 10001323))) == 0 + @test length(collect(subgroups(G; subtype = [6, 6, 6]))) == 0 + @test length(collect(subgroups(G; quotype = [6, 6, 6]))) == 0 + + G = abelian_group([2]) + @test length(collect(subgroups(G; quotype = [3]))) == 0 end