Skip to content

Commit

Permalink
Deduplicate set_precision! (#1844)
Browse files Browse the repository at this point in the history
Use "abstract" `set_precision!`
  • Loading branch information
joschmitt committed Sep 18, 2024
1 parent e1a2e98 commit 8c90844
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 85 deletions.
1 change: 1 addition & 0 deletions src/Nemo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ import AbstractAlgebra: Set
import AbstractAlgebra: set_attribute!
import AbstractAlgebra: Solve
import AbstractAlgebra: terse
import AbstractAlgebra: truncate!

AbstractAlgebra.@include_deprecated_bindings()

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

characteristic(::QQAbsPowerSeriesRing) = 0

function set_precision!(z::QQAbsPowerSeriesRingElem, k::Int)
k < 0 && throw(DomainError(k, "Precision must be non-negative"))
z = truncate!(z, k)
z.prec = k
return z
end

###############################################################################
#
# Similar
Expand Down
10 changes: 0 additions & 10 deletions src/flint/fmpq_rel_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,6 @@ end

characteristic(::QQRelPowerSeriesRing) = 0

function set_precision!(z::QQRelPowerSeriesRingElem, k::Int)
k < 0 && throw(DomainError(k, "Precision must be non-negative"))
z = truncate!(z, k)
z.prec = k
if is_zero(z)
z.val = k
end
return z
end

###############################################################################
#
# Similar
Expand Down
7 changes: 0 additions & 7 deletions src/flint/fmpz_abs_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,6 @@ end

characteristic(::ZZAbsPowerSeriesRing) = 0

function set_precision!(z::ZZAbsPowerSeriesRingElem, k::Int)
k < 0 && throw(DomainError(k, "Precision must be non-negative"))
z = truncate!(z, k)
z.prec = k
return z
end

###############################################################################
#
# Similar
Expand Down
7 changes: 0 additions & 7 deletions src/flint/fmpz_mod_abs_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,6 @@ for (etype, rtype, ctype, mtype, brtype, flint_fn) in (

characteristic(R::($rtype)) = characteristic(base_ring(R))

function set_precision!(z::($etype), k::Int)
k < 0 && throw(DomainError(k, "Precision must be non-negative"))
z = truncate!(z, k)
z.prec = k
return z
end

###############################################################################
#
# Similar
Expand Down
10 changes: 0 additions & 10 deletions src/flint/fmpz_mod_rel_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,6 @@ for (etype, rtype, ctype, mtype, brtype, flint_fn) in (

characteristic(R::($rtype)) = modulus(R)

function set_precision!(z::($etype), k::Int)
k < 0 && throw(DomainError(k, "Precision must be non-negative"))
z = truncate!(z, k)
z.prec = k
if is_zero(z)
z.val = k
end
return z
end

###############################################################################
#
# Similar
Expand Down
10 changes: 0 additions & 10 deletions src/flint/fmpz_rel_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,6 @@ end

characteristic(::ZZRelPowerSeriesRing) = 0

function set_precision!(z::ZZRelPowerSeriesRingElem, k::Int)
k < 0 && throw(DomainError(k, "Precision must be non-negative"))
z = truncate!(z, k)
z.prec = k
if is_zero(z)
z.val = k
end
return z
end

###############################################################################
#
# Similar
Expand Down
7 changes: 0 additions & 7 deletions src/flint/fq_abs_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ for (etype, rtype, ctype, btype, flint_fn, flint_tail) in (

characteristic(R::($rtype)) = characteristic(base_ring(R))

function set_precision!(z::($etype), k::Int)
k < 0 && throw(DomainError(k, "Precision must be non-negative"))
z = truncate!(z, k)
z.prec = k
return z
end

###############################################################################
#
# Similar
Expand Down
10 changes: 0 additions & 10 deletions src/flint/fq_rel_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,6 @@ for (etype, rtype, ctype, btype, flint_fn, flint_tail) in (

characteristic(R::($rtype)) = characteristic(base_ring(R))

function set_precision!(z::($etype), k::Int)
k < 0 && throw(DomainError(k, "Precision must be non-negative"))
z = truncate!(z, k)
z.prec = k
if is_zero(z)
z.val = k
end
return z
end

###############################################################################
#
# Similar
Expand Down
7 changes: 0 additions & 7 deletions src/flint/nmod_abs_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,6 @@ for (etype, rtype, mtype, brtype, flint_fn) in (

characteristic(R::($rtype)) = characteristic(base_ring(R))

function set_precision!(z::($etype), k::Int)
k < 0 && throw(DomainError(k, "Precision must be non-negative"))
z = truncate!(z, k)
z.prec = k
return z
end

###############################################################################
#
# Similar
Expand Down
10 changes: 0 additions & 10 deletions src/flint/nmod_rel_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,6 @@ for (etype, rtype, mtype, brtype, flint_fn) in (

characteristic(R::($rtype)) = modulus(R)

function set_precision!(z::($etype), k::Int)
k < 0 && throw(DomainError(k, "Precision must be non-negative"))
z = truncate!(z, k)
z.prec = k
if is_zero(z)
z.val = k
end
return z
end

###############################################################################
#
# Similar
Expand Down

0 comments on commit 8c90844

Please sign in to comment.