Skip to content

Commit d211700

Browse files
authored
Update for MP renamings (#35)
* Update for MP renamings * Add stdlib packages
1 parent c465e4d commit d211700

File tree

16 files changed

+67
-48
lines changed

16 files changed

+67
-48
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
os: ubuntu-latest
2828
arch: x64
2929
steps:
30-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v3
3131
- uses: julia-actions/setup-julia@v1
3232
with:
3333
version: ${{ matrix.version }}
@@ -42,26 +42,20 @@ jobs:
4242
${{ runner.os }}-test-${{ env.cache-name }}-
4343
${{ runner.os }}-test-
4444
${{ runner.os }}-
45-
- name: MultivariatePolynomials#master
45+
- name: dev
4646
shell: julia --project=@. {0}
4747
run: |
4848
using Pkg
49-
Pkg.add(PackageSpec(name="MultivariatePolynomials", rev="master"))
50-
- name: DynamicPolynomials#master
51-
shell: julia --project=@. {0}
52-
run: |
53-
using Pkg
54-
Pkg.add(PackageSpec(name="DynamicPolynomials", rev="master"))
55-
- name: TypedPolynomials#master
56-
shell: julia --project=@. {0}
57-
run: |
58-
using Pkg
59-
Pkg.add(PackageSpec(name="TypedPolynomials", rev="master"))
49+
Pkg.add([
50+
PackageSpec(name="MultivariatePolynomials", rev="master"),
51+
PackageSpec(name="TypedPolynomials", rev="master"),
52+
PackageSpec(name="DynamicPolynomials", rev="master"),
53+
])
6054
- uses: julia-actions/julia-buildpkg@v1
6155
- uses: julia-actions/julia-runtest@v1
6256
with:
6357
depwarn: error
6458
- uses: julia-actions/julia-processcoverage@v1
65-
- uses: codecov/codecov-action@v1
59+
- uses: codecov/codecov-action@v3
6660
with:
6761
file: lcov.info

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ Manifest.toml
22
*.jl.cov
33
*.jl.*.cov
44
*.jl.mem
5+
.vscode

src/SemialgebraicSets.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ function Base.show(io::IO, ::FullSpace)
2828
end
2929
nequalities(::FullSpace) = 0
3030
equalities(::FullSpace) = []
31-
MP.changecoefficienttype(S::Type{FullSpace}, T::Type) = S
31+
MP.similar_type(S::Type{FullSpace}, T::Type) = S
3232

33-
function MP.changecoefficienttype(set::AbstractSemialgebraicSet, T::Type)
34-
return convert(MP.changecoefficienttype(typeof(set), T), set)
33+
function Base.similar(set::AbstractSemialgebraicSet, T::Type)
34+
return convert(MP.similar_type(typeof(set), T), set)
3535
end
3636

3737
Base.intersect(S::AbstractAlgebraicSet, T::FullSpace) = S

src/basic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function basicsemialgebraicset(V, p)
2020
BasicSemialgebraicSet(V, p)
2121
end
2222

23-
MP.changecoefficienttype(::Type{BasicSemialgebraicSet{S, PS, AT}}, T::Type) where {S, PS, AT} = BasicSemialgebraicSet{T, MP.changecoefficienttype(PS, T), MP.changecoefficienttype(AT, T)}
23+
MP.similar_type(::Type{BasicSemialgebraicSet{S, PS, AT}}, T::Type) where {S, PS, AT} = BasicSemialgebraicSet{T, MP.similar_type(PS, T), MP.similar_type(AT, T)}
2424

2525
function Base.convert(::Type{BasicSemialgebraicSet{T, PT, AT}}, set::BasicSemialgebraicSet) where {T, PT, AT}
2626
return BasicSemialgebraicSet{T, PT, AT}(set.V, set.p)

src/fix.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ end
3737
struct FixedVariablesSet{V, T, MT} <: AbstractAlgebraicSet
3838
ideal::FixedVariablesIdeal{V, T, MT}
3939
end
40-
MP.changecoefficienttype(::Type{FixedVariablesSet{V, S, MT}}, T::Type) where {V, S, MT} = FixedVariablesSet{V, T, MT}
40+
MP.similar_type(::Type{FixedVariablesSet{V, S, MT}}, T::Type) where {V, S, MT} = FixedVariablesSet{V, T, MT}
4141
function Base.convert(::Type{FixedVariablesSet{V, T, MT}}, set::FixedVariablesSet{V, T, MT}) where {V, T, MT}
4242
return set
4343
end
@@ -56,7 +56,7 @@ function nequalities(set::FixedVariablesSet)
5656
end
5757
function equalities(set::FixedVariablesSet{V, T, MT}) where {V, T, MT}
5858
if set.ideal.substitutions === nothing
59-
return [constantterm(one(T), MT)]
59+
return [constant_term(one(T), MT)]
6060
else
6161
return [key - value for (key, value) in set.ideal.substitutions]
6262
end

src/groebner.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ S(p, q) = \\frac{m}{\\mathrm{\\mathsc{LT}}(p)} \\cdot p - \\frac{m}{\\mathrm{\\
1111
where ``m = \\mathrm{lcm}(\\mathrm{\\mathsc{LM}}(p), \\mathrm{\\mathsc{LM}}(q))``.
1212
"""
1313
function spolynomial(p::APL, q::APL)
14-
m = lcm(leadingmonomial(p), leadingmonomial(q))
15-
ltp = leadingterm(p)
14+
m = lcm(leading_monomial(p), leading_monomial(q))
15+
ltp = leading_term(p)
1616
# `MA.operate` ensures that the returned value can be mutated without
1717
# affecting either `a` or `p`.
1818
a = MA.operate(*, MP.div_multiple(m, monomial(ltp)), p)
1919
ad = MA.operate!!(/, a, MP.coefficient(ltp))
20-
ltq = leadingterm(q)
20+
ltq = leading_term(q)
2121
b = MA.operate(*, MP.div_multiple(m, monomial(ltq)), q)
2222
bd = MA.operate!!(/, b, MP.coefficient(ltq))
2323
return MA.operate!!(-, ad, bd)
@@ -36,7 +36,7 @@ function reducebasis!(F::AbstractVector{<:APL}; kwargs...)
3636
deleteat!(keep, findfirst(isequal(j), keep))
3737
push!(del, j)
3838
changed = true # Should probably not set that, no need to do one more loop int this case
39-
elseif leadingmonomial(r) != leadingmonomial(F[j])
39+
elseif leading_monomial(r) != leading_monomial(F[j])
4040
F[j] = r
4141
changed = true
4242
end
@@ -47,14 +47,14 @@ end
4747

4848
ext(i, j) = (min(i, j), max(i, j))
4949

50-
lcmlm(F, i, j) = lcm(leadingmonomial(F[i]), leadingmonomial(F[j]))
50+
lcmlm(F, i, j) = lcm(leading_monomial(F[i]), leading_monomial(F[j]))
5151

5252
function criterion(F, B, i, j)
5353
m = lcmlm(F, i, j)
5454
for k in eachindex(F)
5555
if k != i && k != j &&
5656
!(ext(i, k) in B) && !(ext(j, k) in B) &&
57-
divides(leadingmonomial(F[k]), m)
57+
divides(leading_monomial(F[k]), m)
5858
return true
5959
end
6060
end
@@ -71,7 +71,7 @@ end
7171
# Ideals, Varieties, and Algorithms
7272
# Cox, Little and O'Shea, Fourth edition p. 116
7373
function presort!(F)
74-
sort!(F, by=leadingmonomial)
74+
sort!(F, by=leading_monomial)
7575
end
7676

7777
# Selection of (i, j) ∈ B
@@ -122,8 +122,8 @@ function gröbnerbasis!(F::AbstractVector{<:APL}, algo=defaultgröbnerbasisalgor
122122
B = Set{NTuple{2, Int}}(Iterators.filter(t -> t[1] < t[2], (i, j) for i in eachindex(F), j in eachindex(F)))
123123
while !isempty(B)
124124
(i, j) = algo.sel(F, B)
125-
lmi = leadingmonomial(F[i])
126-
lmj = leadingmonomial(F[j])
125+
lmi = leading_monomial(F[i])
126+
lmj = leading_monomial(F[j])
127127
if !isconstant(gcd(lmi, lmj)) && !criterion(F, B, i, j)
128128
#r = rem(spolynomial(F[i], F[j]), F; ztol=algo.ztol)
129129
r = rem(spolynomial(F[i], F[j]), F)

src/ideal.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function PolynomialIdeal{T, PT}(p::Vector{PT}, algo::A) where {T, PT<:APL{T}, A<
2323
end
2424
function PolynomialIdeal(p::Vector{PT}, algo) where {T, PT<:APL{T}}
2525
S = promote_for_division(T)
26-
PolynomialIdeal{S, polynomialtype(PT, S)}(AbstractVector{polynomialtype(PT, S)}(p), algo)
26+
PolynomialIdeal{S, polynomial_type(PT, S)}(AbstractVector{polynomial_type(PT, S)}(p), algo)
2727
end
2828
function PolynomialIdeal{T, PT}() where {T, PT<:APL{T}}
2929
PolynomialIdeal(PT[], defaultgröbnerbasisalgorithm(PT))
@@ -57,10 +57,10 @@ end
5757
function monomialbasis(I, vars=variables(I))
5858
computegröbnerbasis!(I)
5959
if isempty(I.p)
60-
return false, monomialtype(eltype(I.p))[]
60+
return false, monomial_type(eltype(I.p))[]
6161
end
62-
mv = monovec(leadingmonomial.(I.p))
63-
# monovec makes sure all monomials have the same variables
62+
mv = monomial_vector(leading_monomial.(I.p))
63+
# monomial_vector makes sure all monomials have the same variables
6464
# if x_i^n is in the leading monomials, lv[i] <= n
6565
lv = -ones(Int, length(vars))
6666
for m in mv
@@ -75,7 +75,7 @@ function monomialbasis(I, vars=variables(I))
7575
end
7676
end
7777
if any(lv .< 0)
78-
return false, monomialtype(eltype(I.p))[]
78+
return false, monomial_type(eltype(I.p))[]
7979
end
8080
return true, monomials(vars, 0:(sum(lv)-1), m -> !any(map(m2 -> divides(m2, m), mv)))
8181
end

src/solve.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ function _solvemultiplicationmatrices(Ms::AbstractVector{<:AbstractMatrix{T}},
110110
@assert length(Ms) == length(λ)
111111
n = length(λ)
112112
Z, clusters = clusterordschur(sum.* Ms), solver.ɛ)
113+
for i in 1:n
114+
display(Z' * Ms[i] * Z)
115+
end
113116
r = length(clusters)
114117
vals = [zeros(T, n) for k in 1:r]
115118
for k in 1:r

src/variety.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ AlgebraicSet(I::PolynomialIdeal{T, PT, A}, solver::S) where {T, PT, A, S} = Alge
2121
AlgebraicSet{T, PT}() where {T, PT} = AlgebraicSet(PolynomialIdeal{T, PT}(), defaultalgebraicsolver(T))
2222
AlgebraicSet(p::Vector, algo::AbstractGröbnerBasisAlgorithm, solver) = AlgebraicSet(ideal(p, algo), solver)
2323

24-
MP.changecoefficienttype(::Type{AlgebraicSet{U, PU, A, S, UU}}, T::Type) where {U, PU, A, S, UU} = AlgebraicSet{T, MP.changecoefficienttype(PU, T), A, S, float(T)}
24+
MP.similar_type(::Type{AlgebraicSet{U, PU, A, S, UU}}, T::Type) where {U, PU, A, S, UU} = AlgebraicSet{T, MP.similar_type(PU, T), A, S, float(T)}
2525
function Base.convert(::Type{AlgebraicSet{T, PT, A, S, U}}, set::AlgebraicSet{T, PT, A, S, U}) where {T, PT<:APL{T}, A, S<:AbstractAlgebraicSolver, U}
2626
return set
2727
end

test/Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[deps]
2+
DynamicPolynomials = "7c1d4256-1411-5781-91ec-d7bc3513ac07"
3+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
4+
MultivariatePolynomials = "102ac46a-7ee4-5c85-9060-abc95bfdeaa3"
5+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
6+
SemialgebraicSets = "8e049039-38e8-557d-ae3a-bc521ccf6204"
7+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

0 commit comments

Comments
 (0)