Skip to content

Commit 8df043d

Browse files
committed
refactor code
1 parent 38ba596 commit 8df043d

13 files changed

Lines changed: 142 additions & 254 deletions

.github/workflows/TagBot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
workflow_dispatch:
77
inputs:
88
lookback:
9-
default: 3
9+
default: "3"
1010
permissions:
1111
actions: read
1212
checks: read

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Viktor Korotynskiy <korotynskiy.viktor@gmail.com> and contributors
3+
Copyright (c) 2026 Viktor Korotynskiy <korotynskiy.viktor@gmail.com> and contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/DecomposingPolynomialSystems.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,20 @@ module DecomposingPolynomialSystems
33
import HomotopyContinuation
44
const HC = HomotopyContinuation
55
using HomotopyContinuation.ModelKit
6-
export @var, Variable, Expression, System
6+
export @var, Variable, Expression, subs
77

88
using SparseArrays: SparseVector, SparseMatrixCSC, spzeros, AbstractSparseVector, findnz, sparse
99
using Combinatorics: partitions, multiset_permutations, combinations
10-
using LinearAlgebra: nullspace
10+
using LinearAlgebra: nullspace, I, det
11+
export det
1112
using UnPack: @unpack
1213

1314
include("utils.jl")
14-
include("sampled_system.jl")
15+
include("param_system.jl")
16+
include("sampling/sampled_system.jl")
1517
include("monomials.jl")
16-
# include("expression_map.jl")
1718
include("scalings.jl")
1819
include("interpolation.jl")
1920
include("deck_transformations.jl")
20-
# include("invariants.jl")
21-
# include("implicitization.jl")
22-
# include("decompose.jl")
23-
2421

2522
end # module

src/deck_transformations.jl

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ A `DeckTransformationGroup` is the result of deck transformations computation.
5353
struct DeckTransformationGroup
5454
maps::Vector{DeckTransformation}
5555
group::GapObj
56-
F::SampledSystem
56+
F::SampledParametricSystem
5757
end
5858

59-
function DeckTransformationGroup(F::SampledSystem)
59+
function DeckTransformationGroup(F::SampledParametricSystem)
6060
symmetries = _init_symmetries(length(deck_permutations(F)), unknowns(F))
6161
return DeckTransformationGroup(symmetries, F)
6262
end
6363

6464
function DeckTransformationGroup(
6565
symmetries::Vector{Vector{MiExpression}},
66-
F::SampledSystem
66+
F::SampledParametricSystem
6767
)
6868
action = [DeckTransformation(symmetry, unknowns(F), parameters(F)) for symmetry in symmetries]
6969
return DeckTransformationGroup(action, to_group(deck_permutations(F)), F)
@@ -386,7 +386,7 @@ end
386386
# end
387387

388388
function _sample_for_deck_computation(
389-
F::SampledSystem;
389+
F::SampledParametricSystem;
390390
n_instances::Int
391391
)
392392
Δ_ninstances = n_instances - ninstances(F)
@@ -396,7 +396,7 @@ function _sample_for_deck_computation(
396396
end
397397

398398
function symmetries_fixing_parameters_graded!(
399-
F::SampledSystem,
399+
F::SampledParametricSystem,
400400
grading::Grading;
401401
degree_bound::Integer=1,
402402
param_dep::Bool=true,
@@ -477,7 +477,7 @@ function symmetries_fixing_parameters_graded!(
477477
end
478478

479479
function symmetries_fixing_parameters_dense!(
480-
F::SampledSystem;
480+
F::SampledParametricSystem;
481481
degree_bound::Integer=1,
482482
param_dep::Bool=true,
483483
tols::Tolerances=Tolerances(),
@@ -546,7 +546,7 @@ to_CC(scaling::Tuple{Tv, SparseVector{Tv,Ti}}) where {Tv<:Integer,Ti<:Integer} =
546546
function _deck_action(
547547
deck_permutation::Vector{Int},
548548
(x₀, p₀)::NTuple{2, AbstractVector{<:Number}},
549-
F::SampledSystem;
549+
F::SampledParametricSystem;
550550
tol::Real=1e-5
551551
)
552552
sols, params = all_solutions_samples(F).solutions, all_solutions_samples(F).parameters
@@ -565,7 +565,7 @@ end
565565
function _deck_commutes_with_scaling(
566566
deck_permutation::Vector{Int},
567567
scaling::Tuple{Tv, SparseVector{Tv,Ti}},
568-
F::SampledSystem;
568+
F::SampledParametricSystem;
569569
tol::Real=1e-5
570570
) where {Tv<:Integer,Ti<:Integer}
571571

@@ -584,7 +584,7 @@ function _deck_commutes_with_scaling(
584584
end
585585

586586
function _all_deck_commute(
587-
F::SampledSystem,
587+
F::SampledParametricSystem,
588588
scaling::Tuple{Tv, SparseVector{Tv, Ti}};
589589
tol::Real=1e-5
590590
) where {Tv<:Integer,Ti<:Integer}
@@ -597,10 +597,13 @@ function _all_deck_commute(
597597
return true
598598
end
599599

600-
function _scalings_commuting_with_deck(F::SampledSystem, scalings::ScalingGroup)
601-
grading = scalings.grading
602-
final_grading = Grading{Int8, Int16}(nfree(grading), grading.free_part, [])
603-
for (sᵢ, Uᵢ) in grading.mod_part
600+
function _scalings_commuting_with_deck(F::SampledParametricSystem, scalings::ScalingGroup)
601+
if isempty(grading(scalings))
602+
return scalings
603+
end
604+
grding = scalings.grading
605+
final_grading = Grading{Int8, Int16}(nfree(grding), grding.free_part, [])
606+
for (sᵢ, Uᵢ) in grding.mod_part
604607
Vᵢ = Array{Int}(undef, 0, size(Uᵢ, 2))
605608
# TODO: Uᵢ ↦ all linear combinations of rows of Uᵢ (might not commute with 2 gens, but commutes with their combination)
606609
for j in axes(Uᵢ, 1)
@@ -616,7 +619,7 @@ function _scalings_commuting_with_deck(F::SampledSystem, scalings::ScalingGroup)
616619
end
617620

618621
function symmetries_fixing_parameters!(
619-
F::SampledSystem;
622+
F::SampledParametricSystem;
620623
degree_bound::Integer=1,
621624
param_dep::Bool=true,
622625
tols::Tolerances=Tolerances(),
@@ -627,7 +630,8 @@ function symmetries_fixing_parameters!(
627630
return DeckTransformationGroup(F)
628631
end
629632

630-
scalings = _scalings_commuting_with_deck(F, scaling_symmetries(F))
633+
scalings = scaling_symmetries(F)
634+
scalings = _scalings_commuting_with_deck(F, scalings)
631635
# scalings = param_dep ? scalings : restrict_scalings(scalings, unknowns(F)) # TODO: justify!
632636
if isempty(grading(scalings))
633637
logging && printstyled("Running dense version...\n", color=:green)
@@ -726,7 +730,7 @@ function reduced_nullspace(A::AbstractMatrix{<:Number}; tols::Tolerances=Toleran
726730
end
727731

728732
function deck_vandermonde_dense(
729-
F::SampledSystem;
733+
F::SampledParametricSystem;
730734
deck_id::Int,
731735
var::Variable,
732736
degree::Integer=1,
@@ -765,7 +769,7 @@ function to_multiexponent(mon::Expression, vars::Vector{Variable})
765769
end
766770

767771
function deck_vandermonde_graded(
768-
F::SampledSystem,
772+
F::SampledParametricSystem,
769773
grading::Grading;
770774
deck_id::Int,
771775
var::Variable,

src/decompose.jl

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/expression_map.jl

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/interpolation.jl

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -287,61 +287,3 @@ function interpolate(
287287
error("Not supported method '", method, "' for interpolation")
288288
end
289289
end
290-
291-
292-
293-
294-
295-
296-
297-
#----------- SPARSE INTERPOLATION TESTING -------------
298-
299-
function inv_chinese(d::Int, p::Vector{Int})
300-
n = length(p)
301-
m = prod(p)
302-
D = zeros(Int, n)
303-
for i in 1:n
304-
D[i] = mod(d*invmod(Int(m/p[i]), p[i]), p[i])
305-
end
306-
return D
307-
end
308-
309-
function companion_matrix::Vector{CC})::Matrix{CC}
310-
d = length(λ)
311-
return [[zeros(1,d-1); eye(d-1)] -λ]
312-
end
313-
314-
function f(x, y)
315-
return x^20*y + 2*x^2 + 3*x + 4*y^11 + 5
316-
end
317-
318-
function interpolate_sparse()
319-
320-
end
321-
322-
# t = 5 # number of terms in f
323-
# p₁, p₂ = 139, 193 # pᵢ > deg(fₓᵢ)
324-
# m = p₁*p₂
325-
# ω₁, ω₂ = cispi(2/p₁), cispi(2/p₂) # pᵢ-th roots of unity
326-
# ω = cispi(2/m)
327-
328-
# α = [f(ω₁^s, ω₂^s) for s in 0:2*t-1]
329-
330-
# H₀ = VV2M([[α[j] for j in i:i+t-1] for i in 1:t])
331-
# h = -[α[i] for i in t+1:2*t]
332-
# Hh = [H₀ -h]
333-
# N = nullspace(Hh)
334-
# λ = M2V(p2a(N))
335-
336-
# M = companion_matrix(λ)
337-
# b = eigvals(M)
338-
339-
# d = [mod(Int(round(log(ω, b[i]))), m) for i in 1:length(b)]
340-
# e = [inv_chinese(d[i], [p₁, p₂]) for i in 1:length(d)]
341-
342-
# B = [transpose(VV2M([b.^i for i in 0:t-1])) -α[1:t]]
343-
# N = nullspace(B)
344-
# c = round.(M2V(p2a(N)))
345-
346-
# @var x y
347-
# f_approx = dot(c, [prod([x,y].^e[i]) for i in 1:length(e)])

0 commit comments

Comments
 (0)