Skip to content

Commit

Permalink
Frac -> FracFieldElem
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Feb 27, 2024
1 parent bee70fc commit 6789ebc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Oscar = "f1435218-dba5-11e9-1e4d-f1a5fab5fc13"

[compat]
JSON = "^0.20, ^0.21"
Oscar = "0.12, 0.13, 0.14, 0.15, 1.0"
Oscar = "0.15, 1.0"
julia = "1.6"
18 changes: 9 additions & 9 deletions src/Arith.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export e2p

const FracPoly{T} = Generic.UnivPoly{Generic.Frac{T}, Generic.MPoly{Generic.Frac{T}}} where T
const FracPoly{T} = Generic.UnivPoly{Generic.FracFieldElem{T}, Generic.MPoly{Generic.FracFieldElem{T}}} where T
const NfPoly = Union{PolyRingElem{QQFieldElem}, PolyRingElem{nf_elem}}

"""
Expand Down Expand Up @@ -220,16 +220,16 @@ Base.:*(factor::Union{Int64, Rational{Int64}}, x::CycloSum{<:NfPoly}) = iszero(f
Base.:*(factor::Union{Int64, Rational{Int64}}, x::CycloFrac{<:NfPoly}) = iszero(factor) ? zero(x) : CycloFrac(x.numerator*factor, x.denominator, simplify=false)
Base.:*(x::Cyclotomic{<:NfPoly}, factor::Union{Int64, Rational{Int64}}) = factor*x

Base.:*(factor::Generic.Frac{T}, x::Cyclotomic{T}) where T<:PolyRingElem = (numerator(factor)*x)//denominator(factor)
Base.:*(x::Cyclotomic{T}, factor::Generic.Frac{T}) where T<:PolyRingElem = factor*x
Base.:*(factor::Generic.FracFieldElem{T}, x::Cyclotomic{T}) where T<:PolyRingElem = (numerator(factor)*x)//denominator(factor)
Base.:*(x::Cyclotomic{T}, factor::Generic.FracFieldElem{T}) where T<:PolyRingElem = factor*x

Base.:+(x::Union{T,Generic.Frac{T}}, y::Cyclotomic{T}) where T<:PolyRingElem = x*one(y)+y
Base.:+(x::Cyclotomic{T}, y::Union{T,Generic.Frac{T}}) where T<:PolyRingElem = y+x
Base.:+(x::Union{T,Generic.FracFieldElem{T}}, y::Cyclotomic{T}) where T<:PolyRingElem = x*one(y)+y
Base.:+(x::Cyclotomic{T}, y::Union{T,Generic.FracFieldElem{T}}) where T<:PolyRingElem = y+x
Base.:+(x::Union{Int64, Rational{Int64}}, y::Cyclotomic{<:NfPoly}) = x*one(y)+y
Base.:+(x::Cyclotomic{<:NfPoly}, y::Union{Int64, Rational{Int64}}) = y+x

Base.:-(x::Union{T,Generic.Frac{T}}, y::Cyclotomic{T}) where T<:PolyRingElem = x*one(y)-y
Base.:-(x::Cyclotomic{T}, y::Union{T,Generic.Frac{T}}) where T<:PolyRingElem = x-(y*one(x))
Base.:-(x::Union{T,Generic.FracFieldElem{T}}, y::Cyclotomic{T}) where T<:PolyRingElem = x*one(y)-y
Base.:-(x::Cyclotomic{T}, y::Union{T,Generic.FracFieldElem{T}}) where T<:PolyRingElem = x-(y*one(x))
Base.:-(x::Union{Int64, Rational{Int64}}, y::Cyclotomic{<:NfPoly}) = x*one(y)-y
Base.:-(x::Cyclotomic{<:NfPoly}, y::Union{Int64, Rational{Int64}}) = x-(y*one(x))

Expand Down Expand Up @@ -290,8 +290,8 @@ Base.://(x::T, y::Cyclotomic{T}) where T <: PolyRingElem = (x*one(y))//y
Base.://(x::Cyclotomic{<:NfPoly}, y::Int64) = (1//y)*x
Base.://(x::Int64, y::Cyclotomic{<:NfPoly}) = (x*one(y))//y

Base.://(x::Cyclotomic{T}, y::Generic.Frac{T}) where T <: PolyRingElem = (denominator(y)*x)//numerator(y)
Base.://(x::Generic.Frac{T}, y::Cyclotomic{T}) where T <: PolyRingElem = numerator(x)//(denominator(x)*y)
Base.://(x::Cyclotomic{T}, y::Generic.FracFieldElem{T}) where T <: PolyRingElem = (denominator(y)*x)//numerator(y)
Base.://(x::Generic.FracFieldElem{T}, y::Cyclotomic{T}) where T <: PolyRingElem = numerator(x)//(denominator(x)*y)
Base.://(x::Cyclotomic{<:NfPoly}, y::Rational{Int64}) = inv(y)*x
Base.://(x::Rational{Int64}, y::Cyclotomic{<:NfPoly}) = (x*one(y))//y

Expand Down
2 changes: 1 addition & 1 deletion src/CharTable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct CharTable{T} <: Table{T}
charparams::Vector{Parameters{T}} # Info about the parameters of each character type
congruence::Union{Tuple{T, T}, Nothing} # Congruence of the main parameter q (of T). q is congruent to congruence[1] mod congruence[2].
modulusring::PolyRing # Ring of polynomials of type T used in table (also ring of modulus of Cyclotomics)
argumentring::Generic.UniversalPolyRing{Generic.Frac{T}, Generic.MPoly{Generic.Frac{T}}} # Ring of argument of the Cyclotomics in table
argumentring::Generic.UniversalPolyRing{Generic.FracFieldElem{T}, Generic.MPoly{Generic.FracFieldElem{T}}} # Ring of argument of the Cyclotomics in table
information::String # General info about the table
end

Expand Down
14 changes: 7 additions & 7 deletions src/Congruence.jl
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
function setcongruence(x::FracPoly{T}, c::Union{T, Generic.Frac{T}}) where T <: NfPoly
function setcongruence(x::FracPoly{T}, c::Union{T, Generic.FracFieldElem{T}}) where T <: NfPoly
composed=parent(x)(0)
for (coeff, monomial) in zip(coefficients(x), monomials(x))
composed+=(evaluate(numerator(coeff), c)//evaluate(denominator(coeff), c))*monomial
end
return composed
end
function setcongruence(x::Cyclo{T}, c::Union{T, Generic.Frac{T}}; simplify::Bool=true) where T <: NfPoly
function setcongruence(x::Cyclo{T}, c::Union{T, Generic.FracFieldElem{T}}; simplify::Bool=true) where T <: NfPoly
Cyclo(x.modulus, setcongruence(x.argument, c), simplify=simplify)
end
function setcongruence(x::CycloSum{T}, c::Union{T, Generic.Frac{T}}; simplify::Bool=true) where T <: NfPoly
function setcongruence(x::CycloSum{T}, c::Union{T, Generic.FracFieldElem{T}}; simplify::Bool=true) where T <: NfPoly
summands=setcongruence.(x.summands, Ref(c))
CycloSum(summands, simplify=simplify)
end
function setcongruence(x::CycloFrac{T}, c::Union{T, Generic.Frac{T}}; simplify::Bool=true) where T <: NfPoly
function setcongruence(x::CycloFrac{T}, c::Union{T, Generic.FracFieldElem{T}}; simplify::Bool=true) where T <: NfPoly
CycloFrac(setcongruence(x.numerator, c), setcongruence(x.denominator, c), simplify=simplify)
end
function setcongruence(x::ParameterException{T}, c::Union{T, Generic.Frac{T}}; simplify::Bool=true) where T <: NfPoly
function setcongruence(x::ParameterException{T}, c::Union{T, Generic.FracFieldElem{T}}; simplify::Bool=true) where T <: NfPoly
ParameterException(setcongruence(x.expression, c), simplify=simplify)
end

"""
simplify(x::Union{Cyclotomic{T}, ParameterException{T}}, c::T, cinv::Generic.Frac{T}) where T <: NfPoly
simplify(x::Union{Cyclotomic{T}, ParameterException{T}}, c::T, cinv::Generic.FracFieldElem{T}) where T <: NfPoly
Simplify `x` by replacing the generator of the polynomials of type `T` by `c` and then back to `cinv`.
This is used to remove terms that look fractional but are in fact whole.
"""
function simplify(x::Union{Cyclotomic{T}, ParameterException{T}}, c::T, cinv::Generic.Frac{T}) where T <: NfPoly
function simplify(x::Union{Cyclotomic{T}, ParameterException{T}}, c::T, cinv::Generic.FracFieldElem{T}) where T <: NfPoly
setcongruence(setcongruence(x, c), cinv, simplify=false)
end

Expand Down
4 changes: 2 additions & 2 deletions src/PrintToTex/Factor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ end
Base.show(io::IO, z::ZetaFrac) = print(io, "($(z.numerator)) // ($(z.denominator))")
Base.show(io::IO, m::MIME{Symbol("text/latex")}, z::ZetaFrac) = print(io, "\\frac{$(repr("text/latex", z.numerator))}{$(repr("text/latex",z.denominator))}")

function ordexp(b::Generic.Frac{QQPolyRingElem})
function ordexp(b::Generic.FracFieldElem{QQPolyRingElem})
num, den = numerator(b), denominator(b)
d = lcm(denominator.(collect(coefficients(num))))
return num*d, den*d
end
function ordexp(b::Generic.Frac{Generic.Poly{nf_elem}})
function ordexp(b::Generic.FracFieldElem{Generic.Poly{nf_elem}})
num, den = numerator(b), denominator(b)
d = lcm(denominator.(coeff.(collect(coefficients(num)),0)))
return num*d, den*d
Expand Down

0 comments on commit 6789ebc

Please sign in to comment.