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

Use StarAlgebras.QuadraticForm #391

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: |
using Pkg
Pkg.add([
PackageSpec(name="StarAlgebras", rev="main"),
PackageSpec(name="StarAlgebras", rev="mk/quadratic_form"),
PackageSpec(name="SymbolicWedderburn", rev="master"),
PackageSpec(name="MultivariateBases", rev="master"),
PackageSpec(name="MultivariateMoments", rev="master"),
Expand Down
3 changes: 2 additions & 1 deletion src/Certificate/newton_polytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ Base.copy(s::SignChange) = s
Base.iszero(::SignChange) = false
MA.scaling_convert(::Type, s::SignChange) = s
Base.:*(s::SignChange, α::Real) = SignChange(s.sign * α, s.Δ)
Base.:*(α::Real, s::SignChange) = SignChange(α * s.sign, s.Δ)

struct SignCount
unknown::Int
Expand Down Expand Up @@ -710,7 +711,7 @@ function post_filter(
cache = zero(Float64, MB.algebra(MB.implicit_basis(SA.basis(poly))))
for (mono, v) in SA.nonzero_pairs(SA.coeffs(poly))
MA.operate!(
SA.UnsafeAddMul(*),
SA.UnsafeAdd(),
counter,
_term(SignChange(_sign(v), 1), SA.basis(poly)[mono]),
)
Expand Down
16 changes: 2 additions & 14 deletions src/gram_matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function MP.similar_type(
return GramMatrix{S,B,US,MS}
end

SA.basis(g::GramMatrix) = g.basis
MB.implicit_basis(g::GramMatrix) = MB.implicit_basis(g.basis)

# When taking the promotion of a GramMatrix of JuMP.Variable with a Polynomial JuMP.Variable, it should be a Polynomial of AffExpr
Expand Down Expand Up @@ -193,20 +194,7 @@ function MA.operate!(
g::GramMatrix,
args::Vararg{Any,N},
) where {N}
for row in eachindex(g.basis)
row_star = SA.star(g.basis[row])
for col in eachindex(g.basis)
_gram_operate!(
op,
p,
g.Q[row, col],
row_star,
g.basis[col],
args...,
)
end
end
return p
return MA.operate!(op, p, SA.QuadraticForm(g), args...)
end

"""
Expand Down
Loading