Skip to content

Commit ede413d

Browse files
authored
Remove Base.getproperty methods for MatrixGroup(Elem) and SesquilinearForm (#4362)
* Remove Base.getproperty methods for MatrixGroup(Elem) and SesquilinearForm
1 parent b7b0869 commit ede413d

File tree

5 files changed

+20
-67
lines changed

5 files changed

+20
-67
lines changed

src/Groups/group_characters.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ end
180180
#
181181
function isomorphism_to_GAP_group(G::GAPGroup)
182182
finv = function(x::GAP.Obj) return group_element(G, x); end
183-
return MapFromFunc(G, G.X, GapObj, finv)
183+
return MapFromFunc(G, GapObj(G), GapObj, finv)
184184
end
185185

186186
function isomorphism_to_GAP_group(G::FinGenAbGroup)
@@ -189,9 +189,9 @@ function isomorphism_to_GAP_group(G::FinGenAbGroup)
189189
iso = isomorphism(SubPcGroup, G)
190190
C = codomain(iso)
191191
@assert C isa GAPGroup
192-
f = function(x) return iso(x).X; end
192+
f = function(x) return GapObj(iso(x)) end
193193
finv = function(x::GAP.Obj) return preimage(iso, group_element(C, x)); end
194-
return MapFromFunc(G, C.X, f, finv)
194+
return MapFromFunc(G, GapObj(C), f, finv)
195195
end
196196

197197
function isomorphism_to_GAP_group(tbl::GAPGroupCharacterTable)

src/Groups/matrices/MatGrp.jl

+11-42
Original file line numberDiff line numberDiff line change
@@ -241,37 +241,6 @@ GAP.@install function GapObj(x::MatrixGroupElem)
241241
return x.X
242242
end
243243

244-
# return the G.sym if isdefined(G, :sym); otherwise, the field :sym is computed and set using information from other defined fields
245-
function Base.getproperty(G::MatrixGroup{T}, sym::Symbol) where T
246-
247-
isdefined(G,sym) && return getfield(G,sym)
248-
249-
if sym === :X
250-
if isdefined(G,:descr)
251-
assign_from_description(G)
252-
elseif isdefined(G,:gens)
253-
V = GapObj(gens(G); recursive=true)
254-
G.X = isempty(V) ? GAPWrap.Group(V, GapObj(one(G))) : GAPWrap.Group(V)
255-
else
256-
error("Cannot determine underlying GAP object")
257-
end
258-
end
259-
260-
return getfield(G, sym)
261-
262-
end
263-
264-
265-
function Base.getproperty(x::MatrixGroupElem, sym::Symbol)
266-
267-
isdefined(x,sym) && return getfield(x,sym)
268-
269-
if sym === :X
270-
x.X = map_entries(_ring_iso(parent(x)), x.elm)
271-
end
272-
return getfield(x,sym)
273-
end
274-
275244
Base.IteratorSize(::Type{<:MatrixGroup}) = Base.SizeUnknown()
276245

277246
Base.iterate(G::MatrixGroup) = iterate(G, GAPWrap.Iterator(GapObj(G)))
@@ -530,13 +499,13 @@ degree(G::MatrixGroup) = G.deg
530499
Base.one(G::MatrixGroup) = MatrixGroupElem(G, identity_matrix(base_ring(G), degree(G)))
531500

532501
function Base.rand(rng::Random.AbstractRNG, G::MatrixGroup)
533-
x_gap = GAP.Globals.Random(GAP.wrap_rng(rng), G.X)::GapObj
502+
x_gap = GAP.Globals.Random(GAP.wrap_rng(rng), GapObj(G))::GapObj
534503
return MatrixGroupElem(G, x_gap)
535504
end
536505

537506
function gens(G::MatrixGroup)
538507
if !isdefined(G,:gens)
539-
L = GAPWrap.GeneratorsOfGroup(G.X)::GapObj
508+
L = GAPWrap.GeneratorsOfGroup(GapObj(G))::GapObj
540509
G.gens = [MatrixGroupElem(G, a::GapObj) for a in L]
541510
end
542511
return G.gens::Vector{elem_type(G)}
@@ -555,26 +524,26 @@ end
555524
number_of_generators(G::MatrixGroup) = length(gens(G))
556525

557526

558-
compute_order(G::GAPGroup) = ZZRingElem(GAPWrap.Size(G.X))
527+
compute_order(G::GAPGroup) = ZZRingElem(GAPWrap.Size(GapObj(G)))
559528

560529
function compute_order(G::MatrixGroup{T}) where {T <: Union{AbsSimpleNumFieldElem, QQFieldElem}}
561530
#=
562531
- For a matrix group G over the rationals or over a number field,
563-
the GAP group G.X does usually not store the flag `IsHandledByNiceMonomorphism`.
532+
the GAP group GapObj(G) does usually not store the flag `IsHandledByNiceMonomorphism`.
564533
- If we know a reasonable ("nice") faithful permutation action of `G` in advance,
565-
we can set this flag in `G.X` to true and store the action homomorphism in `G.X`,
534+
we can set this flag in `GapObj(G)` to true and store the action homomorphism in `GapObj(G)`,
566535
and then this information should be used in the computation of the order.
567536
- If the flag is not known to be true then the Oscar code from
568537
`isomorphic_group_over_finite_field` shall be preferred.
569538
=#
570-
if GAP.Globals.HasIsHandledByNiceMonomorphism(G.X) && GAPWrap.IsHandledByNiceMonomorphism(G.X)
539+
if GAP.Globals.HasIsHandledByNiceMonomorphism(GapObj(G)) && GAPWrap.IsHandledByNiceMonomorphism(GapObj(G))
571540
# The call to `IsHandledByNiceMonomorphism` triggers an expensive
572541
# computation of `IsFinite` which we avoid by checking
573542
# `HasIsHandledByNiceMonomorphism` first.
574-
return ZZRingElem(GAPWrap.Size(G.X))
543+
return ZZRingElem(GAPWrap.Size(GapObj(G)))
575544
else
576545
n = order(isomorphic_group_over_finite_field(G)[1])
577-
GAP.Globals.SetSize(G.X, GAP.Obj(n))
546+
GAP.Globals.SetSize(GapObj(G), GAP.Obj(n))
578547
return n
579548
end
580549
end
@@ -990,8 +959,8 @@ const SU = special_unitary_group
990959

991960
function sub(G::MatrixGroup, elements::Vector{S}) where S <: GAPGroupElem
992961
@assert elem_type(G) === S
993-
elems_in_GAP = GAP.Obj(GapObj[x.X for x in elements])
994-
H = GAP.Globals.Subgroup(G.X,elems_in_GAP)::GapObj
962+
elems_in_GAP = GAP.Obj(GapObj[GapObj(x) for x in elements])
963+
H = GAP.Globals.Subgroup(GapObj(G),elems_in_GAP)::GapObj
995964
#H is the group. I need to return the inclusion map too
996965
K,f = _as_subgroup(G, H)
997966
L = Vector{elem_type(K)}(undef, length(elements))
@@ -1028,7 +997,7 @@ function Base.:^(H::MatrixGroup, y::MatrixGroupElem)
1028997
for k in gens(K) k.parent = K end
1029998
else
1030999
K = matrix_group(base_ring(H), degree(H))
1031-
K.X = H.X^y.X
1000+
K.X = GapObj(H)^GapObj(y)
10321001
end
10331002

10341003
return K

src/Groups/matrices/form_group.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,13 @@ end
555555
# return the GAP matrix of the form preserved by the GAP standard group
556556
function _standard_form(descr::Symbol, e::Int, n::Int, q::Int)
557557
if descr==:quadratic
558-
return GAP.Globals.InvariantQuadraticForm(GO(e,n,q).X).matrix
558+
return GAP.Globals.InvariantQuadraticForm(GapObj(GO(e,n,q))).matrix
559559
elseif descr==:symmetric #|| descr==:alternating
560-
return GAP.Globals.InvariantBilinearForm(GO(e,n,q).X).matrix
560+
return GAP.Globals.InvariantBilinearForm(GapObj(GO(e,n,q))).matrix
561561
elseif descr==:hermitian
562-
return GAP.Globals.InvariantSesquilinearForm(GU(n,q).X).matrix
562+
return GAP.Globals.InvariantSesquilinearForm(GapObj(GU(n,q))).matrix
563563
elseif descr==:alternating
564-
return GAP.Globals.InvariantBilinearForm(Sp(n,q).X).matrix
564+
return GAP.Globals.InvariantBilinearForm(GapObj(Sp(n,q))).matrix
565565
else
566566
error("unsupported description")
567567
end

src/Groups/matrices/forms.jl

-16
Original file line numberDiff line numberDiff line change
@@ -311,22 +311,6 @@ GAP.@install function GapObj(f::SesquilinearForm)
311311
return f.X
312312
end
313313

314-
function Base.getproperty(f::SesquilinearForm, sym::Symbol)
315-
316-
if isdefined(f,sym) return getfield(f,sym) end
317-
318-
if sym == :X
319-
if !isdefined(f, :X)
320-
assign_from_description(f)
321-
end
322-
323-
end
324-
325-
return getfield(f, sym)
326-
327-
end
328-
329-
330314

331315
########################################################################
332316
#

src/Groups/matrices/transform_form.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ function is_congruent(f::SesquilinearForm{T}, g::SesquilinearForm{T}) where T <:
394394

395395
if f.descr==:quadratic
396396
if iseven(characteristic(F)) # in this case we use the GAP algorithms
397-
Bg = preimage_matrix(_ring_iso(g), GAP.Globals.BaseChangeToCanonical(g.X))
398-
Bf = preimage_matrix(_ring_iso(f), GAP.Globals.BaseChangeToCanonical(f.X))
397+
Bg = preimage_matrix(_ring_iso(g), GAP.Globals.BaseChangeToCanonical(GapObj(g)))
398+
Bf = preimage_matrix(_ring_iso(f), GAP.Globals.BaseChangeToCanonical(GapObj(f)))
399399

400400
UTf = _upper_triangular_version(Bf*gram_matrix(f)*transpose(Bf))
401401
UTg = _upper_triangular_version(Bg*gram_matrix(g)*transpose(Bg))

0 commit comments

Comments
 (0)