Skip to content

Commit

Permalink
fixed merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-schanz committed Aug 25, 2023
2 parents 80578a9 + 8f223b5 commit 9449acb
Show file tree
Hide file tree
Showing 4 changed files with 459 additions and 10 deletions.
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ uuid = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
version = "0.31.0"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
GroupsCore = "d5909c97-4eac-4ecc-a3dc-fdd0858a4120"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -15,7 +14,6 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
DataStructures = "0.18.13"
GroupsCore = "0.4.0"
MacroTools = "0.5"
Preferences = "1"
Expand Down
20 changes: 17 additions & 3 deletions src/generic/AhoCorasick.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,25 @@ export keyword_index
export keyword

#export Word
#
import DataStructures: Queue, enqueue!, dequeue!

const Word = Vector{Int}

struct Queue{T}
data::Vector{T}
end

function Queue{T}() where T
return Queue{T}(T[])
end

function enqueue!(q::Queue{T}, val::T) where T
push!(q.data, val)
end
function dequeue!(q::Queue)
return popfirst!(q.data)
end
isempty(q::Queue) = isempty(q.data)

@doc """
AhoCorasickAutomaton
Expand Down Expand Up @@ -188,7 +202,7 @@ function construct_fail!(automaton::AhoCorasickAutomaton)
automaton.fail[new_state] = lookup(automaton, state, k)
if automaton.output[new_state][1] >
automaton.output[automaton.fail[new_state]][1]
automaton.output[new_state] = automaton.output[automaton.fail[new_state]] # TODO check if this is the correct way to update output
automaton.output[new_state] = automaton.output[automaton.fail[new_state]]
end

end
Expand Down
10 changes: 5 additions & 5 deletions src/generic/FreeAssAlgebraGroebner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export normal_form

export normal_form_weak

import DataStructures: PriorityQueue, enqueue!, dequeue!
include("PriorityQueue.jl")

const Monomial = Vector{Int}

Expand Down Expand Up @@ -561,7 +561,7 @@ function get_obstructions(g::Vector{FreeAssAlgElem{T}}) where T
end
for o in obs
triple = ObstructionTriple{T}(g[i], g[j], o, i, j)
enqueue!(result, triple, common_multiple_leading_term(triple))
push!(result, triple => common_multiple_leading_term(triple))
end
end
# TODO maybe here some redundancies can be removed too, check Kreuzer Xiu
Expand All @@ -582,7 +582,7 @@ function add_obstructions!(
end
for o in obs
triple = ObstructionTriple{T}(g[i], g[s], o, i, s)
enqueue!(obstruction_queue, triple, common_multiple_leading_term(triple))
push!(obstruction_queue, triple => common_multiple_leading_term(triple))
end
end
#remove_redundancies!(obstruction_queue, s, g[s]) #TODO too slow in practice
Expand All @@ -603,8 +603,8 @@ function groebner_basis_buchberger(
# step 1 from Thm. 5.2.12 Noncommutative Groebner Bases and Applications, Xingqiang Xiu
obstruction_queue = get_obstructions(g)
while !isempty(obstruction_queue) # step 2
obstruction = dequeue!(obstruction_queue)
# step 3
obstruction = popfirst!(obstruction_queue)[1]
# step3
S = s_polynomial(obstruction)
Sp = normal_form(S, g, aut) # or normal_form_weak
if iszero(Sp)
Expand Down
Loading

0 comments on commit 9449acb

Please sign in to comment.