Skip to content

Commit

Permalink
feat: make has_preimage_with_preimage faster for abelian groups
Browse files Browse the repository at this point in the history
- Use to a SolveContext to cache the implicit normal form
  computations
  • Loading branch information
thofma committed May 27, 2024
1 parent 6637470 commit 87a4dc7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/GrpAb/Map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function has_preimage_with_preimage(M::FinGenAbGroupHom, a::FinGenAbGroupElem)
return true, preimage(M, a)
end

m = vcat(M.map, rels(codomain(M)))
m = _preimage_ctx(M)
fl, p = can_solve_with_solution(m, a.coeff, side = :left)

if fl
Expand All @@ -61,6 +61,10 @@ function has_preimage_with_preimage(M::FinGenAbGroupHom, a::FinGenAbGroupElem)
end
end

@attr AbstractAlgebra.Solve.SolveCtx{ZZRingElem, ZZMatrix, ZZMatrix, ZZMatrix} function _preimage_ctx(M::FinGenAbGroupHom)
return solve_init(vcat(M.map, rels(codomain(M))))
end

function has_preimage_with_preimage(M::FinGenAbGroupHom, a::Vector{FinGenAbGroupElem})
if isdefined(M, :imap)
return true, map(x->preimage(M, x), a)
Expand Down

0 comments on commit 87a4dc7

Please sign in to comment.