Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polynomial_ring cached=false for combinatorics #3856

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions src/Combinatorics/Matroids/ChowRings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function chow_ring(M::Matroid; ring::Union{MPolyRing,Nothing}=nothing, extended:

@req length(var_names) > 0 "Chow ring is empty"
if graded
ring, vars = graded_polynomial_ring(QQ, var_names, cached=false)
ring, vars = graded_polynomial_ring(QQ, var_names; cached=false)
else
ring, vars = polynomial_ring(QQ, var_names, cached=false)
ring, vars = polynomial_ring(QQ, var_names; cached=false)
end
else
if extended
Expand Down Expand Up @@ -166,7 +166,7 @@ function augmented_chow_ring(M::Matroid)
var_names = vcat(element_var_names, flat_var_names)
s = length(var_names)

ring, vars = polynomial_ring(QQ, var_names)
ring, vars = polynomial_ring(QQ, var_names; cached=false)
element_vars = vars[1:n]
flat_vars = vars[n+1:s]

Expand Down
4 changes: 2 additions & 2 deletions src/Combinatorics/Matroids/matroid_strata_grassmannian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function make_polynomial_ring(Bs::Vector{Vector{Int}}, B::Vector{Int},
F::AbstractAlgebra.Ring)

MC = bases_matrix_coordinates(Bs, B)
R, x = polynomial_ring(F, :"x"=>MC)
R, x = polynomial_ring(F, :"x"=>MC; cached=false)
xdict = Dict{Vector{Int}, MPolyRingElem}([MC[i] => x[i] for i in 1:length(MC)])
return R, x, xdict
end
Expand Down Expand Up @@ -330,7 +330,7 @@ function realization_polynomial_ring(Bs::Vector{Vector{Int}}, A::Vector{Int},
MC = realization_bases_coordinates(Bs, A)
D = partial_matrix_max_rows(MC)
MR = [x for x in MC if x[1] != D[x[2]]]
R, x = polynomial_ring(F, :"x"=>MR)
R, x = polynomial_ring(F, :"x"=>MR; cached=false)
xdict = Dict{Vector{Int}, MPolyRingElem}(MR[i] => x[i] for i in 1:length(MR))
return R, x, xdict
end
Expand Down
6 changes: 3 additions & 3 deletions src/Combinatorics/Matroids/properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ x^3 + 4*x^2 + 7*x*y + 3*x + y^4 + 3*y^3 + 6*y^2 + 3*y
```
"""
function tutte_polynomial(M::Matroid)
R, (x, y) = polynomial_ring(ZZ, ["x", "y"])
R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; cached=false)
poly = pm_object(M).TUTTE_POLYNOMIAL
exp = Polymake.monomials_as_matrix(poly)
return R(Vector{Int}(Polymake.coefficients_as_vector(poly)),[[exp[i,1],exp[i,2]] for i in 1:size(exp)[1]])
Expand All @@ -918,7 +918,7 @@ q^3 - 7*q^2 + 14*q - 8
```
"""
function characteristic_polynomial(M::Matroid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions touched here should all at some point be changed allow passing in the polynomial ring, as discussed here in our dev docs

(To be clear, that's not a request to change this PR)

R, q = polynomial_ring(ZZ, 'q')
R, q = polynomial_ring(ZZ, 'q'; cached=false)
return (-1)^rank(M)*tutte_polynomial(M)(1-q,0)
end

Expand All @@ -936,7 +936,7 @@ q^2 - 6*q + 8
```
"""
function reduced_characteristic_polynomial(M::Matroid)
R, q = polynomial_ring(ZZ, 'q')
R, q = polynomial_ring(ZZ, 'q'; cached=false)
p = characteristic_polynomial(M)
Comment on lines +939 to 940
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
R, q = polynomial_ring(ZZ, 'q'; cached=false)
p = characteristic_polynomial(M)
p = characteristic_polynomial(M)
R = parent(p)

c = Vector{Int}(undef,degree(p))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh... that seems risky, couldn't one have examples where an Int would over- or underflow?

s = 0
Expand Down
Loading