Skip to content

Commit cc4d115

Browse files
Simplify obstructions handling (#2106)
Co-authored-by: Lars Göttgens <lars.goettgens@rwth-aachen.de>
1 parent dd57fe6 commit cc4d115

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

src/generic/FreeAssociativeAlgebraGroebner.jl

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -543,29 +543,20 @@ function remove_redundancies!(
543543
end
544544

545545
function get_obstructions(g::Vector{FreeAssociativeAlgebraElem{T}}) where T
546-
s = length(g)
547-
result = PriorityQueue{Obstruction{T},FreeAssociativeAlgebraElem{T}}()
548-
for i in 1:s, j in 1:i
549-
if i == j
550-
obs = obstructions(_leading_word(g[i]))
551-
else
552-
obs = obstructions(_leading_word(g[i]), _leading_word(g[j]))
553-
end
554-
for o in obs
555-
triple = ObstructionTriple{T}(g[i], g[j], o, i, j)
556-
push!(result, triple => common_multiple_leading_term(triple))
557-
end
546+
obstruction_queue = PriorityQueue{Obstruction{T},FreeAssociativeAlgebraElem{T}}()
547+
for s in 1:length(g)
548+
add_obstructions!(obstruction_queue, g, s)
558549
end
559550
# TODO maybe here some redundancies can be removed too, check Kreuzer Xiu
560-
return result
551+
return obstruction_queue
561552
end
562553

563554

564555
function add_obstructions!(
565556
obstruction_queue::PriorityQueue{Obstruction{T},FreeAssociativeAlgebraElem{T}},
566557
g::Vector{FreeAssociativeAlgebraElem{T}},
558+
s::Int = length(g)
567559
) where T
568-
s = length(g)
569560
for i in 1:s
570561
if i == s
571562
obs = obstructions(_leading_word(g[i]))
@@ -588,19 +579,11 @@ function groebner_basis_buchberger(
588579
obstruction_free_set::Vector{FreeAssociativeAlgebraElem{T}}=FreeAssociativeAlgebraElem{T}[]
589580
) where T<:FieldElement
590581

591-
if isempty(obstruction_free_set)
592-
g = copy(g)
593-
obstruction_queue = get_obstructions(g)
594-
else
595-
temp_g = copy(obstruction_free_set)
596-
obstruction_queue = PriorityQueue{Obstruction{T},FreeAssociativeAlgebraElem{T}}()
597-
sizehint!(temp_g, length(g)+length(obstruction_free_set))
598-
599-
for p in g
600-
push!(temp_g,p)
601-
add_obstructions!(obstruction_queue,temp_g)
602-
end
603-
g = temp_g
582+
g = vcat(obstruction_free_set, g)
583+
584+
obstruction_queue = PriorityQueue{Obstruction{T},FreeAssociativeAlgebraElem{T}}()
585+
for s in length(obstruction_free_set)+1:length(g)
586+
add_obstructions!(obstruction_queue, g, s)
604587
end
605588

606589
# interreduce!(g) # on some small examples, this increases running time, so it might not be optimal to use this here

0 commit comments

Comments
 (0)