From 6fd471a03dfe41cc7c2a3d12732968f0ff207c15 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Thu, 19 Sep 2024 16:45:21 +0200 Subject: [PATCH 01/22] Attempt to speed up mapping of polynomials. --- src/Rings/MPolyMap/MPolyAnyMap.jl | 10 +++++++++- src/Rings/MPolyMap/MPolyRing.jl | 31 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/Rings/MPolyMap/MPolyAnyMap.jl b/src/Rings/MPolyMap/MPolyAnyMap.jl index 873365b9ad5f..ce09648d1567 100644 --- a/src/Rings/MPolyMap/MPolyAnyMap.jl +++ b/src/Rings/MPolyMap/MPolyAnyMap.jl @@ -42,6 +42,10 @@ const _DomainTypes = Union{MPolyRing, MPolyQuoRing} coeff_map::U img_gens::Vector{V} temp_ring # temporary ring used when evaluating maps + variable_indices::Vector{Int} # a table where the i-th entry contains the + # index of the variable where it's mapped to + # in case the mapping takes such a particularly + # simple form. function MPolyAnyMap{D, C, U, V}(domain::D, codomain::C, @@ -51,7 +55,11 @@ const _DomainTypes = Union{MPolyRing, MPolyQuoRing} for g in img_gens @assert parent(g) === codomain "elements does not have the correct parent" end - return new{D, C, U, V}(domain, codomain, coeff_map, img_gens) + result = new{D, C, U, V}(domain, codomain, coeff_map, img_gens) + if all(x in gens(codomain) for x in img_gens) && length(unique(img_gens)) == ngens(domain) + result.variable_indices = [findfirst(x==y for y in gens(codomain)) for x in img_gens] + end + return result end end diff --git a/src/Rings/MPolyMap/MPolyRing.jl b/src/Rings/MPolyMap/MPolyRing.jl index 6040c1c313e4..d8408f5a22f7 100644 --- a/src/Rings/MPolyMap/MPolyRing.jl +++ b/src/Rings/MPolyMap/MPolyRing.jl @@ -132,12 +132,43 @@ end # ################################################################################ +function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) + if isdefined(F, :variable_indices) + S = codomain(F)::MPolyRing + r = ngens(S) + ctx = MPolyBuildCtx(S) + for (c, e) in zip(coefficients(u), exponents(u)) + ee = [0 for _ in 1:r] + for (i, k) in enumerate(e) + ee[F.variable_indices[i]] = k + end + push_term!(ctx, c, ee) + end + return finish(ctx) + end + + return evaluate(u, F.img_gens) +end + function _evaluate_plain(F::MPolyAnyMap{<: MPolyRing}, u) return evaluate(u, F.img_gens) end # See the comment in MPolyQuo.jl function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyQuoRing}, u) + if isdefined(F, :variable_indices) + S = base_ring(codomain(F))::MPolyRing + r = ngens(S) + ctx = MPolyBuildCtx(S) + for (c, e) in zip(coefficients(u), exponents(u)) + ee = [0 for _ in 1:r] + for (i, k) in enumerate(e) + ee[F.variable_indices[i]] = k + end + push_term!(ctx, c, ee) + end + return codomain(F)(finish(ctx)) + end A = codomain(F) v = evaluate(lift(u), lift.(_images(F))) return simplify(A(v)) From 70279f9cbde57d12c4acb684d71fd11a66e25559 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Thu, 19 Sep 2024 17:43:20 +0200 Subject: [PATCH 02/22] Some more steps towards making stuff faster. --- src/Rings/MPolyMap/MPolyAnyMap.jl | 28 ++++++++++++++++++++-------- src/Rings/MPolyMap/MPolyRing.jl | 6 +++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/Rings/MPolyMap/MPolyAnyMap.jl b/src/Rings/MPolyMap/MPolyAnyMap.jl index ce09648d1567..03384f28d7ad 100644 --- a/src/Rings/MPolyMap/MPolyAnyMap.jl +++ b/src/Rings/MPolyMap/MPolyAnyMap.jl @@ -48,15 +48,27 @@ const _DomainTypes = Union{MPolyRing, MPolyQuoRing} # simple form. function MPolyAnyMap{D, C, U, V}(domain::D, - codomain::C, - coeff_map::U, - img_gens::Vector{V}) where {D, C, U, V} - @assert V === elem_type(C) - for g in img_gens - @assert parent(g) === codomain "elements does not have the correct parent" - end + codomain::C, + coeff_map::U, + img_gens::Vector{V}) where {D, C, U, V} + @assert V === elem_type(C) + for g in img_gens + @assert parent(g) === codomain "elements does not have the correct parent" + end + return new{D, C, U, V}(domain, codomain, coeff_map, img_gens) + end + function MPolyAnyMap{D, C, U, V}(domain::D, + codomain::C, + coeff_map::U, + img_gens::Vector{V}) where {D <: Union{<:MPolyRing, <:MPolyQuoRing}, + C <: Union{<:MPolyRing, <:MPolyQuoRing}, + U, V} + @assert V === elem_type(C) + for g in img_gens + @assert parent(g) === codomain "elements does not have the correct parent" + end result = new{D, C, U, V}(domain, codomain, coeff_map, img_gens) - if all(x in gens(codomain) for x in img_gens) && length(unique(img_gens)) == ngens(domain) + if all(is_gen(x) for x in img_gens) && allunique(img_gens) result.variable_indices = [findfirst(x==y for y in gens(codomain)) for x in img_gens] end return result diff --git a/src/Rings/MPolyMap/MPolyRing.jl b/src/Rings/MPolyMap/MPolyRing.jl index d8408f5a22f7..e9df1c4102eb 100644 --- a/src/Rings/MPolyMap/MPolyRing.jl +++ b/src/Rings/MPolyMap/MPolyRing.jl @@ -132,12 +132,16 @@ end # ################################################################################ +# Some additional methods needed for the test in the constructor for MPolyAnyMap +is_gen(x::MPolyQuoRingElem) = is_gen(lift(x)) +is_gen(x::MPolyDecRingElem) = is_gen(forget_grading(x)) + function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) if isdefined(F, :variable_indices) S = codomain(F)::MPolyRing r = ngens(S) ctx = MPolyBuildCtx(S) - for (c, e) in zip(coefficients(u), exponents(u)) + for (c, e) in zip(AbstractAlgebra.coefficients(u), AbstractAlgebra.exponent_vectors(u)) ee = [0 for _ in 1:r] for (i, k) in enumerate(e) ee[F.variable_indices[i]] = k From 43048816b2efe96e0e8de4f96dba8eea739750d9 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Tue, 24 Sep 2024 20:52:21 +0200 Subject: [PATCH 03/22] Try to make general evaluation faster. --- src/Rings/MPolyMap/MPolyRing.jl | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/Rings/MPolyMap/MPolyRing.jl b/src/Rings/MPolyMap/MPolyRing.jl index e9df1c4102eb..4d726ba9d9fe 100644 --- a/src/Rings/MPolyMap/MPolyRing.jl +++ b/src/Rings/MPolyMap/MPolyRing.jl @@ -178,6 +178,55 @@ function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyQuoRing}, u) return simplify(A(v)) end +function _evaluate_general(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) + if domain(F) === codomain(F) && coefficient_map(F) === nothing + return evaluate(map_coefficients(coefficient_map(F), u, + parent = domain(F)), F.img_gens) + else + S = temp_ring(F) + if S !== nothing + if !isdefined(F, :variable_indices) || coefficient_ring(S) !== codomain(F) + return evaluate(map_coefficients(coefficient_map(F), u, + parent = S), F.img_gens) + else + tmp_poly = map_coefficients(coefficient_map(F), u, parent = S) + cod_ring = codomain(F)::MPolyRing + r = ngens(cod_ring) + ctx = MPolyBuildCtx(cod_ring) + for (p, e) in zip(coefficients(tmp_poly), exponents(tmp_poly)) + ee = [0 for _ in 1:r] + for (i, k) in enumerate(e) + ee[F.variable_indices[i]] = k + end + p::MPolyRingElem + @assert parent(p) === cod_ring + for (c, d) in zip(coefficients(p), exponents(p)) + push_term!(ctx, c, ee+d) + end + end + return finish(ctx) + end + else + if !isdefined(F, :variable_indices) + return evaluate(map_coefficients(coefficient_map(F), u), F.img_gens) + else + tmp_poly = map_coefficients(coefficient_map(F), u) + cod_ring = codomain(F)::MPolyRing + r = ngens(cod_ring) + ctx = MPolyBuildCtx(cod_ring) + for (c, e) in zip(coefficients(tmp_poly), exponents(tmp_poly)) + ee = [0 for _ in 1:r] + for (i, k) in enumerate(e) + ee[F.variable_indices[i]] = k + end + push_term!(ctx, c, ee) + end + return finish(ctx) + end + end + end +end + function _evaluate_general(F::MPolyAnyMap{<: MPolyRing}, u) if domain(F) === codomain(F) && coefficient_map(F) === nothing return evaluate(map_coefficients(coefficient_map(F), u, @@ -186,7 +235,7 @@ function _evaluate_general(F::MPolyAnyMap{<: MPolyRing}, u) S = temp_ring(F) if S !== nothing return evaluate(map_coefficients(coefficient_map(F), u, - parent = S), F.img_gens) + parent = S), F.img_gens) else return evaluate(map_coefficients(coefficient_map(F), u), F.img_gens) end From a96cf364a948d9853925f8111bf64c78b2c769c6 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Wed, 25 Sep 2024 08:26:02 +0200 Subject: [PATCH 04/22] Clean up general evaluation. --- src/Rings/MPolyMap/MPolyAnyMap.jl | 6 ++-- src/Rings/MPolyMap/MPolyRing.jl | 52 ++++++++++++++----------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/Rings/MPolyMap/MPolyAnyMap.jl b/src/Rings/MPolyMap/MPolyAnyMap.jl index 03384f28d7ad..1fbb44a86bb7 100644 --- a/src/Rings/MPolyMap/MPolyAnyMap.jl +++ b/src/Rings/MPolyMap/MPolyAnyMap.jl @@ -43,7 +43,7 @@ const _DomainTypes = Union{MPolyRing, MPolyQuoRing} img_gens::Vector{V} temp_ring # temporary ring used when evaluating maps variable_indices::Vector{Int} # a table where the i-th entry contains the - # index of the variable where it's mapped to + # index of the variable where it is mapped to # in case the mapping takes such a particularly # simple form. @@ -68,8 +68,8 @@ const _DomainTypes = Union{MPolyRing, MPolyQuoRing} @assert parent(g) === codomain "elements does not have the correct parent" end result = new{D, C, U, V}(domain, codomain, coeff_map, img_gens) - if all(is_gen(x) for x in img_gens) && allunique(img_gens) - result.variable_indices = [findfirst(x==y for y in gens(codomain)) for x in img_gens] + if all(_is_gen, img_gens) && allunique(img_gens) + result.variable_indices = [findfirst(==(x), gens(codomain)) for x in img_gens] end return result end diff --git a/src/Rings/MPolyMap/MPolyRing.jl b/src/Rings/MPolyMap/MPolyRing.jl index 4d726ba9d9fe..4736a125b656 100644 --- a/src/Rings/MPolyMap/MPolyRing.jl +++ b/src/Rings/MPolyMap/MPolyRing.jl @@ -133,8 +133,9 @@ end ################################################################################ # Some additional methods needed for the test in the constructor for MPolyAnyMap -is_gen(x::MPolyQuoRingElem) = is_gen(lift(x)) -is_gen(x::MPolyDecRingElem) = is_gen(forget_grading(x)) +_is_gen(x::MPolyQuoRingElem) = _is_gen(lift(x)) +_is_gen(x::MPolyDecRingElem) = is_gen(forget_grading(x)) +_is_gen(x::MPolyRingElem) = is_gen(x) function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) if isdefined(F, :variable_indices) @@ -178,6 +179,24 @@ function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyQuoRing}, u) return simplify(A(v)) end +# The following assumes `p` to be in `S[x₁,…,xₙ]` where `S` is the +# actual codomain of the map. +function _evaluate_with_build_ctx(p::MPolyRingElem, ind::Vector{Int}) + cod_ring = coefficient_ring(parent(p)) + r = ngens(cod_ring) + ctx = MPolyBuildCtx(cod_ring) + for (q, e) in zip(coefficients(p), exponents(p)) + ee = [0 for _ in 1:r] + for (i, k) in enumerate(e) + ee[ind[i]] = k + end + for (c, d) in zip(coefficients(q), exponents(q)) + push_term!(ctx, c, ee+d) + end + end + return finish(ctx) +end + function _evaluate_general(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) if domain(F) === codomain(F) && coefficient_map(F) === nothing return evaluate(map_coefficients(coefficient_map(F), u, @@ -190,38 +209,15 @@ function _evaluate_general(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) parent = S), F.img_gens) else tmp_poly = map_coefficients(coefficient_map(F), u, parent = S) - cod_ring = codomain(F)::MPolyRing - r = ngens(cod_ring) - ctx = MPolyBuildCtx(cod_ring) - for (p, e) in zip(coefficients(tmp_poly), exponents(tmp_poly)) - ee = [0 for _ in 1:r] - for (i, k) in enumerate(e) - ee[F.variable_indices[i]] = k - end - p::MPolyRingElem - @assert parent(p) === cod_ring - for (c, d) in zip(coefficients(p), exponents(p)) - push_term!(ctx, c, ee+d) - end - end - return finish(ctx) + return _evaluate_with_build_ctx(tmp_poly, F.variable_indices) end else if !isdefined(F, :variable_indices) return evaluate(map_coefficients(coefficient_map(F), u), F.img_gens) else tmp_poly = map_coefficients(coefficient_map(F), u) - cod_ring = codomain(F)::MPolyRing - r = ngens(cod_ring) - ctx = MPolyBuildCtx(cod_ring) - for (c, e) in zip(coefficients(tmp_poly), exponents(tmp_poly)) - ee = [0 for _ in 1:r] - for (i, k) in enumerate(e) - ee[F.variable_indices[i]] = k - end - push_term!(ctx, c, ee) - end - return finish(ctx) + coefficient_ring(parent(tmp_poly)) === codomain(F) && return _evaluate_with_build_ctx(tmp_poly, F.variable_indices) + return evaluate(tmp_poly, F.variable_indices) end end end From b6a3c405bb2856024f1e564a6e850fda774b75fa Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 13:48:29 +0200 Subject: [PATCH 05/22] Fix tests. --- src/Rings/MPolyMap/MPolyAnyMap.jl | 6 ++++-- src/Rings/MPolyMap/MPolyRing.jl | 26 +++++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/Rings/MPolyMap/MPolyAnyMap.jl b/src/Rings/MPolyMap/MPolyAnyMap.jl index 1fbb44a86bb7..e7fef2ecd0a1 100644 --- a/src/Rings/MPolyMap/MPolyAnyMap.jl +++ b/src/Rings/MPolyMap/MPolyAnyMap.jl @@ -60,7 +60,9 @@ const _DomainTypes = Union{MPolyRing, MPolyQuoRing} function MPolyAnyMap{D, C, U, V}(domain::D, codomain::C, coeff_map::U, - img_gens::Vector{V}) where {D <: Union{<:MPolyRing, <:MPolyQuoRing}, + img_gens::Vector{V}; + check_for_mapping_of_vars::Bool=true + ) where {D <: Union{<:MPolyRing, <:MPolyQuoRing}, C <: Union{<:MPolyRing, <:MPolyQuoRing}, U, V} @assert V === elem_type(C) @@ -68,7 +70,7 @@ const _DomainTypes = Union{MPolyRing, MPolyQuoRing} @assert parent(g) === codomain "elements does not have the correct parent" end result = new{D, C, U, V}(domain, codomain, coeff_map, img_gens) - if all(_is_gen, img_gens) && allunique(img_gens) + if check_for_mapping_of_vars && all(_is_gen, img_gens) && _allunique(img_gens) result.variable_indices = [findfirst(==(x), gens(codomain)) for x in img_gens] end return result diff --git a/src/Rings/MPolyMap/MPolyRing.jl b/src/Rings/MPolyMap/MPolyRing.jl index 4736a125b656..fb58a4eae962 100644 --- a/src/Rings/MPolyMap/MPolyRing.jl +++ b/src/Rings/MPolyMap/MPolyRing.jl @@ -137,9 +137,17 @@ _is_gen(x::MPolyQuoRingElem) = _is_gen(lift(x)) _is_gen(x::MPolyDecRingElem) = is_gen(forget_grading(x)) _is_gen(x::MPolyRingElem) = is_gen(x) +# In case there is a type of polynomials for which hashing is not implemented +# and throws an error, this gives the opportunity to overwrite the `allunique` +# to be used within the constructor for maps. +function _allunique(lst::Vector{T}) where {T<:RingElem} + return allunique(lst) +end + function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) if isdefined(F, :variable_indices) S = codomain(F)::MPolyRing + kk = coefficient_ring(S) r = ngens(S) ctx = MPolyBuildCtx(S) for (c, e) in zip(AbstractAlgebra.coefficients(u), AbstractAlgebra.exponent_vectors(u)) @@ -147,7 +155,7 @@ function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) for (i, k) in enumerate(e) ee[F.variable_indices[i]] = k end - push_term!(ctx, c, ee) + push_term!(ctx, kk(c), ee) end return finish(ctx) end @@ -181,9 +189,12 @@ end # The following assumes `p` to be in `S[x₁,…,xₙ]` where `S` is the # actual codomain of the map. -function _evaluate_with_build_ctx(p::MPolyRingElem, ind::Vector{Int}) +function _evaluate_with_build_ctx( + p::MPolyRingElem, ind::Vector{Int} + ) cod_ring = coefficient_ring(parent(p)) r = ngens(cod_ring) + kk = coefficient_ring(cod_ring) ctx = MPolyBuildCtx(cod_ring) for (q, e) in zip(coefficients(p), exponents(p)) ee = [0 for _ in 1:r] @@ -191,7 +202,7 @@ function _evaluate_with_build_ctx(p::MPolyRingElem, ind::Vector{Int}) ee[ind[i]] = k end for (c, d) in zip(coefficients(q), exponents(q)) - push_term!(ctx, c, ee+d) + push_term!(ctx, kk(c), ee+d) end end return finish(ctx) @@ -215,9 +226,14 @@ function _evaluate_general(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) if !isdefined(F, :variable_indices) return evaluate(map_coefficients(coefficient_map(F), u), F.img_gens) else + # For the case where we can recycle the method above, do so. tmp_poly = map_coefficients(coefficient_map(F), u) - coefficient_ring(parent(tmp_poly)) === codomain(F) && return _evaluate_with_build_ctx(tmp_poly, F.variable_indices) - return evaluate(tmp_poly, F.variable_indices) + coefficient_ring(parent(tmp_poly)) === codomain(F) && return _evaluate_with_build_ctx( + tmp_poly, + F.variable_indices + ) + # Otherwise default to the standard evaluation for the time being. + return evaluate(tmp_poly, F.img_gens) end end end From d1f90e3de26f3ec8c0d1f3080ae96d72b4096835 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 14:46:29 +0200 Subject: [PATCH 06/22] Widen type signature so that more rings benefit from variable-map. --- src/Rings/MPolyMap/MPolyAnyMap.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Rings/MPolyMap/MPolyAnyMap.jl b/src/Rings/MPolyMap/MPolyAnyMap.jl index e7fef2ecd0a1..1e7c0879f72f 100644 --- a/src/Rings/MPolyMap/MPolyAnyMap.jl +++ b/src/Rings/MPolyMap/MPolyAnyMap.jl @@ -63,8 +63,7 @@ const _DomainTypes = Union{MPolyRing, MPolyQuoRing} img_gens::Vector{V}; check_for_mapping_of_vars::Bool=true ) where {D <: Union{<:MPolyRing, <:MPolyQuoRing}, - C <: Union{<:MPolyRing, <:MPolyQuoRing}, - U, V} + C, U, V} @assert V === elem_type(C) for g in img_gens @assert parent(g) === codomain "elements does not have the correct parent" From f98f1983aecaa3598d23863086eae8698961956b Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 14:46:45 +0200 Subject: [PATCH 07/22] Fix call. --- src/Rings/MPolyMap/MPolyRing.jl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Rings/MPolyMap/MPolyRing.jl b/src/Rings/MPolyMap/MPolyRing.jl index fb58a4eae962..a2e07c0b3e1b 100644 --- a/src/Rings/MPolyMap/MPolyRing.jl +++ b/src/Rings/MPolyMap/MPolyRing.jl @@ -136,6 +136,8 @@ end _is_gen(x::MPolyQuoRingElem) = _is_gen(lift(x)) _is_gen(x::MPolyDecRingElem) = is_gen(forget_grading(x)) _is_gen(x::MPolyRingElem) = is_gen(x) +# default method; overwrite if you want this to work for your rings. +_is_gen(x::NCRingElem) = false # In case there is a type of polynomials for which hashing is not implemented # and throws an error, this gives the opportunity to overwrite the `allunique` @@ -190,9 +192,9 @@ end # The following assumes `p` to be in `S[x₁,…,xₙ]` where `S` is the # actual codomain of the map. function _evaluate_with_build_ctx( - p::MPolyRingElem, ind::Vector{Int} + p::MPolyRingElem, ind::Vector{Int}, cod_ring::MPolyRing ) - cod_ring = coefficient_ring(parent(p)) + @assert cod_ring === coefficient_ring(parent(p)) r = ngens(cod_ring) kk = coefficient_ring(cod_ring) ctx = MPolyBuildCtx(cod_ring) @@ -220,7 +222,7 @@ function _evaluate_general(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) parent = S), F.img_gens) else tmp_poly = map_coefficients(coefficient_map(F), u, parent = S) - return _evaluate_with_build_ctx(tmp_poly, F.variable_indices) + return _evaluate_with_build_ctx(tmp_poly, F.variable_indices, codomain(F)) end else if !isdefined(F, :variable_indices) @@ -230,7 +232,8 @@ function _evaluate_general(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) tmp_poly = map_coefficients(coefficient_map(F), u) coefficient_ring(parent(tmp_poly)) === codomain(F) && return _evaluate_with_build_ctx( tmp_poly, - F.variable_indices + F.variable_indices, + codomain(F) ) # Otherwise default to the standard evaluation for the time being. return evaluate(tmp_poly, F.img_gens) From 570e769e84b351e13ca73b3ad0d207a7577aac72 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 14:47:41 +0200 Subject: [PATCH 08/22] Implement extension for localizations and quotients. --- src/Rings/mpolyquo-localizations.jl | 102 ++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/src/Rings/mpolyquo-localizations.jl b/src/Rings/mpolyquo-localizations.jl index 551d7a82cbfa..76475bef5f29 100644 --- a/src/Rings/mpolyquo-localizations.jl +++ b/src/Rings/mpolyquo-localizations.jl @@ -2717,3 +2717,105 @@ function dim(R::MPolyQuoLocRing) return dim(modulus(R)) end +### extra methods for speedup of mappings +# See `src/Rings/MPolyMap/MPolyRing.jl` for the original implementation and +# the rationale. These methods make speedup available for quotient rings +# and localizations of polynomial rings. +function _allunique(lst::Vector{T}) where {T<:MPolyLocRingElem} + return _allunique(numerator.(lst)) +end + +function _allunique(lst::Vector{T}) where {T<:MPolyQuoLocRingElem} + return _allunique(lifted_numerator.(lst)) +end + +_is_gen(x::MPolyLocRingElem) = is_one(denominator(x)) && _is_gen(numerator(x)) +_is_gen(x::MPolyQuoLocRingElem) = is_one(lifted_denominator(x)) && _is_gen(lifted_numerator(x)) + +function _evaluate_plain( + F::MPolyAnyMap{<:MPolyRing, CT}, u + ) where {CT <: Union{<:MPolyLocRing, <:MPolyQuoLocRing}} + if isdefined(F, :variable_indices) + W = codomain(F)::MPolyLocRing + S = base_ring(W) + kk = coefficient_ring(S) + r = ngens(S) + ctx = MPolyBuildCtx(S) + for (c, e) in zip(AbstractAlgebra.coefficients(u), AbstractAlgebra.exponent_vectors(u)) + ee = [0 for _ in 1:r] + for (i, k) in enumerate(e) + ee[F.variable_indices[i]] = k + end + push_term!(ctx, kk(c), ee) + end + return W(finish(ctx)) + end + + return evaluate(u, F.img_gens) +end + +function _evaluate_general( + F::MPolyAnyMap{<:MPolyRing, CT}, u + ) where {CT <: Union{<:MPolyQuoRing, <:MPolyLocRing, <:MPolyQuoLocRing}} + if domain(F) === codomain(F) && coefficient_map(F) === nothing + return evaluate(map_coefficients(coefficient_map(F), u, + parent = domain(F)), F.img_gens) + else + S = temp_ring(F) + if S !== nothing + if !isdefined(F, :variable_indices) || coefficient_ring(S) !== codomain(F) + return evaluate(map_coefficients(coefficient_map(F), u, + parent = S), F.img_gens) + else + tmp_poly = map_coefficients(coefficient_map(F), u, parent = S) + return _evaluate_with_build_ctx(tmp_poly, F.variable_indices, codomain(F)) + end + else + if !isdefined(F, :variable_indices) + return evaluate(map_coefficients(coefficient_map(F), u), F.img_gens) + else + # For the case where we can recycle the method above, do so. + tmp_poly = map_coefficients(coefficient_map(F), u) + coefficient_ring(parent(tmp_poly)) === codomain(F) && return _evaluate_with_build_ctx( + tmp_poly, + F.variable_indices, + codomain(F) + ) + # Otherwise default to the standard evaluation for the time being. + return evaluate(tmp_poly, F.img_gens) + end + end + end +end + +function _evaluate_with_build_ctx( + p::MPolyRingElem, ind::Vector{Int}, + Q::Union{<:MPolyQuoRing, <:MPolyLocRing, <:MPolyQuoLocRing} + ) + @assert Q === coefficient_ring(parent(p)) + cod_ring = base_ring(Q) + r = ngens(cod_ring) + kk = coefficient_ring(cod_ring) + ctx = MPolyBuildCtx(cod_ring) + for (q, e) in zip(coefficients(p), exponents(p)) + ee = [0 for _ in 1:r] + for (i, k) in enumerate(e) + ee[ind[i]] = k + end + for (c, d) in zip(_coefficients(q), _exponents(q)) + push_term!(ctx, kk(c), ee+d) + end + end + return Q(finish(ctx)) +end + +_coefficients(x::MPolyRingElem) = coefficients(x) +_coefficients(x::MPolyQuoRingElem) = coefficients(lift(x)) +_coefficients(x::MPolyLocRingElem) = coefficients(numerator(x)) +_coefficients(x::MPolyQuoLocRingElem) = coefficients(lifted_numerator(x)) + +_exponents(x::MPolyRingElem) = exponents(x) +_exponents(x::MPolyQuoRingElem) = exponents(lift(x)) +_exponents(x::MPolyLocRingElem) = exponents(numerator(x)) +_exponents(x::MPolyQuoLocRingElem) = exponents(lifted_numerator(x)) + From 2d83dd6d80c71afe9387dc4675653ad38a3d9320 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 14:53:14 +0200 Subject: [PATCH 09/22] Switch default for _allunique. --- src/Rings/MPolyMap/MPolyRing.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Rings/MPolyMap/MPolyRing.jl b/src/Rings/MPolyMap/MPolyRing.jl index a2e07c0b3e1b..5be25f43ea5e 100644 --- a/src/Rings/MPolyMap/MPolyRing.jl +++ b/src/Rings/MPolyMap/MPolyRing.jl @@ -139,13 +139,19 @@ _is_gen(x::MPolyRingElem) = is_gen(x) # default method; overwrite if you want this to work for your rings. _is_gen(x::NCRingElem) = false -# In case there is a type of polynomials for which hashing is not implemented -# and throws an error, this gives the opportunity to overwrite the `allunique` +# In case there is a type of ring elements for which hashing is correctly implemented +# and does not throw an error, this gives the opportunity to overwrite the `allunique` # to be used within the constructor for maps. -function _allunique(lst::Vector{T}) where {T<:RingElem} +function _allunique(lst::Vector{T}) where {T<:MPolyRingElem} return allunique(lst) end +# We have a lot of rings which do/can not implement correct hashing. +# So we make the following the default. +function _allunique(lst::Vector{T}) where {T<:RingElem} + return all(!(x in lst[i+1:end]) for (i, x) in enumerate(lst)) +end + function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) if isdefined(F, :variable_indices) S = codomain(F)::MPolyRing From 9a5961338c135456ce21489ede1a910f0d5a4036 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 15:15:23 +0200 Subject: [PATCH 10/22] Fix tests. --- .../Schemes/AffineSchemeOpenSubscheme/Rings/Methods.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/AlgebraicGeometry/Schemes/AffineSchemeOpenSubscheme/Rings/Methods.jl b/src/AlgebraicGeometry/Schemes/AffineSchemeOpenSubscheme/Rings/Methods.jl index e54bba5722a9..1419c4e2f157 100644 --- a/src/AlgebraicGeometry/Schemes/AffineSchemeOpenSubscheme/Rings/Methods.jl +++ b/src/AlgebraicGeometry/Schemes/AffineSchemeOpenSubscheme/Rings/Methods.jl @@ -506,3 +506,7 @@ function Base.show(io::IO, ::MIME"text/plain", a::AffineSchemeOpenSubschemeRingE end end +# overwrite a method for mapping of rings which would throw otherwise +function _allunique(lst::Vector{T}) where {T<:MPolyQuoRingElem{<:MPolyRingElem{<:AffineSchemeOpenSubschemeRingElem}}} + return false +end From 4e5b8e7be11eb53c2c131b98e5a9b72415149c0d Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 15:27:18 +0200 Subject: [PATCH 11/22] Remove superfluous if-clause and add some comments. --- src/Rings/mpolyquo-localizations.jl | 48 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/Rings/mpolyquo-localizations.jl b/src/Rings/mpolyquo-localizations.jl index 76475bef5f29..4e32732adc08 100644 --- a/src/Rings/mpolyquo-localizations.jl +++ b/src/Rings/mpolyquo-localizations.jl @@ -2757,33 +2757,28 @@ end function _evaluate_general( F::MPolyAnyMap{<:MPolyRing, CT}, u ) where {CT <: Union{<:MPolyQuoRing, <:MPolyLocRing, <:MPolyQuoLocRing}} - if domain(F) === codomain(F) && coefficient_map(F) === nothing - return evaluate(map_coefficients(coefficient_map(F), u, - parent = domain(F)), F.img_gens) + S = temp_ring(F) + if S !== nothing + if !isdefined(F, :variable_indices) || coefficient_ring(S) !== codomain(F) + return evaluate(map_coefficients(coefficient_map(F), u, + parent = S), F.img_gens) + else + tmp_poly = map_coefficients(coefficient_map(F), u, parent = S) + return _evaluate_with_build_ctx(tmp_poly, F.variable_indices, codomain(F)) + end else - S = temp_ring(F) - if S !== nothing - if !isdefined(F, :variable_indices) || coefficient_ring(S) !== codomain(F) - return evaluate(map_coefficients(coefficient_map(F), u, - parent = S), F.img_gens) - else - tmp_poly = map_coefficients(coefficient_map(F), u, parent = S) - return _evaluate_with_build_ctx(tmp_poly, F.variable_indices, codomain(F)) - end + if !isdefined(F, :variable_indices) + return evaluate(map_coefficients(coefficient_map(F), u), F.img_gens) else - if !isdefined(F, :variable_indices) - return evaluate(map_coefficients(coefficient_map(F), u), F.img_gens) - else - # For the case where we can recycle the method above, do so. - tmp_poly = map_coefficients(coefficient_map(F), u) - coefficient_ring(parent(tmp_poly)) === codomain(F) && return _evaluate_with_build_ctx( - tmp_poly, - F.variable_indices, - codomain(F) - ) - # Otherwise default to the standard evaluation for the time being. - return evaluate(tmp_poly, F.img_gens) - end + # For the case where we can recycle the method above, do so. + tmp_poly = map_coefficients(coefficient_map(F), u) + coefficient_ring(parent(tmp_poly)) === codomain(F) && return _evaluate_with_build_ctx( + tmp_poly, + F.variable_indices, + codomain(F) + ) + # Otherwise default to the standard evaluation for the time being. + return evaluate(tmp_poly, F.img_gens) end end end @@ -2809,6 +2804,9 @@ function _evaluate_with_build_ctx( return Q(finish(ctx)) end +# The following methods are only safe, because they are called +# exclusively in a setup where variables map to variables +# and no denominators are introduced. _coefficients(x::MPolyRingElem) = coefficients(x) _coefficients(x::MPolyQuoRingElem) = coefficients(lift(x)) _coefficients(x::MPolyLocRingElem) = coefficients(numerator(x)) From f005ce1e58f96598933a3e0ed1e82afe6efd3f07 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 18:22:13 +0200 Subject: [PATCH 12/22] Fix doctests in Algebraic statistics. --- experimental/AlgebraicStatistics/src/CI.jl | 6 +- .../AlgebraicStatistics/src/Markov.jl | 6 +- .../src/PhylogeneticParametrization.jl | 112 +++++++++++++++--- 3 files changed, 108 insertions(+), 16 deletions(-) diff --git a/experimental/AlgebraicStatistics/src/CI.jl b/experimental/AlgebraicStatistics/src/CI.jl index 0e4d096eeeff..a1f6dcea65ff 100644 --- a/experimental/AlgebraicStatistics/src/CI.jl +++ b/experimental/AlgebraicStatistics/src/CI.jl @@ -137,7 +137,11 @@ julia> ci_statements(["A", "B", "X", "Y"]) [B _||_ Y | {A, X}] [X _||_ Y | {}] [X _||_ Y | A] - ⋮ + [X _||_ Y | B] + [X _||_ Y | {A, B}] + [A _||_ X | {}] + [A _||_ X | B] + [A _||_ X | Y] [A _||_ X | {B, Y}] [B _||_ X | {}] [B _||_ X | A] diff --git a/experimental/AlgebraicStatistics/src/Markov.jl b/experimental/AlgebraicStatistics/src/Markov.jl index 3fb204f42e1e..d5a2c50a4ce4 100644 --- a/experimental/AlgebraicStatistics/src/Markov.jl +++ b/experimental/AlgebraicStatistics/src/Markov.jl @@ -124,7 +124,11 @@ julia> ci_statements(R) [B _||_ Y | {A, X}] [X _||_ Y | {}] [X _||_ Y | A] - ⋮ + [X _||_ Y | B] + [X _||_ Y | {A, B}] + [A _||_ X | {}] + [A _||_ X | B] + [A _||_ X | Y] [A _||_ X | {B, Y}] [B _||_ X | {}] [B _||_ X | A] diff --git a/experimental/AlgebraicStatistics/src/PhylogeneticParametrization.jl b/experimental/AlgebraicStatistics/src/PhylogeneticParametrization.jl index 3bd020933569..0788cd641b77 100644 --- a/experimental/AlgebraicStatistics/src/PhylogeneticParametrization.jl +++ b/experimental/AlgebraicStatistics/src/PhylogeneticParametrization.jl @@ -62,22 +62,64 @@ Dict{Tuple{Vararg{Int64}}, QQMPolyRingElem} with 64 entries: (1, 2, 1) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] (3, 1, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] (4, 4, 2) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] - (1, 2, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … + (1, 2, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] (3, 1, 3) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] - (3, 2, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … - (3, 2, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … - (2, 1, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … + (3, 2, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (3, 2, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (2, 1, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] (3, 2, 3) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] (2, 1, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (1, 3, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … - (1, 4, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … - (2, 1, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … + (1, 3, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (1, 4, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (2, 1, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] (2, 2, 4) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] (4, 3, 4) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] (2, 2, 1) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] (4, 4, 4) => 1//4*a[1]*a[2]*a[3] + 3//4*b[1]*b[2]*b[3] - (4, 3, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … + (4, 3, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] (3, 3, 2) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] + (4, 1, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (4, 4, 1) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] + (2, 2, 3) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] + (3, 4, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (4, 3, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] + (4, 4, 3) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] + (4, 2, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] + (1, 3, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (2, 3, 2) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] + (1, 4, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] + (1, 3, 1) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] + (2, 4, 2) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] + (1, 1, 2) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] + (1, 4, 1) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] + (1, 3, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] + (3, 3, 4) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] + (1, 4, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (4, 1, 4) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] + (3, 4, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] + (3, 3, 1) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] + (4, 1, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] + (1, 2, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] + (3, 1, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (3, 4, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (3, 3, 3) => 1//4*a[1]*a[2]*a[3] + 3//4*b[1]*b[2]*b[3] + (4, 1, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (4, 2, 4) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] + (3, 4, 3) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] + (4, 2, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (3, 2, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] + (2, 3, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (4, 2, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (2, 3, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (2, 4, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] + (1, 1, 4) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] + (2, 1, 2) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] + (2, 4, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (1, 1, 1) => 1//4*a[1]*a[2]*a[3] + 3//4*b[1]*b[2]*b[3] + (2, 3, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] + (2, 4, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (1, 1, 3) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] + (1, 2, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] ⋮ => ⋮ ``` """ @@ -155,6 +197,48 @@ Dict{Tuple{Vararg{Int64}}, QQMPolyRingElem} with 64 entries: (4, 4, 4) => 0 (4, 3, 1) => 0 (3, 3, 2) => 0 + (4, 1, 2) => 0 + (4, 4, 1) => x[3, 1]*x[1, 2]*x[2, 2] + (2, 2, 3) => 0 + (3, 4, 2) => x[1, 2]*x[2, 2]*x[3, 2] + (4, 3, 3) => 0 + (4, 4, 3) => 0 + (4, 2, 2) => 0 + (1, 3, 4) => 0 + (2, 3, 2) => 0 + (1, 4, 4) => x[1, 1]*x[2, 2]*x[3, 2] + (1, 3, 1) => 0 + (2, 4, 2) => 0 + (1, 1, 2) => 0 + (1, 4, 1) => 0 + (1, 3, 3) => x[1, 1]*x[2, 2]*x[3, 2] + (3, 3, 4) => 0 + (1, 4, 3) => 0 + (4, 1, 4) => x[2, 1]*x[1, 2]*x[3, 2] + (3, 4, 4) => 0 + (3, 3, 1) => x[3, 1]*x[1, 2]*x[2, 2] + (4, 1, 1) => 0 + (1, 2, 2) => x[1, 1]*x[2, 2]*x[3, 2] + (3, 1, 2) => 0 + (3, 4, 1) => 0 + (3, 3, 3) => 0 + (4, 1, 3) => 0 + (4, 2, 4) => 0 + (3, 4, 3) => 0 + (4, 2, 1) => 0 + (3, 2, 2) => 0 + (2, 3, 4) => x[1, 2]*x[2, 2]*x[3, 2] + (4, 2, 3) => x[1, 2]*x[2, 2]*x[3, 2] + (2, 3, 1) => 0 + (2, 4, 4) => 0 + (1, 1, 4) => 0 + (2, 1, 2) => x[2, 1]*x[1, 2]*x[3, 2] + (2, 4, 1) => 0 + (1, 1, 1) => x[1, 1]*x[2, 1]*x[3, 1] + (2, 3, 3) => 0 + (2, 4, 3) => x[1, 2]*x[2, 2]*x[3, 2] + (1, 1, 3) => 0 + (1, 2, 4) => 0 ⋮ => ⋮ ``` """ @@ -192,16 +276,16 @@ Dict{Tuple{Vararg{Int64}}, QQMPolyRingElem} with 5 entries: (1, 2, 1) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] (1, 1, 1) => 1//4*a[1]*a[2]*a[3] + 3//4*b[1]*b[2]*b[3] (1, 2, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (1, 2, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … + (1, 2, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] (1, 1, 2) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] julia> p_equivclasses.classes Dict{Tuple{Vararg{Int64}}, Vector{Tuple{Vararg{Int64}}}} with 5 entries: - (1, 2, 1) => [(1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 2), (2, 3, 2), (2, 4, 2… + (1, 2, 1) => [(1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 2), (2, 3, 2), (2, 4, 2), (3, 1, 3), (3, 2, 3), (3, 4, 3), (4, 1, 4), (4, 2, 4), (4, 3, 4)] (1, 1, 1) => [(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4)] - (1, 2, 2) => [(1, 2, 2), (1, 3, 3), (1, 4, 4), (2, 1, 1), (2, 3, 3), (2, 4, 4… - (1, 2, 3) => [(1, 2, 3), (1, 2, 4), (1, 3, 2), (1, 3, 4), (1, 4, 2), (1, 4, 3… - (1, 1, 2) => [(1, 1, 2), (1, 1, 3), (1, 1, 4), (2, 2, 1), (2, 2, 3), (2, 2, 4… + (1, 2, 2) => [(1, 2, 2), (1, 3, 3), (1, 4, 4), (2, 1, 1), (2, 3, 3), (2, 4, 4), (3, 1, 1), (3, 2, 2), (3, 4, 4), (4, 1, 1), (4, 2, 2), (4, 3, 3)] + (1, 2, 3) => [(1, 2, 3), (1, 2, 4), (1, 3, 2), (1, 3, 4), (1, 4, 2), (1, 4, 3), (2, 1, 3), (2, 1, 4), (2, 3, 1), (2, 3, 4) … (3, 2, 1), (3, 2, 4), (3, 4, 1), (3, 4, 2), (4, 1, 2), (4, 1, 3), (4, 2, 1), (4, … + (1, 1, 2) => [(1, 1, 2), (1, 1, 3), (1, 1, 4), (2, 2, 1), (2, 2, 3), (2, 2, 4), (3, 3, 1), (3, 3, 2), (3, 3, 4), (4, 4, 1), (4, 4, 2), (4, 4, 3)] julia> q_equivclasses = compute_equivalent_classes(q); @@ -251,7 +335,7 @@ Dict{Tuple{Int64, Int64, Int64}, QQMPolyRingElem} with 5 entries: (1, 2, 1) => 3*a[1]*a[3]*b[2] + 3*a[2]*b[1]*b[3] + 6*b[1]*b[2]*b[3] (1, 1, 1) => a[1]*a[2]*a[3] + 3*b[1]*b[2]*b[3] (1, 2, 2) => 3*a[1]*b[2]*b[3] + 3*a[2]*a[3]*b[1] + 6*b[1]*b[2]*b[3] - (1, 2, 3) => 6*a[1]*b[2]*b[3] + 6*a[2]*b[1]*b[3] + 6*a[3]*b[1]*b[2] + 6*b[1]*… + (1, 2, 3) => 6*a[1]*b[2]*b[3] + 6*a[2]*b[1]*b[3] + 6*a[3]*b[1]*b[2] + 6*b[1]*b[2]*b[3] (1, 1, 2) => 3*a[1]*a[2]*b[3] + 3*a[3]*b[1]*b[2] + 6*b[1]*b[2]*b[3] ``` """ From 0c65e56d996201f535647cb7d578c2742d38426a Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 18:22:38 +0200 Subject: [PATCH 13/22] Fix doctests in FTheoryTools. --- .../FTheoryTools/src/AbstractFTheoryModels/attributes.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl b/experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl index 5161ab59517b..374abd08a795 100644 --- a/experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl +++ b/experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl @@ -1677,7 +1677,8 @@ julia> components_of_dual_graph(qsm_model) "C7" "C8" "C9" - ⋮ + "C13" + "C14" "C16" "C17" "C21" From 8944bb2e448545e6707c91ed95be09cb6841c82b Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 18:23:15 +0200 Subject: [PATCH 14/22] Fix doctests in AffineSchemes. --- .../Schemes/AffineSchemes/Morphisms/Attributes.jl | 8 ++++---- .../Schemes/AffineSchemes/Morphisms/Constructors.jl | 4 ++-- .../Schemes/AffineSchemes/Objects/Attributes.jl | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/AlgebraicGeometry/Schemes/AffineSchemes/Morphisms/Attributes.jl b/src/AlgebraicGeometry/Schemes/AffineSchemes/Morphisms/Attributes.jl index 5e00d1ebc382..5bc7f57aea79 100644 --- a/src/AlgebraicGeometry/Schemes/AffineSchemes/Morphisms/Attributes.jl +++ b/src/AlgebraicGeometry/Schemes/AffineSchemes/Morphisms/Attributes.jl @@ -46,7 +46,7 @@ Affine scheme morphism from [x1, x2, x3] scheme(x1) to [x1, x2, x3] affine 3-space over QQ given by the pullback function - x1 -> 0 + x1 -> x1 x2 -> x2 x3 -> x3 @@ -95,7 +95,7 @@ Affine scheme morphism from [x1, x2, x3] scheme(x1) to [x1, x2, x3] affine 3-space over QQ given by the pullback function - x1 -> 0 + x1 -> x1 x2 -> x2 x3 -> x3 @@ -143,7 +143,7 @@ Ring homomorphism from multivariate polynomial ring in 3 variables over QQ to quotient of multivariate polynomial ring by ideal (x1) defined by - x1 -> 0 + x1 -> x1 x2 -> x2 x3 -> x3 ``` @@ -254,7 +254,7 @@ Affine scheme morphism from [x1, x2, x3] scheme(x1) to [x1, x2, x3] affine 3-space over QQ given by the pullback function - x1 -> 0 + x1 -> x1 x2 -> x2 x3 -> x3 diff --git a/src/AlgebraicGeometry/Schemes/AffineSchemes/Morphisms/Constructors.jl b/src/AlgebraicGeometry/Schemes/AffineSchemes/Morphisms/Constructors.jl index 2b5e02d949ff..56f8667ba51a 100644 --- a/src/AlgebraicGeometry/Schemes/AffineSchemes/Morphisms/Constructors.jl +++ b/src/AlgebraicGeometry/Schemes/AffineSchemes/Morphisms/Constructors.jl @@ -132,7 +132,7 @@ Affine scheme morphism from [x1, x2, x3] scheme(x1) to [x1, x2, x3] affine 3-space over QQ given by the pullback function - x1 -> 0 + x1 -> x1 x2 -> x2 x3 -> x3 @@ -181,7 +181,7 @@ Affine scheme morphism from [x1, x2, x3] scheme(x1) to [x1, x2, x3] affine 3-space over QQ given by the pullback function - x1 -> 0 + x1 -> x1 x2 -> x2 x3 -> x3 diff --git a/src/AlgebraicGeometry/Schemes/AffineSchemes/Objects/Attributes.jl b/src/AlgebraicGeometry/Schemes/AffineSchemes/Objects/Attributes.jl index 8b9d9f96e7e1..2ad15abb7fac 100644 --- a/src/AlgebraicGeometry/Schemes/AffineSchemes/Objects/Attributes.jl +++ b/src/AlgebraicGeometry/Schemes/AffineSchemes/Objects/Attributes.jl @@ -234,7 +234,7 @@ Affine scheme morphism from [x, y] scheme(x) to [x, y] affine 2-space over QQ given by the pullback function - x -> 0 + x -> x y -> y julia> inc == inclusion_morphism(Y, X) From 90dc0955498255f64846902cb637148671357899 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 19:00:15 +0200 Subject: [PATCH 15/22] Revert "Fix doctests in FTheoryTools." This reverts commit 0c65e56d996201f535647cb7d578c2742d38426a. --- .../FTheoryTools/src/AbstractFTheoryModels/attributes.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl b/experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl index 374abd08a795..5161ab59517b 100644 --- a/experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl +++ b/experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl @@ -1677,8 +1677,7 @@ julia> components_of_dual_graph(qsm_model) "C7" "C8" "C9" - "C13" - "C14" + ⋮ "C16" "C17" "C21" From 5d61dda13ba0b2445bfc2f96111509b7de76e844 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 19:00:21 +0200 Subject: [PATCH 16/22] Revert "Fix doctests in Algebraic statistics." This reverts commit f005ce1e58f96598933a3e0ed1e82afe6efd3f07. --- experimental/AlgebraicStatistics/src/CI.jl | 6 +- .../AlgebraicStatistics/src/Markov.jl | 6 +- .../src/PhylogeneticParametrization.jl | 112 +++--------------- 3 files changed, 16 insertions(+), 108 deletions(-) diff --git a/experimental/AlgebraicStatistics/src/CI.jl b/experimental/AlgebraicStatistics/src/CI.jl index a1f6dcea65ff..0e4d096eeeff 100644 --- a/experimental/AlgebraicStatistics/src/CI.jl +++ b/experimental/AlgebraicStatistics/src/CI.jl @@ -137,11 +137,7 @@ julia> ci_statements(["A", "B", "X", "Y"]) [B _||_ Y | {A, X}] [X _||_ Y | {}] [X _||_ Y | A] - [X _||_ Y | B] - [X _||_ Y | {A, B}] - [A _||_ X | {}] - [A _||_ X | B] - [A _||_ X | Y] + ⋮ [A _||_ X | {B, Y}] [B _||_ X | {}] [B _||_ X | A] diff --git a/experimental/AlgebraicStatistics/src/Markov.jl b/experimental/AlgebraicStatistics/src/Markov.jl index d5a2c50a4ce4..3fb204f42e1e 100644 --- a/experimental/AlgebraicStatistics/src/Markov.jl +++ b/experimental/AlgebraicStatistics/src/Markov.jl @@ -124,11 +124,7 @@ julia> ci_statements(R) [B _||_ Y | {A, X}] [X _||_ Y | {}] [X _||_ Y | A] - [X _||_ Y | B] - [X _||_ Y | {A, B}] - [A _||_ X | {}] - [A _||_ X | B] - [A _||_ X | Y] + ⋮ [A _||_ X | {B, Y}] [B _||_ X | {}] [B _||_ X | A] diff --git a/experimental/AlgebraicStatistics/src/PhylogeneticParametrization.jl b/experimental/AlgebraicStatistics/src/PhylogeneticParametrization.jl index 0788cd641b77..3bd020933569 100644 --- a/experimental/AlgebraicStatistics/src/PhylogeneticParametrization.jl +++ b/experimental/AlgebraicStatistics/src/PhylogeneticParametrization.jl @@ -62,64 +62,22 @@ Dict{Tuple{Vararg{Int64}}, QQMPolyRingElem} with 64 entries: (1, 2, 1) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] (3, 1, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] (4, 4, 2) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] - (1, 2, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (1, 2, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … (3, 1, 3) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] - (3, 2, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (3, 2, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (2, 1, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (3, 2, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … + (3, 2, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … + (2, 1, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … (3, 2, 3) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] (2, 1, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (1, 3, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (1, 4, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (2, 1, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (1, 3, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … + (1, 4, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … + (2, 1, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … (2, 2, 4) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] (4, 3, 4) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] (2, 2, 1) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] (4, 4, 4) => 1//4*a[1]*a[2]*a[3] + 3//4*b[1]*b[2]*b[3] - (4, 3, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (4, 3, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … (3, 3, 2) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] - (4, 1, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (4, 4, 1) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] - (2, 2, 3) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] - (3, 4, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (4, 3, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (4, 4, 3) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] - (4, 2, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (1, 3, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (2, 3, 2) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] - (1, 4, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (1, 3, 1) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] - (2, 4, 2) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] - (1, 1, 2) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] - (1, 4, 1) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] - (1, 3, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (3, 3, 4) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] - (1, 4, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (4, 1, 4) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] - (3, 4, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (3, 3, 1) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] - (4, 1, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (1, 2, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (3, 1, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (3, 4, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (3, 3, 3) => 1//4*a[1]*a[2]*a[3] + 3//4*b[1]*b[2]*b[3] - (4, 1, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (4, 2, 4) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] - (3, 4, 3) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] - (4, 2, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (3, 2, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (2, 3, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (4, 2, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (2, 3, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (2, 4, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (1, 1, 4) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] - (2, 1, 2) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] - (2, 4, 1) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (1, 1, 1) => 1//4*a[1]*a[2]*a[3] + 3//4*b[1]*b[2]*b[3] - (2, 3, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (2, 4, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] - (1, 1, 3) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] - (1, 2, 4) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] ⋮ => ⋮ ``` """ @@ -197,48 +155,6 @@ Dict{Tuple{Vararg{Int64}}, QQMPolyRingElem} with 64 entries: (4, 4, 4) => 0 (4, 3, 1) => 0 (3, 3, 2) => 0 - (4, 1, 2) => 0 - (4, 4, 1) => x[3, 1]*x[1, 2]*x[2, 2] - (2, 2, 3) => 0 - (3, 4, 2) => x[1, 2]*x[2, 2]*x[3, 2] - (4, 3, 3) => 0 - (4, 4, 3) => 0 - (4, 2, 2) => 0 - (1, 3, 4) => 0 - (2, 3, 2) => 0 - (1, 4, 4) => x[1, 1]*x[2, 2]*x[3, 2] - (1, 3, 1) => 0 - (2, 4, 2) => 0 - (1, 1, 2) => 0 - (1, 4, 1) => 0 - (1, 3, 3) => x[1, 1]*x[2, 2]*x[3, 2] - (3, 3, 4) => 0 - (1, 4, 3) => 0 - (4, 1, 4) => x[2, 1]*x[1, 2]*x[3, 2] - (3, 4, 4) => 0 - (3, 3, 1) => x[3, 1]*x[1, 2]*x[2, 2] - (4, 1, 1) => 0 - (1, 2, 2) => x[1, 1]*x[2, 2]*x[3, 2] - (3, 1, 2) => 0 - (3, 4, 1) => 0 - (3, 3, 3) => 0 - (4, 1, 3) => 0 - (4, 2, 4) => 0 - (3, 4, 3) => 0 - (4, 2, 1) => 0 - (3, 2, 2) => 0 - (2, 3, 4) => x[1, 2]*x[2, 2]*x[3, 2] - (4, 2, 3) => x[1, 2]*x[2, 2]*x[3, 2] - (2, 3, 1) => 0 - (2, 4, 4) => 0 - (1, 1, 4) => 0 - (2, 1, 2) => x[2, 1]*x[1, 2]*x[3, 2] - (2, 4, 1) => 0 - (1, 1, 1) => x[1, 1]*x[2, 1]*x[3, 1] - (2, 3, 3) => 0 - (2, 4, 3) => x[1, 2]*x[2, 2]*x[3, 2] - (1, 1, 3) => 0 - (1, 2, 4) => 0 ⋮ => ⋮ ``` """ @@ -276,16 +192,16 @@ Dict{Tuple{Vararg{Int64}}, QQMPolyRingElem} with 5 entries: (1, 2, 1) => 1//4*a[1]*a[3]*b[2] + 1//4*a[2]*b[1]*b[3] + 1//2*b[1]*b[2]*b[3] (1, 1, 1) => 1//4*a[1]*a[2]*a[3] + 3//4*b[1]*b[2]*b[3] (1, 2, 2) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*a[3]*b[1] + 1//2*b[1]*b[2]*b[3] - (1, 2, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//4*b[1]*b[2]*b[3] + (1, 2, 3) => 1//4*a[1]*b[2]*b[3] + 1//4*a[2]*b[1]*b[3] + 1//4*a[3]*b[1]*b[2] … (1, 1, 2) => 1//4*a[1]*a[2]*b[3] + 1//4*a[3]*b[1]*b[2] + 1//2*b[1]*b[2]*b[3] julia> p_equivclasses.classes Dict{Tuple{Vararg{Int64}}, Vector{Tuple{Vararg{Int64}}}} with 5 entries: - (1, 2, 1) => [(1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 2), (2, 3, 2), (2, 4, 2), (3, 1, 3), (3, 2, 3), (3, 4, 3), (4, 1, 4), (4, 2, 4), (4, 3, 4)] + (1, 2, 1) => [(1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 2), (2, 3, 2), (2, 4, 2… (1, 1, 1) => [(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4)] - (1, 2, 2) => [(1, 2, 2), (1, 3, 3), (1, 4, 4), (2, 1, 1), (2, 3, 3), (2, 4, 4), (3, 1, 1), (3, 2, 2), (3, 4, 4), (4, 1, 1), (4, 2, 2), (4, 3, 3)] - (1, 2, 3) => [(1, 2, 3), (1, 2, 4), (1, 3, 2), (1, 3, 4), (1, 4, 2), (1, 4, 3), (2, 1, 3), (2, 1, 4), (2, 3, 1), (2, 3, 4) … (3, 2, 1), (3, 2, 4), (3, 4, 1), (3, 4, 2), (4, 1, 2), (4, 1, 3), (4, 2, 1), (4, … - (1, 1, 2) => [(1, 1, 2), (1, 1, 3), (1, 1, 4), (2, 2, 1), (2, 2, 3), (2, 2, 4), (3, 3, 1), (3, 3, 2), (3, 3, 4), (4, 4, 1), (4, 4, 2), (4, 4, 3)] + (1, 2, 2) => [(1, 2, 2), (1, 3, 3), (1, 4, 4), (2, 1, 1), (2, 3, 3), (2, 4, 4… + (1, 2, 3) => [(1, 2, 3), (1, 2, 4), (1, 3, 2), (1, 3, 4), (1, 4, 2), (1, 4, 3… + (1, 1, 2) => [(1, 1, 2), (1, 1, 3), (1, 1, 4), (2, 2, 1), (2, 2, 3), (2, 2, 4… julia> q_equivclasses = compute_equivalent_classes(q); @@ -335,7 +251,7 @@ Dict{Tuple{Int64, Int64, Int64}, QQMPolyRingElem} with 5 entries: (1, 2, 1) => 3*a[1]*a[3]*b[2] + 3*a[2]*b[1]*b[3] + 6*b[1]*b[2]*b[3] (1, 1, 1) => a[1]*a[2]*a[3] + 3*b[1]*b[2]*b[3] (1, 2, 2) => 3*a[1]*b[2]*b[3] + 3*a[2]*a[3]*b[1] + 6*b[1]*b[2]*b[3] - (1, 2, 3) => 6*a[1]*b[2]*b[3] + 6*a[2]*b[1]*b[3] + 6*a[3]*b[1]*b[2] + 6*b[1]*b[2]*b[3] + (1, 2, 3) => 6*a[1]*b[2]*b[3] + 6*a[2]*b[1]*b[3] + 6*a[3]*b[1]*b[2] + 6*b[1]*… (1, 1, 2) => 3*a[1]*a[2]*b[3] + 3*a[3]*b[1]*b[2] + 6*b[1]*b[2]*b[3] ``` """ From 7ad7f39b4bcfff07fbaeab49984dc20ef0c2f90b Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 22:30:02 +0200 Subject: [PATCH 17/22] Remove duplicated code. --- src/Rings/MPolyMap/MPolyRing.jl | 42 +++++++++++++-------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/src/Rings/MPolyMap/MPolyRing.jl b/src/Rings/MPolyMap/MPolyRing.jl index 5be25f43ea5e..4d43595aec67 100644 --- a/src/Rings/MPolyMap/MPolyRing.jl +++ b/src/Rings/MPolyMap/MPolyRing.jl @@ -152,22 +152,23 @@ function _allunique(lst::Vector{T}) where {T<:RingElem} return all(!(x in lst[i+1:end]) for (i, x) in enumerate(lst)) end -function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) - if isdefined(F, :variable_indices) - S = codomain(F)::MPolyRing - kk = coefficient_ring(S) - r = ngens(S) - ctx = MPolyBuildCtx(S) - for (c, e) in zip(AbstractAlgebra.coefficients(u), AbstractAlgebra.exponent_vectors(u)) - ee = [0 for _ in 1:r] - for (i, k) in enumerate(e) - ee[F.variable_indices[i]] = k - end - push_term!(ctx, kk(c), ee) +function _build_poly(u::MPolyRingElem, indices::Vector{Int}, S::MPolyRing) + S = codomain(F)::MPolyRing + kk = coefficient_ring(S) + r = ngens(S) + ctx = MPolyBuildCtx(S) + for (c, e) in zip(AbstractAlgebra.coefficients(u), AbstractAlgebra.exponent_vectors(u)) + ee = [0 for _ in 1:r] + for (i, k) in enumerate(e) + ee[indices[i]] = k end - return finish(ctx) + push_term!(ctx, kk(c), ee) end + return finish(ctx) +end +function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyRing}, u) + isdefined(F, :variable_indices) && return _build_poly(u, F.variable_indices, codomain(F)) return evaluate(u, F.img_gens) end @@ -177,20 +178,9 @@ end # See the comment in MPolyQuo.jl function _evaluate_plain(F::MPolyAnyMap{<:MPolyRing, <:MPolyQuoRing}, u) - if isdefined(F, :variable_indices) - S = base_ring(codomain(F))::MPolyRing - r = ngens(S) - ctx = MPolyBuildCtx(S) - for (c, e) in zip(coefficients(u), exponents(u)) - ee = [0 for _ in 1:r] - for (i, k) in enumerate(e) - ee[F.variable_indices[i]] = k - end - push_term!(ctx, c, ee) - end - return codomain(F)(finish(ctx)) - end A = codomain(F) + R = base_ring(A) + isdefined(F, :variable_indices) && return A(_build_poly(u, F.variable_indices, R)) v = evaluate(lift(u), lift.(_images(F))) return simplify(A(v)) end From 4d17d351fa66e8c06291be3b18174a8caf58e584 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 22:35:29 +0200 Subject: [PATCH 18/22] Revert to a single internal constructor. --- src/Rings/MPolyMap/MPolyAnyMap.jl | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Rings/MPolyMap/MPolyAnyMap.jl b/src/Rings/MPolyMap/MPolyAnyMap.jl index 1e7c0879f72f..009cebd8380f 100644 --- a/src/Rings/MPolyMap/MPolyAnyMap.jl +++ b/src/Rings/MPolyMap/MPolyAnyMap.jl @@ -47,28 +47,22 @@ const _DomainTypes = Union{MPolyRing, MPolyQuoRing} # in case the mapping takes such a particularly # simple form. - function MPolyAnyMap{D, C, U, V}(domain::D, - codomain::C, - coeff_map::U, - img_gens::Vector{V}) where {D, C, U, V} - @assert V === elem_type(C) - for g in img_gens - @assert parent(g) === codomain "elements does not have the correct parent" - end - return new{D, C, U, V}(domain, codomain, coeff_map, img_gens) - end function MPolyAnyMap{D, C, U, V}(domain::D, codomain::C, coeff_map::U, img_gens::Vector{V}; check_for_mapping_of_vars::Bool=true - ) where {D <: Union{<:MPolyRing, <:MPolyQuoRing}, - C, U, V} + ) where {D, C, U, V} @assert V === elem_type(C) for g in img_gens @assert parent(g) === codomain "elements does not have the correct parent" end result = new{D, C, U, V}(domain, codomain, coeff_map, img_gens) + # If it ever turned out that doing the checks within the following if-block + # is a bottleneck, consider passing on the `check_for_mapping_of_vars` kw + # argument to the outer constructors or make the outer constructors + # call the inner one with this argument set to `false`. This way the check + # can safely be disabled. if check_for_mapping_of_vars && all(_is_gen, img_gens) && _allunique(img_gens) result.variable_indices = [findfirst(==(x), gens(codomain)) for x in img_gens] end From f7289e832d5210ef4145a0c7f056239a699426a5 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 22:36:42 +0200 Subject: [PATCH 19/22] Fix internal method. --- src/Rings/MPolyMap/MPolyRing.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Rings/MPolyMap/MPolyRing.jl b/src/Rings/MPolyMap/MPolyRing.jl index 4d43595aec67..ca21f18226ff 100644 --- a/src/Rings/MPolyMap/MPolyRing.jl +++ b/src/Rings/MPolyMap/MPolyRing.jl @@ -153,7 +153,6 @@ function _allunique(lst::Vector{T}) where {T<:RingElem} end function _build_poly(u::MPolyRingElem, indices::Vector{Int}, S::MPolyRing) - S = codomain(F)::MPolyRing kk = coefficient_ring(S) r = ngens(S) ctx = MPolyBuildCtx(S) From 9092a8a4acaa6d754237f18e000cdc23015f7757 Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Mon, 30 Sep 2024 22:53:56 +0200 Subject: [PATCH 20/22] Remove some more code duplication. --- src/Rings/mpolyquo-localizations.jl | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Rings/mpolyquo-localizations.jl b/src/Rings/mpolyquo-localizations.jl index 4e32732adc08..5294ea50c6ad 100644 --- a/src/Rings/mpolyquo-localizations.jl +++ b/src/Rings/mpolyquo-localizations.jl @@ -2735,22 +2735,9 @@ _is_gen(x::MPolyQuoLocRingElem) = is_one(lifted_denominator(x)) && _is_gen(lifte function _evaluate_plain( F::MPolyAnyMap{<:MPolyRing, CT}, u ) where {CT <: Union{<:MPolyLocRing, <:MPolyQuoLocRing}} - if isdefined(F, :variable_indices) - W = codomain(F)::MPolyLocRing - S = base_ring(W) - kk = coefficient_ring(S) - r = ngens(S) - ctx = MPolyBuildCtx(S) - for (c, e) in zip(AbstractAlgebra.coefficients(u), AbstractAlgebra.exponent_vectors(u)) - ee = [0 for _ in 1:r] - for (i, k) in enumerate(e) - ee[F.variable_indices[i]] = k - end - push_term!(ctx, kk(c), ee) - end - return W(finish(ctx)) - end - + W = codomain(F)::MPolyLocRing + S = base_ring(W) + isdefined(F, :variable_indices) && return W(_build_poly(u, F.variable_indices, S)) return evaluate(u, F.img_gens) end From 733b8f1f096b1b02addb1b41b70afdce5954964e Mon Sep 17 00:00:00 2001 From: HechtiDerLachs Date: Tue, 1 Oct 2024 09:56:43 +0200 Subject: [PATCH 21/22] Switch to the AA methods. --- src/Rings/MPolyMap/MPolyRing.jl | 4 ++-- src/Rings/mpolyquo-localizations.jl | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Rings/MPolyMap/MPolyRing.jl b/src/Rings/MPolyMap/MPolyRing.jl index ca21f18226ff..0b3b9b6044ea 100644 --- a/src/Rings/MPolyMap/MPolyRing.jl +++ b/src/Rings/MPolyMap/MPolyRing.jl @@ -193,12 +193,12 @@ function _evaluate_with_build_ctx( r = ngens(cod_ring) kk = coefficient_ring(cod_ring) ctx = MPolyBuildCtx(cod_ring) - for (q, e) in zip(coefficients(p), exponents(p)) + for (q, e) in zip(AbstractAlgebra.coefficients(p), AbstractAlgebra.exponent_vectors(p)) ee = [0 for _ in 1:r] for (i, k) in enumerate(e) ee[ind[i]] = k end - for (c, d) in zip(coefficients(q), exponents(q)) + for (c, d) in zip(AbstractAlgebra.coefficients(q), AbstractAlgebra.exponent_vectors(q)) push_term!(ctx, kk(c), ee+d) end end diff --git a/src/Rings/mpolyquo-localizations.jl b/src/Rings/mpolyquo-localizations.jl index 5294ea50c6ad..f9357af03df5 100644 --- a/src/Rings/mpolyquo-localizations.jl +++ b/src/Rings/mpolyquo-localizations.jl @@ -620,7 +620,7 @@ function is_zero_divisor(f::MPolyQuoLocRingElem{<:Field}) # once more functionality is working, it will actually do stuff and # the above signature can be widened. if is_constant(lifted_numerator(f)) && is_constant(lifted_denominator(f)) - c = first(coefficients(lift(numerator(f)))) + c = first(AbstractAlgebra.coefficients(lift(numerator(f)))) return is_zero_divisor(c) end return !is_zero(quotient(ideal(parent(f), zero(f)), ideal(parent(f), f))) @@ -1378,7 +1378,7 @@ end gb = groebner_basis(J, ordering=oo) # TODO: Speed up and use build context. - res_gens = elem_type(A)[f for f in gb if all(e -> is_zero(view(e, 1:(n+r))), exponents(f))] + res_gens = elem_type(A)[f for f in gb if all(e -> is_zero(view(e, 1:(n+r))), AbstractAlgebra.exponent_vectors(f))] img_gens2 = vcat([zero(R) for i in 1:(n+r)], gens(R)) result = ideal(R, elem_type(R)[evaluate(g, img_gens2) for g in res_gens]) return result @@ -2779,7 +2779,7 @@ function _evaluate_with_build_ctx( r = ngens(cod_ring) kk = coefficient_ring(cod_ring) ctx = MPolyBuildCtx(cod_ring) - for (q, e) in zip(coefficients(p), exponents(p)) + for (q, e) in zip(AbstractAlgebra.coefficients(p), AbstractAlgebra.exponent_vectors(p)) ee = [0 for _ in 1:r] for (i, k) in enumerate(e) ee[ind[i]] = k @@ -2794,13 +2794,13 @@ end # The following methods are only safe, because they are called # exclusively in a setup where variables map to variables # and no denominators are introduced. -_coefficients(x::MPolyRingElem) = coefficients(x) -_coefficients(x::MPolyQuoRingElem) = coefficients(lift(x)) -_coefficients(x::MPolyLocRingElem) = coefficients(numerator(x)) -_coefficients(x::MPolyQuoLocRingElem) = coefficients(lifted_numerator(x)) - -_exponents(x::MPolyRingElem) = exponents(x) -_exponents(x::MPolyQuoRingElem) = exponents(lift(x)) -_exponents(x::MPolyLocRingElem) = exponents(numerator(x)) -_exponents(x::MPolyQuoLocRingElem) = exponents(lifted_numerator(x)) +_coefficients(x::MPolyRingElem) = AbstractAlgebra.coefficients(x) +_coefficients(x::MPolyQuoRingElem) = AbstractAlgebra.coefficients(lift(x)) +_coefficients(x::MPolyLocRingElem) = AbstractAlgebra.coefficients(numerator(x)) +_coefficients(x::MPolyQuoLocRingElem) = AbstractAlgebra.coefficients(lifted_numerator(x)) + +_exponents(x::MPolyRingElem) = AbstractAlgebra.exponent_vectors(x) +_exponents(x::MPolyQuoRingElem) = AbstractAlgebra.exponent_vectors(lift(x)) +_exponents(x::MPolyLocRingElem) = AbstractAlgebra.exponent_vectors(numerator(x)) +_exponents(x::MPolyQuoLocRingElem) = AbstractAlgebra.exponent_vectors(lifted_numerator(x)) From 1892dabb2729ffa2f14b1b090350ffd2d01338d3 Mon Sep 17 00:00:00 2001 From: Simon Brandhorst Date: Tue, 1 Oct 2024 15:21:40 +0200 Subject: [PATCH 22/22] Update src/Rings/MPolyMap/MPolyAnyMap.jl --- src/Rings/MPolyMap/MPolyAnyMap.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Rings/MPolyMap/MPolyAnyMap.jl b/src/Rings/MPolyMap/MPolyAnyMap.jl index 009cebd8380f..8394cbb8f749 100644 --- a/src/Rings/MPolyMap/MPolyAnyMap.jl +++ b/src/Rings/MPolyMap/MPolyAnyMap.jl @@ -64,7 +64,8 @@ const _DomainTypes = Union{MPolyRing, MPolyQuoRing} # call the inner one with this argument set to `false`. This way the check # can safely be disabled. if check_for_mapping_of_vars && all(_is_gen, img_gens) && _allunique(img_gens) - result.variable_indices = [findfirst(==(x), gens(codomain)) for x in img_gens] + gens_codomain = gens(codomain) + result.variable_indices = [findfirst(==(x), gens_codomain) for x in img_gens] end return result end