Skip to content

Commit

Permalink
Refactor polysubst.jl (#1889)
Browse files Browse the repository at this point in the history
* Refactor polysubst.jl

* Distribute contents of `polysubst.jl` to other files

* Tweak for towers of polys
  • Loading branch information
lgoettgens authored Dec 12, 2024
1 parent 1c57740 commit 56ca039
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
2 changes: 0 additions & 2 deletions src/AbstractAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ include("error.jl")


# Generic functions to be defined after all rings
include("polysubst.jl")

include("broadcasting.jl")

################################################################################
Expand Down
13 changes: 13 additions & 0 deletions src/NCPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,19 @@ rand(rng::AbstractRNG, S::NCPolyRing, deg_range::AbstractUnitRange{Int}, v...) =
rand(S::NCPolyRing, deg_range, v...) = rand(Random.default_rng(), S, deg_range, v...)


###############################################################################
#
# Polynomial substitution
#
###############################################################################

(f::NCPolyRingElem)(a::Integer) = evaluate(f, a)

function (f::NCPolyRingElem)(a::NCRingElem)
return evaluate(f, a)
end


###############################################################################
#
# polynomial_ring constructor
Expand Down
20 changes: 20 additions & 0 deletions src/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3359,6 +3359,26 @@ rand(S::PolyRing, degs, v...) = rand(Random.default_rng(), S, degs, v...)
#
###############################################################################

(f::PolyRingElem)(a) = subst(f, a)

function (f::PolyRingElem)(a::PolyRingElem)
typeof(f) == typeof(a) || return subst(f, a)
parent(f) == parent(a) || return subst(f, a)
return compose(f, a; inner = :second)
end

function (f::PolyRingElem{T})(a::T) where T
base_ring(f) == parent(a) || return subst(f, a)
return evaluate(f, a)
end

(f::PolyRingElem)(a::Integer) = evaluate(f, a)

function (f::PolyRingElem)(a::RingElem)
base_ring(f) == parent(a) || return subst(f, a)
return evaluate(f, a)
end

@doc raw"""
subst(f::PolyRingElem{T}, a::Any) where T <: RingElement
Expand Down
31 changes: 0 additions & 31 deletions src/polysubst.jl

This file was deleted.

0 comments on commit 56ca039

Please sign in to comment.