Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change most uses of GAP.julia_to_gap to GAP.Obj #1600

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions experimental/GModule/Cohomology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function Oscar.relations(G::Oscar.GAPGroup)
end

function Oscar.relations(G::PcGroup)
f = GAP.Globals.IsomorphismFpGroupByPcgs(GAP.Globals.FamilyPcgs(G.X), GAP.julia_to_gap("g"))
f = GAP.Globals.IsomorphismFpGroupByPcgs(GAP.Globals.FamilyPcgs(G.X), GAP.Obj("g"))
f !=GAP.Globals.fail || throw(ArgumentError("Could not convert group into a group of type FPGroup"))
H = FPGroup(GAPWrap.Image(f))
return relations(H)
Expand Down Expand Up @@ -1138,7 +1138,7 @@ function pc_group(M::GrpAbFinGen; refine::Bool = true)
h = rels(M)
@assert !any(x->h[x,x] == 1, 1:ncols(h))

C = GAP.Globals.SingleCollector(G.X, GAP.julia_to_gap([h[i,i] for i=1:nrows(h)], recursive = true))
C = GAP.Globals.SingleCollector(G.X, GAP.Obj([h[i,i] for i=1:nrows(h)], recursive = true))
F = GAP.Globals.FamilyObj(GAP.Globals.Identity(G.X))

for i=1:ngens(M)-1
Expand All @@ -1148,7 +1148,7 @@ function pc_group(M::GrpAbFinGen; refine::Bool = true)
push!(r, -h[i, j])
GAP.Globals.SetConjugate(C, j, i, gen(G, j).X)
end
rr = GAP.Globals.ObjByExtRep(F, GAP.julia_to_gap(r, recursive = true))
rr = GAP.Globals.ObjByExtRep(F, GAP.Obj(r, recursive = true))
GAP.Globals.SetPower(C, i, rr)
end

Expand All @@ -1163,7 +1163,7 @@ function pc_group(M::GrpAbFinGen; refine::Bool = true)
push!(r, a[i])
end
end
return GAP.Globals.ObjByExtRep(FB, GAP.julia_to_gap(r, recursive = true))
return GAP.Globals.ObjByExtRep(FB, GAP.Obj(r, recursive = true))
end

gap_to_julia = function(a::GAP.GapObj)
Expand Down Expand Up @@ -1209,7 +1209,7 @@ function pc_group(M::Generic.FreeModule{<:FinFieldElem}; refine::Bool = true)
G = free_group(degree(k)*dim(M))

C = GAP.Globals.CombinatorialCollector(G.X,
GAP.julia_to_gap([p for i=1:ngens(G)], recursive = true))
GAP.Obj([p for i=1:ngens(G)], recursive = true))
F = GAP.Globals.FamilyObj(GAP.Globals.Identity(G.X))

B = PcGroup(GAP.Globals.GroupByRws(C))
Expand All @@ -1223,7 +1223,7 @@ function pc_group(M::Generic.FreeModule{<:FinFieldElem}; refine::Bool = true)
push!(r, lift(a[i]))
end
end
g = GAP.Globals.ObjByExtRep(FB, GAP.julia_to_gap(r, recursive = true))
g = GAP.Globals.ObjByExtRep(FB, GAP.Obj(r, recursive = true))
return g
end

Expand All @@ -1239,7 +1239,7 @@ function pc_group(M::Generic.FreeModule{<:FinFieldElem}; refine::Bool = true)
end
end
end
g = GAP.Globals.ObjByExtRep(FB, GAP.julia_to_gap(r, recursive = true))
g = GAP.Globals.ObjByExtRep(FB, GAP.Obj(r, recursive = true))
return g
end

Expand Down Expand Up @@ -1450,12 +1450,12 @@ function extension(::Type{PcGroup}, c::CoChain{2,<:Oscar.PcGroupElem})
end
end

# l = GAP.julia_to_gap([])
# l = GAP.Obj([])
# GAP.Globals.FinitePolycyclicCollector_IsConfluent(CN, l)
# @show l

# z = GAP.Globals.GroupByRwsNC(CN)
# s = GAP.Globals.GapInputPcGroup(z, GAP.julia_to_gap("Z"))
# s = GAP.Globals.GapInputPcGroup(z, GAP.Obj("Z"))
# @show GAP.gap_to_julia(s)
Q = PcGroup(GAP.Globals.GroupByRws(CN))
fQ = GAP.Globals.FamilyObj(one(Q).X)
Expand All @@ -1478,7 +1478,7 @@ function extension(::Type{PcGroup}, c::CoChain{2,<:Oscar.PcGroupElem})
push!(wg, wm[i]+ngens(G))
push!(wg, wm[i+1])
end
return mQ(FPGroupElem(N, GAP.Globals.ObjByExtRep(FN, GAP.julia_to_gap(wg))))
return mQ(FPGroupElem(N, GAP.Globals.ObjByExtRep(FN, GAP.Obj(wg))))
end

return Q, inv(mfM)*MtoQ, QtoG, GMtoQ
Expand Down
4 changes: 2 additions & 2 deletions experimental/GModule/GModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ function Gap(C::GModule{<:Any, <:Generic.FreeModule{<:FinFieldElem}}, h=Oscar.is
if z !== nothing
return z
end
z = GAP.Globals.GModuleByMats(GAP.julia_to_gap([GAP.julia_to_gap(map(h, Matrix(mat(x)))) for x = C.ac]), codomain(h))
z = GAP.Globals.GModuleByMats(GAP.Obj([GAP.Obj(map(h, Matrix(mat(x)))) for x = C.ac]), codomain(h))
set_attribute!(C, :Gap=>z)
return z
end
Expand Down Expand Up @@ -1130,7 +1130,7 @@ export irreducible_modules, is_absolutely_irreducible, is_decomposable
## Fill in some stubs for Hecke

function _to_gap(h, x::Vector)
return GAP.Globals.GModuleByMats(GAP.julia_to_gap([GAP.julia_to_gap(map(h, Matrix(y))) for y in x]), codomain(h))
return GAP.Globals.GModuleByMats(GAP.Obj([GAP.Obj(map(h, Matrix(y))) for y in x]), codomain(h))
end

function _gap_matrix_to_julia(h, g)
Expand Down
6 changes: 3 additions & 3 deletions src/Groups/GAPGroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ function hall_subgroup(G::GAPGroup, P::AbstractVector{<:IntegerUnion})
P = unique(P)
all(is_prime, P) || throw(ArgumentError("The integers must be prime"))
is_solvable(G) || throw(ArgumentError("The group is not solvable"))
return _as_subgroup(G,GAP.Globals.HallSubgroup(G.X,GAP.julia_to_gap(P, recursive=true)))
return _as_subgroup(G,GAP.Globals.HallSubgroup(G.X,GAP.Obj(P, recursive=true)))
end

"""
Expand Down Expand Up @@ -1124,7 +1124,7 @@ julia> h = hall_subgroup_reps(g, [2, 7]); length(h)
function hall_subgroup_reps(G::GAPGroup, P::AbstractVector{<:IntegerUnion})
P = unique(P)
all(is_prime, P) || throw(ArgumentError("The integers must be prime"))
res_gap = GAP.Globals.HallSubgroup(G.X, GAP.julia_to_gap(P))::GapObj
res_gap = GAP.Globals.HallSubgroup(G.X, GAP.Obj(P))::GapObj
if res_gap == GAP.Globals.fail
return typeof(G)[]
elseif GAPWrap.IsList(res_gap)
Expand Down Expand Up @@ -1393,7 +1393,7 @@ has_prime_of_pgroup(G::GAPGroup) = has__prime_of_pgroup(G)
Set the value for `prime_of_pgroup(G)` to `p` if it has't been set already.
"""
function set_prime_of_pgroup(G::GAPGroup, p::IntegerUnion)
set__prime_of_pgroup(G, GAP.julia_to_gap(p))
set__prime_of_pgroup(G, GAP.Obj(p))
end


Expand Down
2 changes: 1 addition & 1 deletion src/Groups/abelian_aut.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function (aut::AutGrpAbTor)(f::Union{GrpAbFinGenMap,TorQuadModMor};check::Bool=t
return b.X
end
gene = GAP.Globals.GeneratorsOfGroup(AA)
img = GAP.julia_to_gap([img_gap(a) for a in gene])
img = GAP.Obj([img_gap(a) for a in gene])
fgap = GAP.Globals.GroupHomomorphismByImagesNC(AA,AA,img)
return aut(fgap)
end
Expand Down
2 changes: 1 addition & 1 deletion src/Groups/cosets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ function intersect(V::AbstractVector{Union{T, GroupCoset, GroupDoubleCoset}}) wh
else
G = V[1].G
end
l = GAP.julia_to_gap([v.X for v in V])
l = GAP.Obj([v.X for v in V])
ints = GAP.Globals.Intersection(l)
L = Vector{typeof(G)}(undef, length(ints))
for i in 1:length(ints)
Expand Down
2 changes: 1 addition & 1 deletion src/Groups/directproducts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function inner_direct_product(L::AbstractVector{T}; morphisms=false) where T<:Un
end

function inner_direct_product(L::AbstractVector{PermGroup}; morphisms=false)
P = GAP.Globals.DirectProductOfPermGroupsWithMovedPoints(GapObj([G.X for G in L]), GAP.julia_to_gap([collect(1:degree(G)) for G in L], recursive = true))
P = GAP.Globals.DirectProductOfPermGroupsWithMovedPoints(GapObj([G.X for G in L]), GAP.Obj([collect(1:degree(G)) for G in L], recursive = true))
DP = PermGroup(P, sum([degree(G) for G in L], init = 0))
if morphisms
emb = [GAPGroupHomomorphism(L[i],DP,GAP.Globals.Embedding(P,i)) for i in 1:length(L)]
Expand Down
4 changes: 2 additions & 2 deletions src/Groups/group_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function abelian_group(v::Vector{Int})
for i = 1:length(v)
iszero(v[i]) && error("Cannot represent an infinite group as a polycyclic group")
end
v1 = GAP.julia_to_gap(v)
v1 = GAP.Obj(v)
return PcGroup(GAP.Globals.AbelianGroup(v1))
end
=#
Expand All @@ -168,7 +168,7 @@ function abelian_group(::Type{T}, v::Vector{Int}) where T <: GAPGroup
end

function abelian_group(::Type{T}, v::Vector{fmpz}) where T <: GAPGroup
vgap = GAP.julia_to_gap(v, recursive=true)
vgap = GAP.Obj(v, recursive=true)
return T(GAP.Globals.AbelianGroup(_gap_filter(T), vgap)::GapObj)
end

Expand Down
12 changes: 6 additions & 6 deletions src/Groups/gsets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ julia> permutation(Omega, x)
```
"""
function permutation(Omega::GSetByElements{T}, g::GAPGroupElem) where T<:GAPGroup
omega_list = GAP.julia_to_gap(elements(Omega))
gfun = GAP.julia_to_gap(action_function(Omega))
omega_list = GAP.Obj(elements(Omega))
gfun = GAP.Obj(action_function(Omega))

# The following works only because GAP does not check
# whether the given group element 'g' is a group element.
Expand Down Expand Up @@ -494,13 +494,13 @@ true
"""
@attr GAPGroupHomomorphism{T, PermGroup} function action_homomorphism(Omega::GSetByElements{T}) where T<:GAPGroup
G = acting_group(Omega)
omega_list = GAP.julia_to_gap(collect(Omega))
omega_list = GAP.Obj(collect(Omega))
gap_gens = map(x -> x.X, gens(G))
gfun = GAP.julia_to_gap(action_function(Omega))
gfun = GAP.Obj(action_function(Omega))

# The following works only because GAP does not check
# whether the given generators in GAP and Julia fit together.
acthom = GAP.Globals.ActionHomomorphism(G.X, omega_list, GAP.julia_to_gap(gap_gens), GAP.julia_to_gap(gens(G)), gfun)
acthom = GAP.Globals.ActionHomomorphism(G.X, omega_list, GAP.Obj(gap_gens), GAP.Obj(gens(G)), gfun)

# The first difficulty on the GAP side is `ImagesRepresentative`
# (which is the easy direction of the action homomorphism):
Expand All @@ -516,7 +516,7 @@ true
# (Yes, this is also overhead.
# The alternative would be to create a new type of Oscar homomorphism,
# which uses `permutation` or something better for mapping elements.)
GAP.Globals.SetJuliaData(acthom, GAP.julia_to_gap([Omega, G]))
GAP.Globals.SetJuliaData(acthom, GAP.Obj([Omega, G]))

sym = get_attribute!(Omega, :action_range) do
return symmetric_group(length(Omega))
Expand Down
6 changes: 3 additions & 3 deletions src/Groups/homomorphisms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function hom(G::GAPGroup, H::GAPGroup, img::Function)
img_el = img(el)
return img_el.X
end
mp = GAP.Globals.GroupHomomorphismByFunction(G.X, H.X, GAP.julia_to_gap(gap_fun))
mp = GAP.Globals.GroupHomomorphismByFunction(G.X, H.X, GAP.Obj(gap_fun))
return GAPGroupHomomorphism(G, H, mp)
end

Expand All @@ -122,9 +122,9 @@ function hom(G::GAPGroup, H::GAPGroup, img::Function, preimg::Function; is_known
end

if is_known_to_be_bijective
mp = GAP.Globals.GroupHomomorphismByFunction(G.X, H.X, GAP.julia_to_gap(gap_fun), GAP.julia_to_gap(gap_pre_fun))
mp = GAP.Globals.GroupHomomorphismByFunction(G.X, H.X, GAP.Obj(gap_fun), GAP.Obj(gap_pre_fun))
else
mp = GAP.Globals.GroupHomomorphismByFunction(G.X, H.X, GAP.julia_to_gap(gap_fun), false, GAP.julia_to_gap(gap_pre_fun))
mp = GAP.Globals.GroupHomomorphismByFunction(G.X, H.X, GAP.Obj(gap_fun), false, GAP.Obj(gap_pre_fun))
end

return GAPGroupHomomorphism(G, H, mp)
Expand Down
2 changes: 1 addition & 1 deletion src/Groups/matrices/MatGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ matrix_group(V::T...) where T<:Union{MatElem,MatrixGroupElem} = matrix_group(col

function sub(G::MatrixGroup, elements::Vector{S}) where S <: GAPGroupElem
@assert elem_type(G) === S
elems_in_GAP = GAP.julia_to_gap(GapObj[x.X for x in elements])
elems_in_GAP = GAP.Obj(GapObj[x.X for x in elements])
H = GAP.Globals.Subgroup(G.X,elems_in_GAP)::GapObj
#H is the group. I need to return the inclusion map too
K,f = _as_subgroup(G, H)
Expand Down
4 changes: 2 additions & 2 deletions src/Groups/perm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function cperm(L::AbstractVector{T}...) where T <: IntegerUnion
if length(L)==0
return one(symmetric_group(1))
else
return prod([PermGroupElem(symmetric_group(maximum(y)), GAP.Globals.CycleFromList(GAP.julia_to_gap([Int(k) for k in y]))) for y in L])
return prod([PermGroupElem(symmetric_group(maximum(y)), GAP.Globals.CycleFromList(GAP.Obj([Int(k) for k in y]))) for y in L])
#TODO: better create the product of GAP permutations?
end
end
Expand All @@ -298,7 +298,7 @@ function cperm(g::PermGroup,L::AbstractVector{T}...) where T <: IntegerUnion
if length(L)==0
return one(g)
else
x=prod(y -> GAP.Globals.CycleFromList(GAP.julia_to_gap([Int(k) for k in y])), L)
x=prod(y -> GAP.Globals.CycleFromList(GAP.Obj([Int(k) for k in y])), L)
if length(L) <= degree(g) && x in g.X
return PermGroupElem(g, x)
else
Expand Down
2 changes: 1 addition & 1 deletion src/Rings/AbelianClosure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ Base.conj(elm::QQAbElem) = elm^QQAbAutomorphism(-1)
###############################################################################

function generators_galois_group_cyclotomic_field(n::Int)
res = GAP.Globals.GeneratorsPrimeResidues(GAP.julia_to_gap(n))
res = GAP.Globals.GeneratorsPrimeResidues(GAP.Obj(n))
return [QQAbAutomorphism(k)
for k in Vector{Int}(GAP.Globals.Flat(res.generators))]
end
Expand Down
8 changes: 4 additions & 4 deletions test/Groups/matrixgroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# for i in 1:3
# xg[i] = GAP.GapObj([preimage(G.ring_iso, xo[i,j]) for j in 1:3])
# end
# xg=GAP.julia_to_gap(xg)
# xg=GAP.Obj(xg)

xg = GAP.GapObj([[G.ring_iso(xo[i,j]) for j in 1:3] for i in 1:3]; recursive=true)
@test map_entries(G.ring_iso, xo) == xg
Expand Down Expand Up @@ -58,9 +58,9 @@
xo = matrix(F,3,3,[1,z,0,0,1,2*z+1,0,0,z+2])
xg = Vector{GAP.GapObj}(undef, 3)
for i in 1:3
xg[i] = GAP.julia_to_gap([G.ring_iso(xo[i,j]) for j in 1:3])
xg[i] = GAP.Obj([G.ring_iso(xo[i,j]) for j in 1:3])
end
xg=GAP.julia_to_gap(xg)
xg=GAP.Obj(xg)
@test map_entries(G.ring_iso, xo) == xg
@test Oscar.preimage_matrix(G.ring_iso, xg) == xo
@test Oscar.preimage_matrix(G.ring_iso, GAP.Globals.One(GAP.Globals.GL(3, codomain(G.ring_iso)))) == matrix(one(G))
Expand Down Expand Up @@ -134,7 +134,7 @@ end
@test (g\x) * (g\y) == g\(x * y)
@test g(g\x) == x
end
H = GAP.Globals.Group(GAP.julia_to_gap(gens(G0); recursive=true))
H = GAP.Globals.Group(GAP.Obj(gens(G0); recursive=true))
f = GAP.Globals.GroupHomomorphismByImages(G.X, H)
@test GAP.Globals.IsBijective(f)
@test order(G) == GAP.Globals.Order(H)
Expand Down