Skip to content

Commit

Permalink
Move even more stuff from NemoStuff.jl to the right places (#1441)
Browse files Browse the repository at this point in the history
* Move `ngens(::MPolyRing)` from NemoStuff.jl to MPoly.jl

* move `preimage(::Generic.CompositeMap, ::Any)`

* Add test

* Fix import
  • Loading branch information
lgoettgens authored Sep 19, 2023
1 parent e9da0f6 commit b2e4f8e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ import ..AbstractAlgebra: order
import ..AbstractAlgebra: parent_type
import ..AbstractAlgebra: Perm
import ..AbstractAlgebra: pol_length
import ..AbstractAlgebra: preimage
import ..AbstractAlgebra: pretty
import ..AbstractAlgebra: primpart
import ..AbstractAlgebra: promote_rule
Expand Down
7 changes: 7 additions & 0 deletions src/MPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ function is_exact_type(a::Type{T}) where {S <: RingElement, T <: MPolyRingElem{S
return is_exact_type(S)
end

@doc raw"""
ngens(R::MPolyRing)
Return the number of variables in `R`.
"""
ngens(R::MPolyRing) = nvars(R)

@doc raw"""
vars(p::MPolyRingElem{T}) where {T <: RingElement}
Expand Down
6 changes: 0 additions & 6 deletions src/NemoStuff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,6 @@ end

Base.:\(f::Map, x) = preimage(f, x)

function preimage(f::Generic.CompositeMap, a)
return preimage(f.map1, preimage(f.map2, a))
end

export set_precision, set_precision!

function set_precision(f::PolyRingElem{T}, n::Int) where {T<:SeriesElem}
Expand Down Expand Up @@ -598,8 +594,6 @@ function set_precision(a::SeriesElem, i::Int)
return b
end

ngens(R::MPolyRing) = nvars(R)

Random.gentype(::Type{T}) where {T<:FinField} = elem_type(T)

import LinearAlgebra
Expand Down
4 changes: 4 additions & 0 deletions src/generic/Map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ function (f::CompositeMap{D, C})(a) where {D, C}
return f.map2(f.map1(a))::elem_type(C)
end

function preimage(f::Generic.CompositeMap{D, C}, a) where {D, C}
return preimage(f.map1, preimage(f.map2, a))
end

function show(io::IO, ::MIME"text/plain", M::CompositeMap)
io = pretty(io)
println(io, "Composite map")
Expand Down
1 change: 1 addition & 0 deletions test/generic/MPoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ end
@test ord == ordering(S)

@test nvars(parent(f)) == num_vars
@test ngens(parent(f)) == num_vars

@test isone(one(S))

Expand Down

0 comments on commit b2e4f8e

Please sign in to comment.