1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-26 02:20:30 +01:00

Merge pull request #13 from kalmarek/fix/iterate

fix iteration over Automorphisms
This commit is contained in:
Marek Kaluba 2020-11-10 17:12:36 +01:00 committed by GitHub
commit bb811cb76e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -1,7 +1,7 @@
change_pow(s::S, n::Integer) where S<:GSymbol = S(s.id, n) change_pow(s::S, n::Integer) where S<:GSymbol = S(s.id, n)
function Base.iterate(s::GS, i=1) where GS<:GSymbol function Base.iterate(s::GS, i=1) where GS<:GSymbol
return i <= abs(s.pow) ? (GS(s.id, sign(s.pow)), i+1) : nothing return i <= abs(s.pow) ? (change_pow(s, sign(s.pow)), i+1) : nothing
end end
Base.size(s::GSymbol) = (abs(s.pow), ) Base.size(s::GSymbol) = (abs(s.pow), )
Base.length(s::GSymbol) = first(size(s)) Base.length(s::GSymbol) = first(size(s))

View File

@ -142,12 +142,17 @@
@test (Groups.change_pow(f, -2)).pow == 1 @test (Groups.change_pow(f, -2)).pow == 1
@test (inv(f)).pow == 1 @test (inv(f)).pow == 1
f = Groups.AutSymbol(perm"(1,2)(3,4)") g = Groups.AutSymbol(perm"(1,2)(3,4)")
@test isa(inv(f), Groups.AutSymbol) @test isa(inv(g), Groups.AutSymbol)
@test_throws MethodError f*f @test_throws MethodError g*f
@test A(f)^-1 == A(inv(f)) @test A(g)^-1 == A(inv(g))
h = Groups.transvection_R(1,2)
@test collect(A(g)*A(h)) == [g, h]
@test collect(A(h)^2) == [h, h]
end end
@testset "reductions/arithmetic" begin @testset "reductions/arithmetic" begin