Skip to content

Commit

Permalink
Resolve some JET warnings (#2812)
Browse files Browse the repository at this point in the history
... about captured variables and runtime dispatch
  • Loading branch information
fingolfin authored and fieker committed Sep 29, 2023
1 parent 043cf28 commit 5f96abd
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 33 deletions.
21 changes: 10 additions & 11 deletions experimental/GModule/Cohomology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2179,36 +2179,35 @@ function compatible_pairs(C::GModule)
autG = automorphism_group(G)
autM = automorphism_group(M)

T, emb, pro = direct_product(autM, autG, morphisms = true)
D, emb, pro = direct_product(autM, autG, morphisms = true)

function action_on_chain(g::GAPGroupElem, c::CoChain{2, S, T}) where {S, T}
al = pro[1](C[2](g))
ga = pro[2](C[2](g))
d = Dict(ab=> al(c((inv(ga)(ab[1]), inv(ga)(ab[2])))) for ab = keys(c.d))
return CoChain{2, S, T}(c.C, d)
al = pro[1](func(g)::elem_type(D))::elem_type(autM)
ga = pro[2](func(g)::elem_type(D))::elem_type(autG)
d = Dict{Tuple{S, S}, T}(ab=> al(c((inv(ga)(ab[1]), inv(ga)(ab[2])))) for ab = keys(c.d))
return CoChain{2, S, T}(C, d)
end

h = hom(G, autM, [autM(x) for x = C.ac])
im = image(h)[1]
ke = kernel(h)[1]

if order(im) == 1
C = (T, x->x)
return T, action_on_chain
func = Base.identity
return D, action_on_chain
end

N, mN = normalizer(autM, im)
S, mS = stabilizer(autG, ke, (x,y)->image(hom(y), x)[1])

NS, em, pr = direct_product(N, S, morphisms = true)
#from Holt/ Eick, ... Handbook of Computational Group Theory, P319
C = stabilizer(NS, h, (x, y) -> hom(G, autM,
S, func = stabilizer(NS, h, (x, y) -> hom(G, autM,
[inv(pr[1](y))*x(inv(pr[2](y))(g))*pr[1](y) for g = gens(G)]))

#the more direct naive (and slow) approach...
#C = sub(T, [t for t in preimage(pro[1], N)[1] if all(ag -> action(C, pro[2](t)(ag[2]), ag[1]) == pro[1](t)(action(C, ag[2], inv(pro[1](t))(ag[1]))), Iterators.product(gens(M), gens(G)))])
#C = sub(D, [t for t in preimage(pro[1], N)[1] if all(ag -> action(C, pro[2](t)(ag[2]), ag[1]) == pro[1](t)(action(C, ag[2], inv(pro[1](t))(ag[1]))), Iterators.product(gens(M), gens(G)))])

return C[1], action_on_chain
return S, action_on_chain
end

function split_extension(C::GModule)
Expand Down
5 changes: 4 additions & 1 deletion experimental/QuadFormAndIsom/src/enumeration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,10 @@ function splitting_of_prime_power(Lf::ZZLatWithIsom, p::Int, b::Int = 0)
@req is_prime(p) "p must be a prime number"
@req b in [0, 1] "b must be an integer equal to 0 or 1"

ok, e, q = is_prime_power_with_data(order_of_isometry(Lf))
ord = order_of_isometry(Lf)
@req ord isa Int "Order of isometry must be finite"

ok, e, q = is_prime_power_with_data(ord)

@req ok || e == 0 "Order of isometry must be a prime power"
@req p != q "Prime numbers must be distinct"
Expand Down
5 changes: 2 additions & 3 deletions src/Groups/homomorphisms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,11 @@ function isomorphism(::Type{T}, A::GrpAbFinGen) where T <: GAPGroup
exponents = diagonal(rels(A))
A2 = A
A2_to_A = identity_map(A)
A_to_A2 = identity_map(A)
else
exponents = elementary_divisors(A)
A2, A2_to_A = snf(A)
A_to_A2 = inv(A2_to_A)
end
A_to_A2 = inv(A2_to_A)
# the isomorphic gap group
G = abelian_group(T, exponents)
# `GAPWrap.GeneratorsOfGroup(G.X)` consists of independent elements
Expand All @@ -590,7 +589,7 @@ function isomorphism(::Type{T}, A::GrpAbFinGen) where T <: GAPGroup
@assert length(Ggens) + length(filter(x -> x == 1, exponents)) ==
length(exponents)
o = one(G).X
newGgens = []
newGgens = Vector{GapObj}()
pos = 1
for i in 1:length(exponents)
if exponents[i] == 1
Expand Down
28 changes: 11 additions & 17 deletions src/Groups/matrices/FiniteFormOrthogonalGroup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
function _mod_p_to_a_kernel(G::Union{zzModMatrix, ZZModMatrix}, a, p)
n = ncols(G)
R = base_ring(G)
E = identity_matrix(R, n)
ind, val = Hecke._block_indices_vals(G, p)
# add a virtual even block at the end
push!(ind, n+1)
Expand Down Expand Up @@ -57,15 +56,15 @@ function _mod_p_to_a_kernel(G::Union{zzModMatrix, ZZModMatrix}, a, p)
end
end
for h in gensk
g = deepcopy(E)
g = identity_matrix(R, n)
g[i1:i2-1, i1:i2-1] = Ek + p^a*h*Gk_inv
push!(gens, g)
end
end
# generators below the block diagonal.
for i in 1:n
for j in 1:i
g = deepcopy(E)
g = identity_matrix(R, n)
g[i,j] = p^a
flag = true
for k in 1:(length(ind)-1)
Expand Down Expand Up @@ -184,15 +183,14 @@ function _orthogonal_gens_bilinear(G::Union{ZZModMatrix, zzModMatrix})
# but we obtain several possible lifts
gens_1 = _gens_af(G[1:end-2,1:end-2], 2)
gens_1 = [diagonal_matrix(g, identity_matrix(R, 2)) for g in gens_1]
E = identity_matrix(R, r)
for i in 1:r-2
g = deepcopy(E)
g = identity_matrix(R, r)
g[i, r-1] = 1
g[i, r] = 1
g[r-1:end, 1:r-1] = transpose(g[1:r-1, r-1:end]) * G[1:r-1, 1:r-1]
push!(gens_1, g)
end
g = deepcopy(E)
g = identity_matrix(R, r)
g[end-1:end, end-1:end] = matrix(R, 2, 2, [0, 1, 1, 0])
push!(gens_1, g)
else
Expand Down Expand Up @@ -443,7 +441,6 @@ end
function _gens_mod_p(G::Union{ZZModMatrix, zzModMatrix}, p)
n = ncols(G)
R = base_ring(G)
E = identity_matrix(R, n)
indices, valuations = Hecke._block_indices_vals(G, p)
push!(indices, n+1)
gens1 = typeof(G)[]
Expand All @@ -453,15 +450,15 @@ function _gens_mod_p(G::Union{ZZModMatrix, zzModMatrix}, p)
Gi = divexact(G[i1:i2, i1:i2], R(p)^valuations[k])
gens_homog = _orthogonal_grp_gens_odd(Gi, p)
for f in gens_homog
g = deepcopy(E)
g = identity_matrix(R, n)
g[i1:i2, i1:i2] = f
push!(gens1, g)
end
end
# generators below the block diagonal.
for i in 1:n
for j in 1:i-1
g = deepcopy(E)
g = identity_matrix(R, n)
g[i,j] = 1
flag = true
for k in 1:(length(indices)-1)
Expand Down Expand Up @@ -494,7 +491,6 @@ end
function _gens_mod_2(G::Union{ZZModMatrix, zzModMatrix})
n = ncols(G)
R = base_ring(G)
E = identity_matrix(R, n)
p = ZZ(2)
ind0, val0 = Hecke._block_indices_vals(G, 2)
par0 = Int[]
Expand Down Expand Up @@ -548,13 +544,13 @@ function _gens_mod_2(G::Union{ZZModMatrix, zzModMatrix})
end

for h in gens_k
g = deepcopy(E)
g = identity_matrix(R, n)
g[i1:i3,i1:i3] = h
push!(gens, g)
end
end
# a change in convention
trafo = deepcopy(E)
trafo = identity_matrix(R, n)
for k in 2:length(ind)-1
if par[k] == 1 && mod(ind[k][2]-ind[k][1],2) == 1
i = ind[k][2]
Expand Down Expand Up @@ -585,19 +581,18 @@ function _gens_pair(G::Union{ZZModMatrix, zzModMatrix}, k, on_second)
G1 = G[1:k,1:k] # 2^1 - modular
G1inv = inv(divexact(G1, 2))
G2 = G[k+1:end,k+1:end] # 2^0 - modular
E = identity_matrix(R, n)
if on_second
for f in _orthogonal_gens_bilinear(G2)
a = diagonal(divexact(f*G2*transpose(f)-G2, 2))
g = deepcopy(E)
g = identity_matrix(R, n)
g[k+1:end, k+1:end] = f
g[k+1:end, k] = a
push!(gen, g)
end
else
for f in _orthogonal_gens_bilinear(divexact(G1, 2))
a = [divexact(x,2) for x in diagonal(f*G1*transpose(f) - G1)]
g = deepcopy(E)
g = identity_matrix(R, n)
g[1:k,1:k] = f
g[1:k,end] = a
g[k+1:end,1:k] = - G2 * transpose(divexact(g[1:k,k+1:end],2)) * transpose(inv(f)) * G1inv
Expand All @@ -614,15 +609,14 @@ end
function _ker_gens(G::Union{ZZModMatrix, zzModMatrix}, i1, i2, parity)
n = nrows(G)
R = base_ring(G)
E = identity_matrix(R, n)
gens = typeof(G)[]
e = n - 1
if parity[3]==1 && mod(n - i2, 2)==0
e = n - 2
end
for i in i2+1:n
for j in 1:i2
g = deepcopy(E)
g = identity_matrix(R, n)
if parity == [0,0,0] || parity == [1,0,0]
g[i,j] = 1
elseif parity == [0,0,1]
Expand Down
2 changes: 1 addition & 1 deletion src/Groups/spinor_norms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ function det_spin_homomorphism(L::ZZLat; signed=false)
T = discriminant_group(L)
Oq = orthogonal_group(T)
S = prime_divisors(2 * order(domain(Oq)))
A, diagonal, proj,inj,det_hom = _det_spin_group(S, infinity=false)
A, diagonal, _, inj, det_hom = _det_spin_group(S, infinity=false)

# \Sigma^\#(L)
# This is the the image of K under `(det, spin)` where `K` is the kernel
Expand Down

0 comments on commit 5f96abd

Please sign in to comment.