Skip to content

Commit

Permalink
Move pirated stuff to AbstractAlgebra (#1531)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Sep 13, 2023
1 parent d411bf9 commit 1da1aea
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 983 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RandomExtensions = "fb686558-2515-59ef-acaa-46db3789a887"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[compat]
AbstractAlgebra = "0.31"
AbstractAlgebra = "0.32.0"
Antic_jll = "~0.201.500"
Arb_jll = "~200.2300.000"
Calcium_jll = "~0.401.100"
Expand Down
2 changes: 0 additions & 2 deletions src/HeckeMiscFiniteField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ Base.length(F::FqPolyRepField) = BigInt(characteristic(F)^degree(F))

Base.IteratorSize(::Type{FqPolyRepField}) = Base.HasLength()

sub!(z::T, x::T, y::T) where {T} = x - y

function (A::fqPolyRepField)(x::fpFieldElem)
@assert characteristic(A) == characteristic(parent(x))
return A(lift(x))
Expand Down
48 changes: 2 additions & 46 deletions src/HeckeMiscInteger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,6 @@ function mulmod(a::UInt, b::UInt, n::UInt, ni::UInt)
ccall((:n_mulmod2_preinv, libflint), UInt, (UInt, UInt, UInt, UInt), a, b, n, ni)
end

# TODO (CF):
# should be Bernstein'ed: this is slow for large valuations
# returns the maximal v s.th. z mod p^v == 0 and z div p^v
# also useful if p is not prime....
#
# TODO: what happens to z = 0???

function remove(z::T, p::T) where {T<:Integer}
z == 0 && return (0, z)
v = 0
@assert p > 1
while mod(z, p) == 0
z = Base.div(z, p)
v += 1
end
return (v, z)
end

function remove(z::Rational{T}, p::T) where {T<:Integer}
z == 0 && return (0, z)
v, d = remove(denominator(z), p)
w, n = remove(numerator(z), p)
return w - v, n // d
end

function valuation(z::T, p::T) where {T<:Integer}
iszero(z) && error("Not yet implemented")
v = 0
@assert p > 1
while mod(z, p) == 0
z = Base.div(z, p)
v += 1
end
return v
end

function valuation(z::Rational{T}, p::T) where {T<:Integer}
z == 0 && error("Not yet implemented")
v = valuation(denominator(z), p)
w = valuation(numerator(z), p)
return w - v
end

@inline __get_rounding_mode() = Base.MPFR.rounding_raw(BigFloat)

function BigFloat(a::QQFieldElem)
Expand Down Expand Up @@ -284,8 +241,8 @@ end

/(a::BigFloat, b::ZZRingElem) = a / BigInt(b)

is_negative(n::IntegerUnion) = cmp(n, 0) < 0
is_positive(n::IntegerUnion) = cmp(n, 0) > 0
is_negative(n::ZZRingElem) = cmp(n, 0) < 0
is_positive(n::ZZRingElem) = cmp(n, 0) > 0


################################################################################
Expand Down Expand Up @@ -454,7 +411,6 @@ mod(i::IntegerUnion, r::fmpzUnitRange) = mod(i - first(r), length(r)) + first(r)
Base.:(:)(a::ZZRingElem, b::Integer) = (:)(promote(a, b)...)
Base.:(:)(a::Integer, b::ZZRingElem) = (:)(promote(a, b)...)

Base.:(:)(x::Int, y::Nothing) = 1:0
Base.:(:)(x::Int, y::ZZRingElem) = ZZRingElem(x):y

# Construct StepRange{ZZRingElem, T} where +(::ZZRingElem, zero(::T)) must be defined
Expand Down
Loading

0 comments on commit 1da1aea

Please sign in to comment.