Iterator protocol for elements of Nemo.FinField
This commit is contained in:
parent
6d07adabf3
commit
762f069cbd
@ -11,20 +11,47 @@ import Nemo.elements
|
|||||||
|
|
||||||
using JLD
|
using JLD
|
||||||
|
|
||||||
function elements(F::Nemo.FqNmodFiniteField)
|
include("Projections.jl")
|
||||||
deg = Int(degree(F))
|
|
||||||
char = Int(characteristic(F))
|
|
||||||
z = (gen(F)^i for i in 0:deg-1)
|
|
||||||
crtsn_prd = Base.product([0:char-1 for i in 1:deg]...)
|
|
||||||
|
|
||||||
function _it()
|
###############################################################################
|
||||||
for crt in crtsn_prd
|
#
|
||||||
g = sum([b*a for (a,b) in zip(z,crt)])
|
# Iterator protocol for Nemo.FinField
|
||||||
produce(g)
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
type FFEltsIter{T<:Nemo.FinField}
|
||||||
|
all::Int
|
||||||
|
field::T
|
||||||
|
|
||||||
|
function FFEltsIter(F::T)
|
||||||
|
return new(Int(characteristic(F)^degree(F)), F)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return Task(_it)
|
FFEltsIter{T<:Nemo.FinField}(F::T) = FFEltsIter{T}(F)
|
||||||
|
|
||||||
|
import Base: start, next, done, eltype, length
|
||||||
|
|
||||||
|
Base.start(A::FFEltsIter) = (zero(A.field), 0)
|
||||||
|
Base.next(A::FFEltsIter, state) = next_ffelem(state...)
|
||||||
|
Base.done(A::FFEltsIter, state) = state[2] >= A.all
|
||||||
|
Base.eltype(::Type{FFEltsIter}) = elem_type(A.field)
|
||||||
|
Base.length(A::FFEltsIter) = A.all
|
||||||
|
|
||||||
|
function next_ffelem(f::Nemo.FinFieldElem, c::Int)
|
||||||
|
if c == 0
|
||||||
|
return (f, (f, 1))
|
||||||
|
elseif c == 1
|
||||||
|
f = one(parent(f))
|
||||||
|
return (f, (f, 2))
|
||||||
|
else
|
||||||
|
f = gen(parent(f))*f
|
||||||
|
return (f, (f, c+1))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
import Nemo.elements
|
||||||
|
elements(F::Nemo.FinField) = FFEltsIter(F)
|
||||||
|
|
||||||
|
|
||||||
function AutFG_emb(A::AutGroup, g::WreathProductElem)
|
function AutFG_emb(A::AutGroup, g::WreathProductElem)
|
||||||
isa(A.objectGroup, FreeGroup) || throw("Not an Aut(Fₙ)")
|
isa(A.objectGroup, FreeGroup) || throw("Not an Aut(Fₙ)")
|
||||||
|
Loading…
Reference in New Issue
Block a user