Skip to content

Commit

Permalink
Don't call fmpz_remove
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Oct 22, 2024
1 parent 5eec5f2 commit 569413b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/flint/fmpq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -672,25 +672,25 @@ valuation(a::QQFieldElem, b::Integer) = valuation(a, ZZRingElem(b))

function remove!(a::QQFieldElem, b::ZZRingElem)
nr = ccall((:fmpq_numerator_ptr, libflint), Ptr{ZZRingElem}, (Ref{QQFieldElem},), a)
vn = ccall((:fmpz_remove, libflint), Clong, (Ptr{ZZRingElem}, Ptr{ZZRingElem}, Ref{ZZRingElem}), nr, nr, b)
vn, nr = remove!(nr, b)
#QQFieldElem's are simplified: either num OR den will be non-trivial
if vn != 0
return vn, a
end
nr = ccall((:fmpq_denominator_ptr, libflint), Ptr{ZZRingElem}, (Ref{QQFieldElem},), a)
vn = ccall((:fmpz_remove, libflint), Clong, (Ptr{ZZRingElem}, Ptr{ZZRingElem}, Ref{ZZRingElem}), nr, nr, b)
vn, nr = remove!(nr, b)
return -vn, a
end

function valuation!(a::QQFieldElem, b::ZZRingElem)
nr = ccall((:fmpq_numerator_ptr, libflint), Ptr{ZZRingElem}, (Ref{QQFieldElem},), a)
vn = ccall((:fmpz_remove, libflint), Clong, (Ptr{ZZRingElem}, Ptr{ZZRingElem}, Ref{ZZRingElem}), nr, nr, b)
vn, nr = remove!(nr, b)
#QQFieldElem's are simplified: either num OR den will be non-trivial
if vn != 0
return vn
end
nr = ccall((:fmpq_denominator_ptr, libflint), Ptr{ZZRingElem}, (Ref{QQFieldElem},), a)
vn = ccall((:fmpz_remove, libflint), Clong, (Ptr{ZZRingElem}, Ptr{ZZRingElem}, Ref{ZZRingElem}), nr, nr, b)
vn, nr = remove!(nr, b)
return -vn
end

Expand Down
2 changes: 1 addition & 1 deletion src/flint/fmpz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ function next_prime(x::Int, proved::Bool = true)
return x < 2 ? 2 : Int(next_prime(x % UInt, proved))
end

function remove!(a::ZZRingElem, b::ZZRingElem)
function remove!(a::ZZRingElemOrPtr, b::ZZRingElemOrPtr)
v = ccall((:fmpz_remove, libflint), Clong, (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), a, a, b)
return v, a
end
Expand Down

0 comments on commit 569413b

Please sign in to comment.