diff --git a/src/LocalField/PowerSeries.jl b/src/LocalField/PowerSeries.jl index 710c0b8a7e..59e6624d8a 100644 --- a/src/LocalField/PowerSeries.jl +++ b/src/LocalField/PowerSeries.jl @@ -59,7 +59,7 @@ function canonical_unit(a::LaurentSeriesFieldValuationRingElem) iszero(a) && return one(parent(a), precision = precision(a)) v = valuation(a) pi = uniformizer(parent(a)) - return LaurentSeriesFieldValuationRingElem(parent(a), divexact(data(a), pi^v)) + return divexact(data(a), pi^v) end ################################################################################ @@ -104,7 +104,11 @@ function (Q::LaurentSeriesFieldValuationRing)(a::Generic.LaurentSeriesFieldElem) @assert parent(a) === _field(Q) @req valuation(a) >= 0 "Not an element of the valuation ring" R = data(Q) - b = R([polcoeff(a, i) for i in 0:pol_length(a) - 1], pol_length(a), precision(a), valuation(a)) + c = zeros(base_ring(R), pol_length(a) * Generic.scale(a)) + for i in 0:pol_length(a) - 1 + c[Generic.scale(a) * i + 1] = polcoeff(a, i) + end + b = R(c, Generic.scale(a) * pol_length(a), precision(a), valuation(a)) return Q(b) end @@ -291,11 +295,6 @@ function zero!(a::LaurentSeriesFieldValuationRingElem) return a end -function mul_red!(a::LaurentSeriesFieldValuationRingElem, b::LaurentSeriesFieldValuationRingElem, c::LaurentSeriesFieldValuationRingElem, f::Bool = false) - a.a = mul_red!(data(a), data(b), data(c), f) - return a -end - function mul!(a::LaurentSeriesFieldValuationRingElem, b::LaurentSeriesFieldValuationRingElem, c::LaurentSeriesFieldValuationRingElem) a.a = mul!(data(a), data(b), data(c)) return a diff --git a/test/LocalField.jl b/test/LocalField.jl index 9d71622c0a..2030e5fee5 100644 --- a/test/LocalField.jl +++ b/test/LocalField.jl @@ -6,5 +6,6 @@ include("LocalField/Completions.jl") include("LocalField/Ring.jl") include("LocalField/ResidueRing.jl") + include("LocalField/LaurentSeries.jl") include("LocalField/PowerSeries.jl") end diff --git a/test/LocalField/LaurentSeries.jl b/test/LocalField/LaurentSeries.jl new file mode 100644 index 0000000000..6b97cb964d --- /dev/null +++ b/test/LocalField/LaurentSeries.jl @@ -0,0 +1,26 @@ +@testset "Local field interface" begin + K, x = laurent_series_field(GF(3), 10, "x") + @test characteristic(K) == 3 + + p = uniformizer(K) + @test p == x + + p = uniformizer(K, 3, prec = 5) + @test p == x^3 + @test precision(p) == 5 + q = setprecision(p, 10) + @test precision(p) == 5 + @test precision(q) == 10 + + @test absolute_ramification_index(K) == 1 + + @test Hecke._valuation_integral(x^2) == 2 + + k, Ktok = residue_field(K) + @test k === base_ring(K) + + @test_throws ErrorException Ktok(x^-1) + @test is_zero(Ktok(x)) + @test is_one(Ktok(x + 1)) + @test is_one(Ktok\one(k)) +end diff --git a/test/LocalField/PowerSeries.jl b/test/LocalField/PowerSeries.jl index a2cb35ff27..51eba810c1 100644 --- a/test/LocalField/PowerSeries.jl +++ b/test/LocalField/PowerSeries.jl @@ -8,9 +8,64 @@ end @testset "Conformance tests" begin K, x = laurent_series_field(GF(101), 30, "x", cached = false) - R = valuation_ring(K) + R = @inferred valuation_ring(K) @test is_domain_type(elem_type(R)) @test !is_exact_type(elem_type(R)) test_Ring_interface(R) #test_EuclideanRing_interface(R) # doesn't do anything for a non-exact ring end + +@testset "Ring to field" begin + K, x = laurent_series_field(GF(101), 30, "x") + R = @inferred valuation_ring(K) + p = uniformizer(R) + a = p + p^3 + 4*p^5 + b = x + x^3 + 4*x^5 + @test K(a) == b + @test R(b) == a + + L, _ = laurent_series_field(GF(3), 10, "x") + @test_throws ErrorException L(a) + + @test_throws AssertionError R(gen(L)) + @test_throws ArgumentError R(x^-1) +end + +@testset "Euclidean functionality" begin + K, x = laurent_series_field(GF(101), 30, "x") + R = @inferred valuation_ring(K) + p = uniformizer(R) + + for a in [zero(R), p, p + 1, p^2] + for b in [p, p + 1, p^2] + q, r = divrem(a, b) + @test a == q*b + r + if !is_zero(r) + @test valuation(r) < valuation(b) + end + q = div(a, b) + if !is_zero(a - q*b) + @test valuation(a - q*b) < valuation(b) + end + end + end + + for a in [zero(R), p, p + 1, p^2] + for b in [zero(R), p, p + 1, p^2] + g, u, v = gcdx(a, b) + + @test u*a + v*b == g + if !is_zero(a) && !is_zero(b) + @test valuation(g) == min(valuation(a), valuation(b)) + end + end + end +end + +@testset "Construction" begin + # Test type stability for different field types + for F in [GF(3), Native.GF(3), Native.GF(ZZ(3)), Native.GF(3, 2), Native.GF(ZZ(3), 2)] + K, _ = laurent_series_field(F, 10, "x") + @inferred valuation_ring(K) + end +end diff --git a/test/LocalField/ResidueRing.jl b/test/LocalField/ResidueRing.jl index baf2e1f38a..e5ab20eb39 100644 --- a/test/LocalField/ResidueRing.jl +++ b/test/LocalField/ResidueRing.jl @@ -59,6 +59,12 @@ end @test is_exact_type(elem_type(R)) test_Ring_interface(R) + p = uniformizer(R) + @test p == R(pi) + @test p == R(uniformizer(K)) + p = uniformizer(R, 2) + @test p == R(pi^2) + # the euclidean conformance test seems to assume that the ring is a domain R, _ = residue_ring(O, pi) test_EuclideanRing_interface(R)