Skip to content

Commit 6e20099

Browse files
authored
fix: add! for QadicFieldElem (#1990)
1 parent 2f71f71 commit 6e20099

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/flint/qadic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,9 @@ function mul!(z::QadicFieldElem, x::QadicFieldElem, y::QadicFieldElem)
618618
end
619619

620620
function add!(z::QadicFieldElem, x::QadicFieldElem, y::QadicFieldElem)
621-
z.N = min(x.N, y.N)
622621
ctx = parent(x)
623622
@ccall libflint.qadic_add(z::Ref{QadicFieldElem}, x::Ref{QadicFieldElem}, y::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing
623+
setprecision!(z, min(x.N, y.N))
624624
return z
625625
end
626626

test/flint/qadic-test.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ end
116116

117117
@test shift_right(a, 2) == R(7)^-2 + 2*R(7)^-1 + 4*7^0 + O(R, 7^3)
118118
@test shift_left(a, 2) == 7^2 + 2*7^3 + 4*7^4 + O(R, 7^5)
119+
120+
#
121+
R, _ = QadicField(19, 1, 10)
122+
x = 2*19^1 + 17*19^3 + 5*19^4 + 10*19^5 + O(R, 19^6)
123+
y = 9*19^0 + 9*19^1 + 14*19^2 + 4*19^3 + 11*19^4 + O(R, 19^5)
124+
@test isequal(add!(deepcopy(x), x, y), x + y)
125+
@test hash(add!(deepcopy(x), x, y)) == hash(x + y)
119126
end
120127

121128
@testset "QadicFieldElem.unary_ops" begin

0 commit comments

Comments
 (0)