Skip to content

Commit 56ca039

Browse files
authored
Refactor polysubst.jl (#1889)
* Refactor polysubst.jl * Distribute contents of `polysubst.jl` to other files * Tweak for towers of polys
1 parent 1c57740 commit 56ca039

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

src/AbstractAlgebra.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,6 @@ include("error.jl")
372372

373373

374374
# Generic functions to be defined after all rings
375-
include("polysubst.jl")
376-
377375
include("broadcasting.jl")
378376

379377
################################################################################

src/NCPoly.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,19 @@ rand(rng::AbstractRNG, S::NCPolyRing, deg_range::AbstractUnitRange{Int}, v...) =
727727
rand(S::NCPolyRing, deg_range, v...) = rand(Random.default_rng(), S, deg_range, v...)
728728

729729

730+
###############################################################################
731+
#
732+
# Polynomial substitution
733+
#
734+
###############################################################################
735+
736+
(f::NCPolyRingElem)(a::Integer) = evaluate(f, a)
737+
738+
function (f::NCPolyRingElem)(a::NCRingElem)
739+
return evaluate(f, a)
740+
end
741+
742+
730743
###############################################################################
731744
#
732745
# polynomial_ring constructor

src/Poly.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3359,6 +3359,26 @@ rand(S::PolyRing, degs, v...) = rand(Random.default_rng(), S, degs, v...)
33593359
#
33603360
###############################################################################
33613361

3362+
(f::PolyRingElem)(a) = subst(f, a)
3363+
3364+
function (f::PolyRingElem)(a::PolyRingElem)
3365+
typeof(f) == typeof(a) || return subst(f, a)
3366+
parent(f) == parent(a) || return subst(f, a)
3367+
return compose(f, a; inner = :second)
3368+
end
3369+
3370+
function (f::PolyRingElem{T})(a::T) where T
3371+
base_ring(f) == parent(a) || return subst(f, a)
3372+
return evaluate(f, a)
3373+
end
3374+
3375+
(f::PolyRingElem)(a::Integer) = evaluate(f, a)
3376+
3377+
function (f::PolyRingElem)(a::RingElem)
3378+
base_ring(f) == parent(a) || return subst(f, a)
3379+
return evaluate(f, a)
3380+
end
3381+
33623382
@doc raw"""
33633383
subst(f::PolyRingElem{T}, a::Any) where T <: RingElement
33643384

src/polysubst.jl

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

0 commit comments

Comments
 (0)