From 79e433bd8bf9a6387eb5f8356406ee7e00295678 Mon Sep 17 00:00:00 2001 From: pogudingleb Date: Sat, 24 Feb 2024 00:37:55 +0100 Subject: [PATCH] updating to the newest AA and Nemo --- ext/ModelingToolkitSIExt.jl | 2 +- src/ODE.jl | 28 +++++++++---------- src/RationalFunctionFields/IdealMQS.jl | 6 ++-- .../RationalFunctionField.jl | 6 ++-- src/RationalFunctionFields/normalforms.jl | 4 +-- src/RationalFunctionFields/util.jl | 2 +- src/StructuralIdentifiability.jl | 4 ++- src/discrete.jl | 4 +-- src/global_identifiability.jl | 4 +-- src/identifiable_functions.jl | 4 +-- src/input_macro.jl | 6 ++-- src/io_equation.jl | 2 +- src/known_ic.jl | 8 +++--- src/lincomp.jl | 11 +++----- src/local_identifiability.jl | 4 ++- src/parametrizations.jl | 21 ++++++++------ src/states.jl | 6 ++-- src/submodels.jl | 2 +- src/util.jl | 20 ++++++------- src/wronskian.jl | 2 +- test/check_algebraicity.jl | 2 +- test/differentiate_output.jl | 4 +-- test/identifiable_functions.jl | 3 +- test/local_identifiability_me.jl | 10 ++++--- test/ode_ps_solution.jl | 2 +- test/parent_ring_change.jl | 6 ++-- 26 files changed, 91 insertions(+), 82 deletions(-) diff --git a/ext/ModelingToolkitSIExt.jl b/ext/ModelingToolkitSIExt.jl index 65af94c9e..35786217e 100644 --- a/ext/ModelingToolkitSIExt.jl +++ b/ext/ModelingToolkitSIExt.jl @@ -165,7 +165,7 @@ function __mtk_to_si( measured_quantities::Array{<:Tuple{String, <:SymbolicUtils.BasicSymbolic}}, ) polytype = StructuralIdentifiability.Nemo.QQMPolyRingElem - fractype = StructuralIdentifiability.Nemo.Generic.Frac{polytype} + fractype = StructuralIdentifiability.Nemo.Generic.FracFieldElem{polytype} diff_eqs = filter(eq -> !(ModelingToolkit.isoutput(eq.lhs)), ModelingToolkit.equations(de)) # performing full structural simplification diff --git a/src/ODE.jl b/src/ODE.jl index addf9f933..36301d5a1 100644 --- a/src/ODE.jl +++ b/src/ODE.jl @@ -11,14 +11,14 @@ struct ODE{P} # P is the type of polynomials in the rhs of the ODE system y_vars::Array{P, 1} u_vars::Array{P, 1} parameters::Array{P, 1} - x_equations::Dict{P, <:Union{P, Generic.Frac{P}}} - y_equations::Dict{P, <:Union{P, Generic.Frac{P}}} + x_equations::Dict{P, <:ExtendedFraction{P}} + y_equations::Dict{P, <:ExtendedFraction{P}} function ODE{P}( x_vars::Array{P, 1}, y_vars::Array{P, 1}, - x_eqs::Dict{P, <:Union{P, Generic.Frac{P}}}, - y_eqs::Dict{P, <:Union{P, Generic.Frac{P}}}, + x_eqs::Dict{P, <:ExtendedFraction{P}}, + y_eqs::Dict{P, <:ExtendedFraction{P}}, inputs::Array{P, 1}, ) where {P <: MPolyRingElem{<:FieldElem}} # Initialize ODE @@ -37,8 +37,8 @@ struct ODE{P} # P is the type of polynomials in the rhs of the ODE system end function ODE{P}( - x_eqs::Dict{P, <:Union{P, Generic.Frac{P}}}, - y_eqs::Dict{P, <:Union{P, Generic.Frac{P}}}, + x_eqs::Dict{P, <:ExtendedFraction{P}}, + y_eqs::Dict{P, <:ExtendedFraction{P}}, inputs::Array{P, 1}, ) where {P <: MPolyRingElem{<:FieldElem}} x_vars = collect(keys(x_eqs)) @@ -62,7 +62,7 @@ function add_outputs( new_ring, new_vars = Nemo.polynomial_ring(base_ring(ode.poly_ring), new_var_names) new_x = Array{P, 1}([parent_ring_change(x, new_ring) for x in ode.x_vars]) - new_x_eqs = Dict{P, Union{P, Generic.Frac{P}}}( + new_x_eqs = Dict{P, ExtendedFraction{P}}( parent_ring_change(x, new_ring) => parent_ring_change(f, new_ring) for (x, f) in ode.x_equations ) @@ -70,11 +70,11 @@ function add_outputs( for y in keys(extra_y) push!(new_y, str_to_var(y, new_ring)) end - new_y_eqs = Dict{P, Union{P, Generic.Frac{P}}}( + new_y_eqs = Dict{P, ExtendedFraction{P}}( parent_ring_change(y, new_ring) => parent_ring_change(g, new_ring) for (y, g) in ode.y_equations ) - extra_y_eqs = Dict{P, Union{P, Generic.Frac{P}}}( + extra_y_eqs = Dict{P, ExtendedFraction{P}}( str_to_var(y, new_ring) => parent_ring_change(g, new_ring) for (y, g) in extra_y ) merge!(new_y_eqs, extra_y_eqs) @@ -106,11 +106,11 @@ function set_parameter_values( merge!(eval_dict, Dict(p => small_ring(val) for (p, val) in param_values)) return ODE{P}( - Dict{P, Union{P, Generic.Frac{P}}}( + Dict{P, ExtendedFraction{P}}( eval_at_dict(v, eval_dict) => eval_at_dict(f, eval_dict) for (v, f) in ode.x_equations ), - Dict{P, Union{P, Generic.Frac{P}}}( + Dict{P, ExtendedFraction{P}}( eval_at_dict(v, eval_dict) => eval_at_dict(f, eval_dict) for (v, f) in ode.y_equations ), @@ -225,7 +225,7 @@ function _reduce_mod_p(poly::QQMPolyRingElem, p::Int) return change_base_ring(Nemo.Native.GF(p), num) * (1 // Nemo.Native.GF(p)(den)) end -function _reduce_mod_p(rat::Generic.Frac{QQMPolyRingElem}, p::Int) +function _reduce_mod_p(rat::Generic.FracFieldElem{QQMPolyRingElem}, p::Int) num, den = map(poly -> _reduce_mod_p(poly, p), [numerator(rat), denominator(rat)]) if den == 0 throw(Base.ArgumentError("Prime $p divides the denominator of $rat")) @@ -248,8 +248,8 @@ function reduce_ode_mod_p(ode::ODE{<:MPolyRingElem{Nemo.QQFieldElem}}, p::Int) new_inputs = map(u -> switch_ring(u, new_ring), ode.u_vars) new_x = map(x -> switch_ring(x, new_ring), ode.x_vars) new_y = map(y -> switch_ring(y, new_ring), ode.y_vars) - new_x_eqs = Dict{new_type, Union{new_type, Generic.Frac{new_type}}}() - new_y_eqs = Dict{new_type, Union{new_type, Generic.Frac{new_type}}}() + new_x_eqs = Dict{new_type, ExtendedFraction{new_type}}() + new_y_eqs = Dict{new_type, ExtendedFraction{new_type}}() for (old, new) in Dict(ode.x_equations => new_x_eqs, ode.y_equations => new_y_eqs) for (v, f) in old new_v = switch_ring(v, new_ring) diff --git a/src/RationalFunctionFields/IdealMQS.jl b/src/RationalFunctionFields/IdealMQS.jl index 95b9fa060..dd767c2b6 100644 --- a/src/RationalFunctionFields/IdealMQS.jl +++ b/src/RationalFunctionFields/IdealMQS.jl @@ -100,7 +100,7 @@ mutable struct IdealMQS{T} <: AbstractBlackboxIdeal end varnames = append_at_index(ystrs, sat_var_index, sat_varname) @debug "Saturating variable is $sat_varname, index is $sat_var_index" - R_sat, v_sat = Nemo.polynomial_ring(K, varnames, ordering = ordering) + R_sat, v_sat = Nemo.polynomial_ring(K, varnames, internal_ordering = ordering) # Saturation t_sat = v_sat[sat_var_index] den_lcm_orig = den_lcm @@ -144,7 +144,7 @@ mutable struct IdealMQS{T} <: AbstractBlackboxIdeal push!(nums_qq, num) end end - parent_ring_param, _ = polynomial_ring(ring, varnames, ordering = ordering) + parent_ring_param, _ = polynomial_ring(ring, varnames, internal_ordering = ordering) @debug "Constructed MQS ideal in $R_sat with $(length(nums_qq) + 1) elements" @assert length(pivots_indices) == length(dens_indices) == length(dens_qq) @assert length(pivots_indices) == length(funcs_den_nums) @@ -202,7 +202,7 @@ function fractionfree_generators_raw(mqs::IdealMQS) end # NOTE: new variables go first! big_ring, big_vars = - polynomial_ring(K, vcat(new_varnames, old_varnames), ordering = :lex) + polynomial_ring(K, vcat(new_varnames, old_varnames), internal_ordering = :lex) @info "$(mqs.sat_var_index) $(varnames) $ring_params $(parent(mqs.sat_qq))" nums_qq, dens_qq, sat_qq = mqs.nums_qq, mqs.dens_qq, mqs.sat_qq nums_y = map(num -> parent_ring_change(num, big_ring, matching = :byindex), nums_qq) diff --git a/src/RationalFunctionFields/RationalFunctionField.jl b/src/RationalFunctionFields/RationalFunctionField.jl index f2583d9cd..739f793da 100644 --- a/src/RationalFunctionFields/RationalFunctionField.jl +++ b/src/RationalFunctionFields/RationalFunctionField.jl @@ -26,7 +26,7 @@ mutable struct RationalFunctionField{T} function RationalFunctionField(polys::Vector{T}) where {T} RationalFunctionField(polys .// one(parent(first(polys)))) end - function RationalFunctionField(fractions::Vector{Generic.Frac{T}}) where {T} + function RationalFunctionField(fractions::Vector{Generic.FracFieldElem{T}}) where {T} RationalFunctionField(fractions_to_dennums(fractions)) end function RationalFunctionField(dennums::Vector{Vector{T}}) where {T} @@ -156,7 +156,7 @@ end function field_contains( field::RationalFunctionField{T}, - ratfuncs::Vector{Generic.Frac{T}}, + ratfuncs::Vector{Generic.FracFieldElem{T}}, prob_threshold, ) where {T} return field_contains(field, fractions_to_dennums(ratfuncs), prob_threshold) @@ -200,7 +200,7 @@ function check_algebraicity(field, ratfuncs, p) eval_point = [Nemo.QQ(rand(1:D)) for x in base_vars] # Filling the jacobain for generators - S = MatrixSpace(Nemo.QQ, length(base_vars), length(fgens) + 1) + S = matrix_space(Nemo.QQ, length(base_vars), length(fgens) + 1) J = zero(S) for (i, f) in enumerate(fgens) for (j, x) in enumerate(base_vars) diff --git a/src/RationalFunctionFields/normalforms.jl b/src/RationalFunctionFields/normalforms.jl index 77b8dce58..ab2b98b5a 100644 --- a/src/RationalFunctionFields/normalforms.jl +++ b/src/RationalFunctionFields/normalforms.jl @@ -291,7 +291,7 @@ Note: uses Monte-Carlo probabilistic algorithm. The probability of correctness is not specified but is assumed to be close to 1. """ @timeit _to function linear_relations_between_normal_forms( - fracs::Vector{Generic.Frac{T}}, + fracs::Vector{Generic.FracFieldElem{T}}, up_to_degree::Integer; seed = 42, ) where {T} @@ -391,7 +391,7 @@ is not specified but is assumed to be close to 1. end union!(complete_intersection_relations_ff, relations_ff_1) @debug "Reconstructing relations to rationals" - relations_qq = Vector{Generic.Frac{elem_type(ring_param)}}( + relations_qq = Vector{Generic.FracFieldElem{elem_type(ring_param)}}( undef, length(complete_intersection_relations_ff), ) diff --git a/src/RationalFunctionFields/util.jl b/src/RationalFunctionFields/util.jl index 1183ddc6b..b1d7b0f5b 100644 --- a/src/RationalFunctionFields/util.jl +++ b/src/RationalFunctionFields/util.jl @@ -11,7 +11,7 @@ Output: an array of fractions `[f2/f1, f3/f1, ..., g2/g1, g3/g1, ...]` """ function dennums_to_fractions(dennums::Vector{Vector{T}}) where {T} - fractions = Vector{AbstractAlgebra.Generic.Frac{T}}() + fractions = Vector{AbstractAlgebra.Generic.FracFieldElem{T}}() for dni in dennums den, nums = dni[1], dni[2:end] isempty(nums) && continue diff --git a/src/StructuralIdentifiability.jl b/src/StructuralIdentifiability.jl index 1b709a60b..38172eaaf 100644 --- a/src/StructuralIdentifiability.jl +++ b/src/StructuralIdentifiability.jl @@ -47,6 +47,8 @@ export find_submodels # finding identifiabile reparametrizations export reparametrize_global +ExtendedFraction{P} = Union{P, Generic.FracFieldElem{P}} + include("logging.jl") include("util.jl") include("power_series_utils.jl") @@ -102,7 +104,7 @@ The function returns an (ordered) dictionary from the functions to check to thei function assess_identifiability( ode::ODE{P}; funcs_to_check = Vector(), - known_ic::Vector{<:Union{P, Generic.Frac{P}}} = Vector{Union{P, Generic.Frac{P}}}(), + known_ic::Vector{<:ExtendedFraction{P}} = Vector{ExtendedFraction{P}}(), prob_threshold::Float64 = 0.99, loglevel = Logging.Info, ) where {P <: MPolyRingElem{QQFieldElem}} diff --git a/src/discrete.jl b/src/discrete.jl index 45bbe0c58..5cfc7b478 100644 --- a/src/discrete.jl +++ b/src/discrete.jl @@ -10,8 +10,8 @@ struct DDS{P} # P is the type of polynomials in the rhs of the DDS system function DDS{P}( x_vars::Array{P, 1}, y_vars::Array{P, 1}, - x_eqs::Dict{P, <:Union{P, Generic.Frac{P}}}, - y_eqs::Dict{P, <:Union{P, Generic.Frac{P}}}, + x_eqs::Dict{P, <:ExtendedFraction{P}}, + y_eqs::Dict{P, <:ExtendedFraction{P}}, u_vars::Array{P, 1}, ) where {P <: MPolyRingElem{<:FieldElem}} new{P}(ODE{P}(x_vars, y_vars, x_eqs, y_eqs, u_vars)) diff --git a/src/global_identifiability.jl b/src/global_identifiability.jl index 87060fd9d..39d00b36b 100644 --- a/src/global_identifiability.jl +++ b/src/global_identifiability.jl @@ -148,7 +148,7 @@ The function returns a tuple containing the following: param_ring, _ = polynomial_ring( base_ring(bring), map(string, ode.parameters), - ordering = Nemo.ordering(bring), + internal_ordering = Nemo.internal_ordering(bring), ) id_funcs_no_states_param = map( polys -> map(poly -> parent_ring_change(poly, param_ring), polys), @@ -218,7 +218,7 @@ Output: a list L of booleans with L[i] being the identifiability status of the i with_states = states_needed, ) - funcs_to_check = Vector{Generic.Frac{P}}( + funcs_to_check = Vector{Generic.FracFieldElem{P}}( map(f -> parent_ring_change(f, bring) // one(bring), funcs_to_check), ) diff --git a/src/identifiable_functions.jl b/src/identifiable_functions.jl index 743c7fba5..fedcaf1f7 100644 --- a/src/identifiable_functions.jl +++ b/src/identifiable_functions.jl @@ -40,7 +40,7 @@ ode = @ODEmodel( find_identifiable_functions(ode) # prints -3-element Vector{AbstractAlgebra.Generic.Frac{Nemo.QQMPolyRingElem}}: +3-element Vector{AbstractAlgebra.Generic.FracFieldElem{Nemo.QQMPolyRingElem}}: a12 + a01 + a21 a12*a01 ``` @@ -48,7 +48,7 @@ find_identifiable_functions(ode) """ function find_identifiable_functions( ode::ODE{T}; - known_ic::Vector{<:Union{T, Generic.Frac{T}}} = Vector{Union{T, Generic.Frac{T}}}(), + known_ic::Vector{<:ExtendedFraction{T}} = Vector{ExtendedFraction{T}}(), prob_threshold::Float64 = 0.99, seed = 42, with_states = false, diff --git a/src/input_macro.jl b/src/input_macro.jl index a4c8a6f1c..95c44b7d4 100644 --- a/src/input_macro.jl +++ b/src/input_macro.jl @@ -136,7 +136,7 @@ function generate_model_code(type, ex::Expr...) StructuralIdentifiability.Nemo.QQMPolyRingElem, Union{ StructuralIdentifiability.Nemo.QQMPolyRingElem, - StructuralIdentifiability.AbstractAlgebra.Generic.Frac{ + StructuralIdentifiability.AbstractAlgebra.Generic.FracFieldElem{ StructuralIdentifiability.Nemo.QQMPolyRingElem, }, }, @@ -147,7 +147,7 @@ function generate_model_code(type, ex::Expr...) StructuralIdentifiability.Nemo.QQMPolyRingElem, Union{ StructuralIdentifiability.Nemo.QQMPolyRingElem, - StructuralIdentifiability.AbstractAlgebra.Generic.Frac{ + StructuralIdentifiability.AbstractAlgebra.Generic.FracFieldElem{ StructuralIdentifiability.Nemo.QQMPolyRingElem, }, }, @@ -304,4 +304,4 @@ macro DDSmodel(ex::Expr...) return esc(generate_model_code(:dds, ex...)) end -#------------------------------------------------------------------------------ +#-----------------------------------------------------------------------------i diff --git a/src/io_equation.jl b/src/io_equation.jl index 92d90ff4e..6da051f22 100644 --- a/src/io_equation.jl +++ b/src/io_equation.jl @@ -24,7 +24,7 @@ function diff_poly(poly::P, derivation::Dict{P, T}) where {P <: MPolyRingElem, T return sum(derivative(poly, x) * xd for (x, xd) in derivation) end -function diff_frac(frac::Generic.Frac{F}, derivation::Dict{P, T}) where {F, P, T} +function diff_frac(frac::Generic.FracFieldElem{F}, derivation::Dict{P, T}) where {F, P, T} num, den = unpack_fraction(frac) numd = den * diff_poly(num, derivation) - num * diff_poly(den, derivation) dend = den^2 diff --git a/src/known_ic.jl b/src/known_ic.jl index 1fee878cb..0983e777e 100644 --- a/src/known_ic.jl +++ b/src/known_ic.jl @@ -28,12 +28,12 @@ This functions takes the following optional arguments: """ function _find_identifiable_functions_kic( ode::ODE{T}, - known_ic::Vector{<:Union{T, Generic.Frac{T}}}; + known_ic::Vector{<:ExtendedFraction{T}}; prob_threshold::Float64 = 0.99, seed = 42, simplify = :standard, rational_interpolator = :VanDerHoevenLecerf, -) where {T <: MPolyElem{fmpq}} +) where {T <: MPolyRingElem{Nemo.QQFieldElem}} Random.seed!(seed) @assert simplify in (:standard, :weak, :strong, :absent) half_p = 0.5 + prob_threshold / 2 @@ -80,10 +80,10 @@ The function returns an (ordered) dictionary from the functions to check to thei """ function _assess_identifiability_kic( ode::ODE{P}, - known_ic::Vector{<:Union{P, Generic.Frac{P}}}; + known_ic::Vector{<:ExtendedFraction{P}}; funcs_to_check = Vector(), prob_threshold::Float64 = 0.99, -) where {P <: MPolyElem{fmpq}} +) where {P <: MPolyRingElem{Nemo.QQFieldElem}} runtime_start = time_ns() if length(funcs_to_check) == 0 funcs_to_check = vcat(ode.x_vars, ode.parameters) diff --git a/src/lincomp.jl b/src/lincomp.jl index 0603e39a9..038dcd37d 100644 --- a/src/lincomp.jl +++ b/src/lincomp.jl @@ -51,9 +51,7 @@ function linear_compartment_model( ) x_vars = @view vars[1:n] x_equations = - Dict{QQMPolyRingElem, Union{QQMPolyRingElem, Generic.Frac{QQMPolyRingElem}}}( - x => R(0) for x in x_vars - ) + Dict{QQMPolyRingElem, ExtendedFraction{QQMPolyRingElem}}(x => R(0) for x in x_vars) for i in 1:n for j in graph[i] rate = str_to_var("a_$(j)_$(i)", R) @@ -69,10 +67,9 @@ function linear_compartment_model( end end - y_equations = - Dict{QQMPolyRingElem, Union{QQMPolyRingElem, Generic.Frac{QQMPolyRingElem}}}( - str_to_var("y$i", R) => str_to_var("x$i", R) for i in outputs - ) + y_equations = Dict{QQMPolyRingElem, ExtendedFraction{QQMPolyRingElem}}( + str_to_var("y$i", R) => str_to_var("x$i", R) for i in outputs + ) return ODE{QQMPolyRingElem}( x_equations, diff --git a/src/local_identifiability.jl b/src/local_identifiability.jl index 8b9c89982..90f195d2d 100644 --- a/src/local_identifiability.jl +++ b/src/local_identifiability.jl @@ -135,7 +135,9 @@ function get_degree_and_coeffsize(f::MPolyRingElem{Nemo.QQFieldElem}) return (total_degree(f), max_coef) end -function get_degree_and_coeffsize(f::Generic.Frac{<:MPolyRingElem{Nemo.QQFieldElem}}) +function get_degree_and_coeffsize( + f::Generic.FracFieldElem{<:MPolyRingElem{Nemo.QQFieldElem}}, +) num_deg, num_coef = get_degree_and_coeffsize(numerator(f)) den_deg, den_coef = get_degree_and_coeffsize(denominator(f)) return (max(num_deg, den_deg), max(num_coef, den_coef)) diff --git a/src/parametrizations.jl b/src/parametrizations.jl index b0d7f6fe3..d5c945d95 100644 --- a/src/parametrizations.jl +++ b/src/parametrizations.jl @@ -137,7 +137,7 @@ Returns a 4-element tuple """ function check_constructive_field_membership( rff::RationalFunctionField{T}, - to_be_reduced::Vector{Generic.Frac{T}}; + to_be_reduced::Vector{Generic.FracFieldElem{T}}; tag_names = Vector{String}(), ) where {T} @assert !isempty(to_be_reduced) @@ -236,8 +236,11 @@ $sat_string Tags: $tag_strings Original vars: $orig_strings""" end - parametric_ring, _ = - polynomial_ring(fraction_field(ring_of_tags), orig_strings, ordering = :degrevlex) + parametric_ring, _ = polynomial_ring( + fraction_field(ring_of_tags), + orig_strings, + internal_ordering = :degrevlex, + ) relations_between_tags = map(poly -> parent_ring_change(poly, ring_of_tags), relations_between_tags) param_var_mapping = merge( @@ -259,7 +262,7 @@ $sat_string # Reduce each fraction var_mapping = Dict(gens(poly_ring) .=> gens(parametric_ring)) memberships = Vector{Bool}(undef, length(to_be_reduced)) - remainders = Vector{Generic.Frac{T}}(undef, length(to_be_reduced)) + remainders = Vector{Generic.FracFieldElem{T}}(undef, length(to_be_reduced)) for i in 1:length(to_be_reduced) frac = to_be_reduced[i] num = crude_parent_ring_change(numerator(frac), parametric_ring, var_mapping) @@ -283,8 +286,10 @@ Returns the vector field obtained by applying `derivation` to each element of `directions`. """ function vector_field_along(derivation::Dict{T, U}, directions::AbstractVector) where {T, U} - new_vector_field = - Dict{AbstractAlgebra.Generic.Frac{T}, AbstractAlgebra.Generic.Frac{T}}() + new_vector_field = Dict{ + AbstractAlgebra.Generic.FracFieldElem{T}, + AbstractAlgebra.Generic.FracFieldElem{T}, + }() for func in directions df = diff_frac(func, derivation) new_vector_field[func] = df @@ -384,7 +389,7 @@ function reparametrize_with_respect_to(ode, new_states, new_params) ring_output, _ = polynomial_ring( base_ring(ring_of_tags), all_variable_names, - ordering = Nemo.ordering(ring_of_tags), + internal_ordering = Nemo.internal_ordering(ring_of_tags), ) new_vars_vector_field = Dict( parent_ring_change(var_old, ring_output, matching = :byindex) => @@ -458,7 +463,7 @@ X1'(t) = -X1(t)*X2(t) + X1(t)*a3 y1(t) = X1(t) # new_vars -Dict{Nemo.QQMPolyRingElem, AbstractAlgebra.Generic.Frac{Nemo.QQMPolyRingElem}} with 6 entries: +Dict{Nemo.QQMPolyRingElem, AbstractAlgebra.Generic.FracFieldElem{Nemo.QQMPolyRingElem}} with 6 entries: X2 => b*x2 y1 => y X1 => x1 diff --git a/src/states.jl b/src/states.jl index eee9a018e..2c648e528 100644 --- a/src/states.jl +++ b/src/states.jl @@ -13,7 +13,7 @@ Output: - list containing coefficients of `A` and `B` in some order (and in the original ring!) """ function extract_coefficients_ratfunc( - f::AbstractAlgebra.Generic.Frac{<:P}, + f::AbstractAlgebra.Generic.FracFieldElem{<:P}, vars::Vector{<:P}, ) where {P <: MPolyRingElem{<:FieldElem}} num, denom = unpack_fraction(f) @@ -48,7 +48,7 @@ Output: - Lie derivative of `f` with respect to `ode` """ function lie_derivative( - f::Generic.Frac{<:P}, + f::Generic.FracFieldElem{<:P}, ode::ODE{<:P}, ) where {P <: MPolyRingElem{<:FieldElem}} @assert all([(x in ode.parameters) || (x in ode.x_vars) for x in vars(f)]) @@ -91,7 +91,7 @@ identifiable functions of parameters only end end - result = Array{Generic.Frac{P}, 1}() + result = Array{Generic.FracFieldElem{P}, 1}() for (y, ord) in y_to_ord curr = extract_coefficients_ratfunc(ode.y_equations[y], ode.u_vars) for _ in 0:ord diff --git a/src/submodels.jl b/src/submodels.jl index b492bc5fd..9be6c97c5 100644 --- a/src/submodels.jl +++ b/src/submodels.jl @@ -126,7 +126,7 @@ function ode_aux(ode::ODE{P}, submodel::Set{QQMPolyRingElem}) where {P <: MPolyR sub_str = map(var_to_str, collect(submodel)) S, _ = Nemo.polynomial_ring(Nemo.QQ, sub_str) - dict_type = Dict{QQMPolyRingElem, Union{QQMPolyRingElem, Generic.Frac{QQMPolyRingElem}}} + dict_type = Dict{QQMPolyRingElem, ExtendedFraction{QQMPolyRingElem}} fin_x = dict_type(parent_ring_change(x, S) => parent_ring_change(f, S) for (x, f) in new_x) fin_y = diff --git a/src/util.jl b/src/util.jl index d68a59628..fbb3fbfae 100644 --- a/src/util.jl +++ b/src/util.jl @@ -1,6 +1,6 @@ # ------------------------------------------------------------------------------ -function total_degree_frac(f::Generic.Frac{<:MPolyRingElem}) +function total_degree_frac(f::Generic.FracFieldElem{<:MPolyRingElem}) return sum(map(total_degree, unpack_fraction(f))) end @@ -60,7 +60,7 @@ function eval_at_dict(poly::P, d::Dict{P, S}) where {P <: MPolyRingElem, S <: Re end function eval_at_dict( - rational::Generic.Frac{T}, + rational::Generic.FracFieldElem{T}, d::Dict{T, V}, ) where {T <: MPolyRingElem, V} f, g = unpack_fraction(rational) @@ -68,7 +68,7 @@ function eval_at_dict( end function eval_at_dict( - rational::Generic.Frac{<:T}, + rational::Generic.FracFieldElem{<:T}, d::Dict{T, <:RingElem}, ) where {T <: MPolyRingElem} f, g = unpack_fraction(rational) @@ -76,8 +76,8 @@ function eval_at_dict( end function eval_at_dict( - rational::Generic.Frac{<:P}, - d::Dict{<:P, <:Union{<:Generic.Frac, <:P}}, + rational::Generic.FracFieldElem{<:P}, + d::Dict{<:P, <:Union{<:Generic.FracFieldElem, <:P}}, ) where {P <: MPolyRingElem} f, g = unpack_fraction(rational) return eval_at_dict(f, d) // eval_at_dict(g, d) @@ -89,7 +89,7 @@ function unpack_fraction(f::MPolyRingElem) return (f, one(parent(f))) end -function unpack_fraction(f::Generic.Frac{<:MPolyRingElem}) +function unpack_fraction(f::Generic.FracFieldElem{<:MPolyRingElem}) return (numerator(f), denominator(f)) end @@ -186,7 +186,7 @@ function homogenize(fs) newring, hom_vars = polynomial_ring( base_ring(ring), vcat("X0", map(string, gens(ring))), - ordering = ordering(ring), + internal_ordering = internal_ordering(ring), ) Fs = empty(fs) for f in fs @@ -208,7 +208,7 @@ function dehomogenize(Fs) newring, dehom_vars = polynomial_ring( base_ring(ring), map(string, gens(ring)[2:end]), - ordering = ordering(ring), + internal_ordering = internal_ordering(ring), ) fs = empty(Fs) for F in Fs @@ -282,7 +282,7 @@ function parent_ring_change( end function parent_ring_change( - f::Generic.Frac{<:MPolyRingElem}, + f::Generic.FracFieldElem{<:MPolyRingElem}, new_ring::MPolyRing; matching = :byname, ) @@ -536,7 +536,7 @@ function replace_with_ic(ode, funcs) push!(varnames, (s, s * "(0)")) end end - R0, vars0 = PolynomialRing(base_ring(ode.poly_ring), [p[2] for p in varnames]) + R0, vars0 = polynomial_ring(base_ring(ode.poly_ring), [p[2] for p in varnames]) eval_dict = Dict(str_to_var(p[1], ode.poly_ring) => str_to_var(p[2], R0) for p in varnames) return [eval_at_dict(f, eval_dict) for f in funcs] diff --git a/src/wronskian.jl b/src/wronskian.jl index cca62bc5a..964509611 100644 --- a/src/wronskian.jl +++ b/src/wronskian.jl @@ -226,7 +226,7 @@ Computes the Wronskians of io_equations ord, ) @debug "Computing the derivatives of the solution" - ps_ext = Dict{MPolyRingElem, Nemo.gfp_abs_series}()# Generic.AbsSeries}() + ps_ext = Dict{MPolyRingElem, Nemo.fpAbsPowerSeriesRingElem}()# Generic.AbsSeries}() for v in vcat(ode_red.y_vars, ode_red.u_vars) cur_ps = ps[v] for i in 0:length(ode_red.x_vars) diff --git a/test/check_algebraicity.jl b/test/check_algebraicity.jl index ecb742f1a..9f8cc61d1 100644 --- a/test/check_algebraicity.jl +++ b/test/check_algebraicity.jl @@ -1,6 +1,6 @@ cases = [] -R, (x, y, z) = PolynomialRing(QQ, ["x", "y", "z"]) +R, (x, y, z) = polynomial_ring(QQ, ["x", "y", "z"]) push!( cases, Dict( diff --git a/test/differentiate_output.jl b/test/differentiate_output.jl index 3c8ef8662..615ce15a1 100644 --- a/test/differentiate_output.jl +++ b/test/differentiate_output.jl @@ -80,7 +80,7 @@ end @testset "Partial derivatives of an output w.r.t. to initial conditions and parameters" begin test_cases = [] P = QQMPolyRingElem - DType = Union{P, Generic.Frac{P}} + DType = Union{P, Generic.FracFieldElem{P}} ode = @ODEmodel(x'(t) = x(t) + a, y(t) = x(t)^2) push!( @@ -137,7 +137,7 @@ end F = Nemo.Native.GF(2^31 - 1) P = fpMPolyRingElem - DType = Union{P, Generic.Frac{P}} + DType = Union{P, Generic.FracFieldElem{P}} varnames = vcat( ["x_$i" for i in 1:3], diff --git a/test/identifiable_functions.jl b/test/identifiable_functions.jl index 6adcd51ca..099c6b252 100644 --- a/test/identifiable_functions.jl +++ b/test/identifiable_functions.jl @@ -19,7 +19,8 @@ ode = StructuralIdentifiability.@ODEmodel( x2'(t) = x1(t) + a, y(t) = x1(t) + x2(t) ) -ident_funcs = Vector{StructuralIdentifiability.AbstractAlgebra.Generic.Frac{typeof(x1)}}() +ident_funcs = + Vector{StructuralIdentifiability.AbstractAlgebra.Generic.FracFieldElem{typeof(x1)}}() push!(test_cases, (ode = ode, ident_funcs = ident_funcs)) diff --git a/test/local_identifiability_me.jl b/test/local_identifiability_me.jl index 07065365d..f53390510 100644 --- a/test/local_identifiability_me.jl +++ b/test/local_identifiability_me.jl @@ -32,10 +32,12 @@ function _linear_compartment_model(graph, sinks) Nemo.polynomial_ring(Nemo.QQ, vcat(x_vars_names, edges_vars_names, ["y1", "y2"])) x_vars = vars[2:(n + 1)] x0 = vars[1] - equations = - Dict{QQMPolyRingElem, Union{QQMPolyRingElem, Generic.Frac{QQMPolyRingElem}}}( - x => R(0) for x in x_vars - ) + equations = Dict{ + QQMPolyRingElem, + Union{QQMPolyRingElem, Generic.FracFieldElem{QQMPolyRingElem}}, + }( + x => R(0) for x in x_vars + ) equations[x0] = R(0) for i in 1:n for j in graph[i] diff --git a/test/ode_ps_solution.jl b/test/ode_ps_solution.jl index 35c59ccfa..020bf69ce 100644 --- a/test/ode_ps_solution.jl +++ b/test/ode_ps_solution.jl @@ -66,7 +66,7 @@ ) R, vars = Nemo.polynomial_ring(F, varnames) PType = fpMPolyRingElem - TDict = Dict{PType, Union{PType, Generic.Frac{PType}}} + TDict = Dict{PType, Union{PType, Generic.FracFieldElem{PType}}} # Generating the initial conditions etc ic = Dict(vars[i] => F(rand(-5:5)) for i in 1:NUMX) diff --git a/test/parent_ring_change.jl b/test/parent_ring_change.jl index 327d2cae8..dfeffcc36 100644 --- a/test/parent_ring_change.jl +++ b/test/parent_ring_change.jl @@ -1,9 +1,9 @@ @testset "Parent ring change" begin for field in [Nemo.QQ, Nemo.Native.GF(2^31 - 1)] - R, (z, x, y) = polynomial_ring(QQ, ["z", "x", "y"], ordering = :degrevlex) - R_, (y_, x_) = polynomial_ring(QQ, ["y", "x"], ordering = :lex) + R, (z, x, y) = polynomial_ring(QQ, ["z", "x", "y"], internal_ordering = :degrevlex) + R_, (y_, x_) = polynomial_ring(QQ, ["y", "x"], internal_ordering = :lex) R__, (x__, t__, y__, z__) = - polynomial_ring(QQ, ["x", "t", "y", "z"], ordering = :deglex) + polynomial_ring(QQ, ["x", "t", "y", "z"], internal_ordering = :deglex) f = 2x + 3y + x^7 * y @test f == StructuralIdentifiability.parent_ring_change(f, R, matching = :byname)