1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-05 02:11:27 +01:00

update elements, order

This commit is contained in:
kalmar 2017-07-21 13:31:42 +02:00
parent 83f9ed61b8
commit 16f3b6b44e

View File

@ -208,15 +208,15 @@ end
doc""" doc"""
elements(G::DirectProductGroup) elements(G::DirectProductGroup)
> Returns `Task` that produces all elements of group `G` (provided that factors > Returns `generator` that produces all elements of group `G` (provided that
> implement the elements function). > `G.group` implements the `elements` method).
""" """
# TODO: can Base.product handle generators? # TODO: can Base.product handle generators?
# now it returns nothing's so we have to collect ellements... # now it returns nothing's so we have to collect ellements...
function elements(G::DirectProductGroup) function elements(G::DirectProductGroup)
cartesian_prod = Base.product([collect(elements(H)) for H in G.factors]...) elts = collect(elements(G.group))
return (G(collect(elt)) for elt in cartesian_prod) cartesian_prod = Base.product([elts for _ in 1:G.n]...)
return (DirectProductGroupElem([elt...]) for elt in cartesian_prod)
end end
doc""" doc"""
@ -224,4 +224,4 @@ doc"""
> Returns the order (number of elements) in the group. > Returns the order (number of elements) in the group.
""" """
order(G::DirectProductGroup) = prod([order(H) for H in G.factors]) order(G::DirectProductGroup) = order(G.group)^G.n