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

Some fixes and a minor tweak #1885

Merged
merged 1 commit into from
Oct 9, 2024
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
4 changes: 4 additions & 0 deletions src/calcium/ca.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,10 @@
return z
end

function (C::CalciumField)(v::RationalUnion)
return C(flintify(v))

Check warning on line 1474 in src/calcium/ca.jl

View check run for this annotation

Codecov / codecov/patch

src/calcium/ca.jl#L1473-L1474

Added lines #L1473 - L1474 were not covered by tests
end

# todo: optimize
function (C::CalciumField)(v::Complex{Int})
return C(QQBarFieldElem(v))
Expand Down
9 changes: 2 additions & 7 deletions src/flint/FlintTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,8 @@ mutable struct zzModPolyRingElem <: PolyRingElem{zzModRingElem}
return z
end

function zzModPolyRingElem(n::UInt, a::Int)
z = new()
ccall((:nmod_poly_init, libflint), Nothing, (Ref{zzModPolyRingElem}, UInt), z, n)
ccall((:nmod_poly_set_coeff_ui, libflint), Nothing,
(Ref{zzModPolyRingElem}, Int, UInt), z, 0, mod(a, n))
finalizer(_nmod_poly_clear_fn, z)
return z
function zzModPolyRingElem(n::UInt, a::Integer)
return zzModPolyRingElem(n, mod(a, n) % UInt)
end

function zzModPolyRingElem(n::UInt, arr::Vector{ZZRingElem})
Expand Down
16 changes: 11 additions & 5 deletions src/flint/fmpz_mod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,21 @@
end

function one!(z::ZZModRingElem)
one!(z.data)
R = parent(z)
if R.n == 1
zero!(z.data)

Check warning on line 348 in src/flint/fmpz_mod.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fmpz_mod.jl#L346-L348

Added lines #L346 - L348 were not covered by tests
else
one!(z.data)

Check warning on line 350 in src/flint/fmpz_mod.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fmpz_mod.jl#L350

Added line #L350 was not covered by tests
end
return z
end

function neg!(z::ZZModRingElem, a::ZZModRingElem)
if iszero(a.data)
z.data = zero!(z.data)
function neg!(z::ZZModRingElem, x::ZZModRingElem)
R = parent(z)
if is_zero(x.data)
zero!(z.data)

Check warning on line 358 in src/flint/fmpz_mod.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fmpz_mod.jl#L355-L358

Added lines #L355 - L358 were not covered by tests
else
z.data = sub!(z.data, R.n, a.data)
sub!(z.data, R.n, x.data)

Check warning on line 360 in src/flint/fmpz_mod.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fmpz_mod.jl#L360

Added line #L360 was not covered by tests
end
return z
end
Expand Down
7 changes: 6 additions & 1 deletion src/flint/gfp_fmpz_elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,12 @@
end

function neg!(z::FpFieldElem, x::FpFieldElem)
z.data = R.n - x.data
R = parent(z)
if is_zero(x.data)
zero!(z.data)

Check warning on line 365 in src/flint/gfp_fmpz_elem.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/gfp_fmpz_elem.jl#L363-L365

Added lines #L363 - L365 were not covered by tests
else
sub!(z.data, R.n, x.data)

Check warning on line 367 in src/flint/gfp_fmpz_elem.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/gfp_fmpz_elem.jl#L367

Added line #L367 was not covered by tests
end
return z
end

Expand Down
Loading