Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/elimination.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function det_minor_expansion_inner(
if length(discarded[1]) == n
return 1
end
if discarded in keys(cache)
if haskey(cache, discarded)
return cache[discarded]
end
result = 0
Expand All @@ -25,7 +25,7 @@ function det_minor_expansion_inner(
sign *
m[row, col] *
det_minor_expansion_inner(m, (dis_rows, dis_cols), cache)
sign = -1 * sign
sign = -sign
end
end
if length(discarded[1]) > 1
Expand Down
31 changes: 15 additions & 16 deletions src/wronskian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,37 @@ end

function monomial_compress(io_equation, params::Array{<:MPolyRingElem, 1})
params_xs = isempty(params) ? empty(params) : gens(parent(first(params)))
# Pre-compute param string names for faster lookup
param_names = Set(var_to_str(p, xs = params_xs) for p in params)
other_vars = [
v for v in gens(parent(io_equation)) if
!(var_to_str(v) in map(p -> var_to_str(p, xs = params_xs), params))
v for v in gens(parent(io_equation)) if !(var_to_str(v) in param_names)
]
coeffdict = extract_coefficients(io_equation, other_vars)
expvect = collect(keys(coeffdict))
coeffs = collect(values(coeffdict))
termlist = map(x -> prod(other_vars .^ x), expvect)

echelon_form = Array{Any, 1}()
# Use typed arrays instead of Array{Any, 1}
P = eltype(coeffs)
T = eltype(termlist)
echelon_form = Vector{Tuple{P, T}}()
sizehint!(echelon_form, length(coeffs))
for (c, p) in zip(coeffs, termlist)
for i in 1:length(echelon_form)
basis_c = echelon_form[i][1]
coef = coeff(c, leading_monomial(basis_c)) // leading_coefficient(basis_c)
lm = leading_monomial(basis_c)
coef = coeff(c, lm) // leading_coefficient(basis_c)
if coef != 0
c = c - coef * basis_c
echelon_form[i][2] += coef * p
echelon_form[i] = (echelon_form[i][1], echelon_form[i][2] + coef * p)
end
end
if c != 0
push!(echelon_form, [c, p])
push!(echelon_form, (c, p))
end
end

result = ([a[1] for a in echelon_form], [a[2] for a in echelon_form])
#s = 0
#for (a, b) in zip(result[1], result[2])
# s += parent_ring_change(a, parent(io_equation)) * parent_ring_change(b, parent(io_equation))
#end
#println("====================")
#println(s - io_equation)

return result
end

Expand Down Expand Up @@ -139,14 +138,14 @@ function massive_eval(polys, eval_dict)
point = [get(eval_dict, v, zero(R)) for v in gens(parent(first(polys)))]
n = length(point)

monomials = Set()
monomials = Set{Vector{Int}}()
for p in polys
for exp in exponent_vectors(p)
push!(monomials, exp)
end
end

cache = Dict()
cache = Dict{Vector{Int}, typeof(one(R))}()
cache[[0 for i in 1:n]] = one(R)
cached_monoms = ExpVectTrie(n)
push!(cached_monoms, [0 for _ in 1:n])
Expand All @@ -158,7 +157,7 @@ function massive_eval(polys, eval_dict)
end

for exp in sort!(collect(monomials), by = sum)
if !(exp in keys(cache))
if !haskey(cache, exp)
monom_val = one(R)
computed = [0 for i in 1:n]
while sum(exp) > 0
Expand Down