Skip to content

Commit

Permalink
fix: add! for QadicFieldElem (#1990)
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma authored Jan 13, 2025
1 parent 2f71f71 commit 6e20099
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/flint/qadic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,9 @@ function mul!(z::QadicFieldElem, x::QadicFieldElem, y::QadicFieldElem)
end

function add!(z::QadicFieldElem, x::QadicFieldElem, y::QadicFieldElem)
z.N = min(x.N, y.N)
ctx = parent(x)
@ccall libflint.qadic_add(z::Ref{QadicFieldElem}, x::Ref{QadicFieldElem}, y::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing
setprecision!(z, min(x.N, y.N))
return z
end

Expand Down
7 changes: 7 additions & 0 deletions test/flint/qadic-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ end

@test shift_right(a, 2) == R(7)^-2 + 2*R(7)^-1 + 4*7^0 + O(R, 7^3)
@test shift_left(a, 2) == 7^2 + 2*7^3 + 4*7^4 + O(R, 7^5)

#
R, _ = QadicField(19, 1, 10)
x = 2*19^1 + 17*19^3 + 5*19^4 + 10*19^5 + O(R, 19^6)
y = 9*19^0 + 9*19^1 + 14*19^2 + 4*19^3 + 11*19^4 + O(R, 19^5)
@test isequal(add!(deepcopy(x), x, y), x + y)
@test hash(add!(deepcopy(x), x, y)) == hash(x + y)
end

@testset "QadicFieldElem.unary_ops" begin
Expand Down

0 comments on commit 6e20099

Please sign in to comment.