Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move pirated stuff to AbstractAlgebra #1531

Merged
merged 6 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -293,8 +250,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 @@ -463,7 +420,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
Loading