diff --git a/docs/make.jl b/docs/make.jl index 09a0187eda..cf9e315d1c 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -46,7 +46,6 @@ makedocs( "function_field.md", "finfield.md", "real.md", - "numberfield.md", ], "Groups" => [ "perm.md", diff --git a/docs/src/constructors.md b/docs/src/constructors.md index 8fe7fb1c22..c1adbdaa85 100644 --- a/docs/src/constructors.md +++ b/docs/src/constructors.md @@ -62,7 +62,7 @@ AbstractAlgebra.jl and explain what mathematical domains they represent. | $R = \mathbb{Z}$ | `R = ZZ` | | $R = \mathbb{Q}$ | `R = QQ` | | $R = \mathbb{F}_{p}$ | `R = GF(p)` | -| $R = \mathbb{Z}/n\mathbb{Z}$ | `R = residue_ring(ZZ, n)` | +| $R = \mathbb{Z}/n\mathbb{Z}$ | `R, = residue_ring(ZZ, n)` | | $S = R[x]$ | `S, x = polynomial_ring(R, :x)` | | $S = R[x, y]$ | `S, (x, y) = polynomial_ring(R, [:x, :y])` | | $S = R\langle x, y\rangle$ | `S, (x, y) = free_associative_algebra(R, [:x, :y])` | @@ -77,10 +77,9 @@ AbstractAlgebra.jl and explain what mathematical domains they represent. | Puiseux series field to precision $n$| `S, x = puiseux_series_field(R, n, :x)` | | $S = K(x)(y)/(f)$ | `S, y = function_field(f, :y)` with $f\in K(x)[t]$ | | $S = \mathrm{Frac}_R$ | `S = fraction_field(R)` | -| $S = R/(f)$ | `S = residue_ring(R, f)` | -| $S = R/(f)$ (with $(f)$ maximal) | `S = residue_field(R, f)` | +| $S = R/(f)$ | `S, = residue_ring(R, f)` | +| $S = R/(f)$ (with $(f)$ maximal) | `S, = residue_field(R, f)` | | $S = \mathrm{Mat}_{m\times n}(R)$ | `S = matrix_space(R, m, n)` | -| $S = \mathbb{Q}[x]/(f)$ | `S, a = number_field(f, :a)` | ## Parent objects with variable names diff --git a/docs/src/index.md b/docs/src/index.md index 58a3b3ae9c..320638647d 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -75,7 +75,7 @@ R = GF(7) S, y = polynomial_ring(R, "y") -T = residue_ring(S, y^3 + 3y + 1) +T, = residue_ring(S, y^3 + 3y + 1) U, z = polynomial_ring(T, "z") diff --git a/docs/src/matrix.md b/docs/src/matrix.md index 39d9f31726..177298fecd 100644 --- a/docs/src/matrix.md +++ b/docs/src/matrix.md @@ -827,8 +827,7 @@ fflu{T <: RingElem}(::MatElem{T}, ::SymmetricGroup) julia> R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over rationals, x) -julia> K, a = number_field(x^3 + 3x + 1, "a") -(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x) +julia> K, = residue_field(R, x^3 + 3x + 1); a = K(x); julia> S = matrix_space(K, 3, 3) Matrix space of 3 rows and 3 columns @@ -865,8 +864,7 @@ is_rref{T <: FieldElem}(::MatElem{T}) julia> R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over rationals, x) -julia> K, a = number_field(x^3 + 3x + 1, "a") -(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x) +julia> K, = residue_field(R, x^3 + 3x + 1); a = K(x); julia> S = matrix_space(K, 3, 3) Matrix space of 3 rows and 3 columns @@ -995,8 +993,7 @@ can_solve_left_reduced_triu{T <: RingElement}(::MatElem{T}, ::MatElem{T}) julia> R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over rationals, x) -julia> K, a = number_field(x^3 + 3x + 1, "a") -(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x) +julia> K, = residue_field(R, x^3 + 3x + 1); a = K(x); julia> S = matrix_space(K, 3, 3) Matrix space of 3 rows and 3 columns @@ -1120,8 +1117,7 @@ is_invertible{T <: RingElement}(::MatrixElem{T}) julia> R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over rationals, x) -julia> K, a = number_field(x^3 + 3x + 1, "a") -(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x) +julia> K, = residue_field(R, x^3 + 3x + 1); a = K(x); julia> S = matrix_space(K, 3, 3) Matrix space of 3 rows and 3 columns @@ -1211,8 +1207,7 @@ is_hessenberg{T <: RingElem}(::MatElem{T}) **Examples** ```jldoctest -julia> R = residue_ring(ZZ, 7) -Residue ring of integers modulo 7 +julia> R, = residue_ring(ZZ, 7); julia> S = matrix_space(R, 4, 4) Matrix space of 4 rows and 4 columns diff --git a/docs/src/numberfield.md b/docs/src/numberfield.md deleted file mode 100644 index 7dff2c8444..0000000000 --- a/docs/src/numberfield.md +++ /dev/null @@ -1,54 +0,0 @@ -```@meta -CurrentModule = AbstractAlgebra -DocTestSetup = quote - using AbstractAlgebra -end -``` - -# Number fields - -AbstractAlgebra.jl provides a very naive implementation of number fields. This allows -arithmetic in algebraic number fields, which are currently modeled as $\mathbb{Q}[x]$ -modulo an irreducible polynomial, i.e. as a residue field. - -The definition of the number field constructor is given in -`src/generic/NumberField.jl` but no type is defined for a number field. The definition -mainly exists for testing purposes. It may later be replaced by a more standard -implementation. For a more fully fleshed out number field implementation (based on a -very high performance C library), see Nemo.jl. - -## Number field constructors - -In order to construct number fields in AbstractAlgebra.jl, one must first construct the -field itself. This is accomplished with the following constructor. - -```julia -number_field(f::Generic.Poly{Rational{BigInt}}, s::VarName, t = "\$"; cached::Bool = true) -``` - -Given an irreducible defining polynomial $f$ in $\mathbb{Q}[x]$, return a tuple $(K, x)$ -consisting of the number field defined by that polynomial and a generator. The string -fields are currently ignored, but are reserved for future use. - -Currently the generator of the number field prints the same way as the variable in -$\mathbb{Q}[x]$. - -**Examples** - -```jldoctest -julia> R, x = polynomial_ring(QQ, "x") -(Univariate polynomial ring in x over rationals, x) - -julia> K, a = number_field(x^3 + 3x + 1, "a") -(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x) - -julia> f = a^2 + 2a + 7 -x^2 + 2*x + 7 - -``` - -## Basic field functionality - -The number field module in AbstractAlgebra.jl implements the full Field and residue_ring -interfaces. - diff --git a/docs/src/polynomial.md b/docs/src/polynomial.md index 4a3346cf68..d4d991c134 100644 --- a/docs/src/polynomial.md +++ b/docs/src/polynomial.md @@ -298,8 +298,7 @@ gcdinv(f::PolyRingElem, g::PolyRingElem) julia> R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over rationals, x) -julia> S = residue_ring(R, x^3 + 3x + 1) -Residue ring of univariate polynomial ring modulo x^3 + 3*x + 1 +julia> S, = residue_ring(R, x^3 + 3x + 1); julia> T, y = polynomial_ring(S, "y") (Univariate polynomial ring in y over residue ring, y) @@ -464,8 +463,7 @@ julia> S, y = polynomial_ring(R, "y") julia> T, z = polynomial_ring(QQ, "z") (Univariate polynomial ring in z over rationals, z) -julia> U = residue_ring(ZZ, 17) -Residue ring of integers modulo 17 +julia> U, = residue_ring(ZZ, 17); julia> V, w = polynomial_ring(U, "w") (Univariate polynomial ring in w over residue ring, w) @@ -859,8 +857,7 @@ julia> S, y = polynomial_ring(R, "y") julia> T, z = polynomial_ring(QQ, "z") (Univariate polynomial ring in z over rationals, z) -julia> U = residue_ring(T, z^3 + 3z + 1) -Residue ring of univariate polynomial ring modulo z^3 + 3*z + 1 +julia> U, = residue_ring(T, z^3 + 3z + 1); julia> V, w = polynomial_ring(U, "w") (Univariate polynomial ring in w over residue ring, w) diff --git a/docs/src/residue.md b/docs/src/residue.md index 8a187e3e62..02857bc344 100644 --- a/docs/src/residue.md +++ b/docs/src/residue.md @@ -46,8 +46,9 @@ residue_field(R::Ring, m::RingElem; cached::Bool = true) ``` Given a base ring `R` and residue $m$ contained in this ring, return the parent object -of the residue ring $R/(m)$. By default the parent object `S` will depend only on `R` -and `m` and will be cached. Setting the optional argument `cached` to `false` will +of the residue ring $R/(m)$ together with the canonical projection. By default +the parent object `S` will depend only on `R` and `m` and will be cached. +Setting the optional argument `cached` to `false` will prevent the parent object `S` from being cached. The `residue_field` constructor does the same thing as the `residue_ring` constructor, @@ -71,8 +72,7 @@ resulting parent objects to coerce various elements into the residue ring. julia> R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over rationals, x) -julia> S = residue_ring(R, x^3 + 3x + 1) -Residue ring of univariate polynomial ring modulo x^3 + 3*x + 1 +julia> S, = residue_ring(R, x^3 + 3x + 1); julia> f = S() 0 @@ -174,8 +174,7 @@ modulus(::ResElem) julia> R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over rationals, x) -julia> S = residue_ring(R, x^3 + 3x + 1) -Residue ring of univariate polynomial ring modulo x^3 + 3*x + 1 +julia> S, = residue_ring(R, x^3 + 3x + 1); julia> f = S(x + 1) x + 1 @@ -229,8 +228,7 @@ Base.inv(::ResElem) julia> R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over rationals, x) -julia> S = residue_ring(R, x^3 + 3x + 1) -Residue ring of univariate polynomial ring modulo x^3 + 3*x + 1 +julia> S, = residue_ring(R, x^3 + 3x + 1); julia> f = S(x + 1) x + 1 @@ -252,8 +250,7 @@ gcd{T <: RingElem}(::ResElem{T}, ::ResElem{T}) julia> R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over rationals, x) -julia> S = residue_ring(R, x^3 + 3x + 1) -Residue ring of univariate polynomial ring modulo x^3 + 3*x + 1 +julia> S, = residue_ring(R, x^3 + 3x + 1); julia> f = S(x + 1) x + 1 @@ -304,8 +301,7 @@ rand(R::ResidueRing, v...) **Examples** ```jldoctest; setup = :(import Random; Random.seed!(42)) -julia> R = residue_ring(ZZ, 7) -Residue ring of integers modulo 7 +julia> R, = residue_ring(ZZ, 7); julia> f = rand(R, 0:6) 4 @@ -313,9 +309,6 @@ julia> f = rand(R, 0:6) julia> S, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over rationals, x) -julia> U = residue_field(S, x^3 + 3x + 1) -Residue field of univariate polynomial ring modulo x^3 + 3*x + 1 - julia> g = rand(S, 2:2, -10:10) -1//4*x^2 - 2//7*x + 1 ``` diff --git a/docs/src/total_fraction.md b/docs/src/total_fraction.md index 6588768c7d..5fd0e4d79f 100644 --- a/docs/src/total_fraction.md +++ b/docs/src/total_fraction.md @@ -265,8 +265,7 @@ rand(R::TotFracRing, v...) **Examples** ```jldoctest; setup = :(import Random; Random.seed!(42)) -julia> R = residue_ring(ZZ, 12) -Residue ring of integers modulo 12 +julia> R, = residue_ring(ZZ, 12); julia> K = total_ring_of_fractions(R) Total ring of fractions of Residue ring of integers modulo 12 diff --git a/docs/src/types.md b/docs/src/types.md index be04fa0418..18769e0a36 100644 --- a/docs/src/types.md +++ b/docs/src/types.md @@ -34,7 +34,7 @@ corresponding to the ring $\mathbb{Z}/7\mathbb{Z}$. We then create a new element of this ring by calling the parent object `R`. ```julia -R = residue_ring(ZZ, 7) +R, = residue_ring(ZZ, 7) a = R(3) ``` diff --git a/src/AbstractAlgebra.jl b/src/AbstractAlgebra.jl index 43fa395650..dd3ee2c146 100644 --- a/src/AbstractAlgebra.jl +++ b/src/AbstractAlgebra.jl @@ -16,7 +16,7 @@ using Test # for "interface-conformance" functions # A list of all symbols external packages should not import from AbstractAlgebra const import_exclude = [:import_exclude, :QQ, :ZZ, - :RealField, :number_field, :NumberField, :GF, + :RealField, :GF, :AbstractAlgebra, :inv, :log, :exp, :sqrt, :div, :divrem, :numerator, :denominator, @@ -677,6 +677,8 @@ import .Generic: dense_matrix_type import .Generic: dim import .Generic: disable_cache! import .Generic: downscale +import .Generic: EuclideanRingResidueField +import .Generic: EuclideanRingResidueRing import .Generic: enable_cache! import .Generic: exp_gcd import .Generic: exponent @@ -737,7 +739,6 @@ import .Generic: norm import .Generic: normal_form import .Generic: normalise import .Generic: num_coeff -import .Generic: number_field import .Generic: one import .Generic: order import .Generic: ordering @@ -883,6 +884,8 @@ export divhigh export divides export domain export downscale +export EuclideanRingResidueField +export EuclideanRingResidueRing export elem_type export enable_cache! export evaluate @@ -1071,7 +1074,6 @@ export normal_form export normalise export nullspace export num_coeff -export number_field export O export one export order diff --git a/src/Aliases.jl b/src/Aliases.jl index dc3830975c..d60f325400 100644 --- a/src/Aliases.jl +++ b/src/Aliases.jl @@ -54,7 +54,6 @@ Base.@deprecate_binding LaurentPolynomialRing laurent_polynomial_ring Base.@deprecate_binding LaurentSeriesRing laurent_series_ring Base.@deprecate_binding LaurentSeriesField laurent_series_field Base.@deprecate_binding FractionField fraction_field -Base.@deprecate_binding NumberField number_field Base.@deprecate_binding FunctionField function_field Base.@deprecate_binding RationalFunctionField rational_function_field diff --git a/src/Generic.jl b/src/Generic.jl index 68a00149e6..f051c8586a 100644 --- a/src/Generic.jl +++ b/src/Generic.jl @@ -266,8 +266,6 @@ include("generic/Residue.jl") include("generic/ResidueField.jl") -include("generic/NumberField.jl") - include("generic/Poly.jl") include("generic/NCPoly.jl") diff --git a/src/Matrix.jl b/src/Matrix.jl index 4604ce338c..4c1845f479 100644 --- a/src/Matrix.jl +++ b/src/Matrix.jl @@ -2226,21 +2226,10 @@ Return the determinant of the matrix $M$. We assume $M$ is square. julia> R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over rationals, x) -julia> K, a = number_field(x^3 + 3x + 1, "a") -(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x) - -julia> S = matrix_space(K, 3, 3) -Matrix space of 3 rows and 3 columns - over residue field of univariate polynomial ring modulo x^3 + 3*x + 1 - -julia> A = S([K(0) 2a + 3 a^2 + 1; a^2 - 2 a - 1 2a; a^2 + 3a + 1 2a K(1)]) -[ 0 2*x + 3 x^2 + 1] -[ x^2 - 2 x - 1 2*x] -[x^2 + 3*x + 1 2*x 1] +julia> A = R[x 1; 1 x^2]; julia> d = det(A) -11*x^2 - 30*x - 5 - +x^3 - 1 ``` """ function det(M::MatrixElem{T}) where {T <: RingElement} @@ -2599,24 +2588,10 @@ Return the rank of the matrix $M$. # Examples ```jldoctest; setup = :(using AbstractAlgebra) -julia> R, x = polynomial_ring(QQ, "x") -(Univariate polynomial ring in x over rationals, x) - -julia> K, a = number_field(x^3 + 3x + 1, "a") -(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x) - -julia> S = matrix_space(K, 3, 3) -Matrix space of 3 rows and 3 columns - over residue field of univariate polynomial ring modulo x^3 + 3*x + 1 - -julia> A = S([K(0) 2a + 3 a^2 + 1; a^2 - 2 a - 1 2a; a^2 + 3a + 1 2a K(1)]) -[ 0 2*x + 3 x^2 + 1] -[ x^2 - 2 x - 1 2*x] -[x^2 + 3*x + 1 2*x 1] +julia> A = QQ[1 2; 3 4]; julia> d = rank(A) -3 - +2 ``` """ function rank(M::MatrixElem{T}) where {T <: RingElement} @@ -4469,8 +4444,7 @@ the resulting polynomial is an element of it. # Examples ```jldoctest; setup = :(using AbstractAlgebra) -julia> R = residue_ring(ZZ, 7) -Residue ring of integers modulo 7 +julia> R, = residue_ring(ZZ, 7); julia> S = matrix_space(R, 4, 4) Matrix space of 4 rows and 4 columns @@ -6276,8 +6250,7 @@ preserves the minimal and characteristic polynomials of a matrix. # Examples ```jldoctest; setup = :(using AbstractAlgebra) -julia> R = residue_ring(ZZ, 7) -Residue ring of integers modulo 7 +julia> R, = residue_ring(ZZ, 7); julia> S = matrix_space(R, 4, 4) Matrix space of 4 rows and 4 columns diff --git a/src/Residue.jl b/src/Residue.jl index 72bf5dbc50..8874e7cec6 100644 --- a/src/Residue.jl +++ b/src/Residue.jl @@ -453,16 +453,16 @@ function residue_ring(R::Ring, a::RingElement; cached::Bool = true) # do matrices over Z/0 using a Z/nZ type. The former is multiprecision, the latter not. iszero(a) && throw(DomainError(a, "Modulus must be nonzero")) T = elem_type(R) - - return Generic.EuclideanRingResidueRing{T}(R(a), cached) + S = Generic.EuclideanRingResidueRing{T}(R(a), cached) + return S, Generic.EuclideanRingResidueMap(R, S) end function residue_ring(R::PolyRing, a::RingElement; cached::Bool = true) iszero(a) && throw(DomainError(a, "Modulus must be nonzero")) !is_unit(leading_coefficient(a)) && throw(DomainError(a, "Non-invertible leading coefficient")) T = elem_type(R) - - return Generic.EuclideanRingResidueRing{T}(R(a), cached) + S = Generic.EuclideanRingResidueRing{T}(R(a), cached) + return S, Generic.EuclideanRingResidueMap(R, S) end @doc raw""" @@ -474,8 +474,7 @@ where the section is the lift of an element of the residue field back to the ring `R`. """ function quo(R::Ring, a::RingElement; cached::Bool = true) - S = residue_ring(R, a; cached=cached) - f = map_with_section_from_func(x->S(x), x->lift(x), R, S) + S, f = residue_ring(R, a; cached = cached) return S, f end diff --git a/src/ResidueField.jl b/src/ResidueField.jl index 1a40c270ee..6d686bb810 100644 --- a/src/ResidueField.jl +++ b/src/ResidueField.jl @@ -497,8 +497,8 @@ to the constructor with the same base ring $R$ and element $a$. function residue_field(R::Ring, a::RingElement; cached::Bool = true) iszero(a) && throw(DivideError()) T = elem_type(R) - - return Generic.EuclideanRingResidueField{T}(R(a), cached) + S = Generic.EuclideanRingResidueField{T}(R(a), cached) + return S, Generic.EuclideanRingResidueMap(R, S) end @doc raw""" @@ -510,7 +510,6 @@ where the section is the lift of an element of the residue field back to the ring `R`. """ function quo(::Type{Field}, R::Ring, a::RingElement; cached::Bool = true) - S = residue_field(R, a; cached=cached) - f = map_with_section_from_func(x->S(x), x->lift(x), R, S) + S, f = residue_field(R, a; cached = cached) return S, f end diff --git a/src/generic/GenericTypes.jl b/src/generic/GenericTypes.jl index fce6d9f7b2..34797491cc 100644 --- a/src/generic/GenericTypes.jl +++ b/src/generic/GenericTypes.jl @@ -637,6 +637,21 @@ mutable struct EuclideanRingResidueFieldElem{T <: RingElement} <: AbstractAlgebr EuclideanRingResidueFieldElem{T}(a::T) where T <: RingElement = new{T}(a) end +################################################################################ +# +# Residue ring/field map +# +################################################################################ + +mutable struct EuclideanRingResidueMap{S, T} <: AbstractAlgebra.Map{S, T, AbstractAlgebra.SetMap, EuclideanRingResidueMap} + domain::S + codomain::T + + function EuclideanRingResidueMap(domain::S, codomain::T) where {S, T} + return new{S, T}(domain, codomain) + end +end + ############################################################################### # # RelPowerSeriesRing / RelSeries diff --git a/src/generic/NumberField.jl b/src/generic/NumberField.jl deleted file mode 100644 index b3f0b37cf5..0000000000 --- a/src/generic/NumberField.jl +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################### -# -# number_field.jl - Generic number fields (mainly for test code) -# -############################################################################### - -############################################################################### -# -# Basic manipulation -# -############################################################################### - -function gen(R::EuclideanRingResidueField{PolyRingElem{Rational{BigInt}}}) - return R(gen(base_ring(R))) -end - -############################################################################### -# -# Random generation -# -############################################################################### - -function RandomExtensions.make(S::EuclideanRingResidueField{Generic.Poly{Rational{BigInt}}}, vs...) - R = base_ring(S) - if length(vs) == 1 && elem_type(R) == Random.gentype(vs[1]) - Make(S, vs[1]) - else - n = degree(S.modulus) - Make(S, make(base_ring(S), n - 1:n - 1, vs...)) - end -end - -############################################################################### -# -# number_field constructor (mainly for test code) -# -############################################################################### - -function number_field(a::Poly{Rational{BigInt}}, ::VarName; cached::Bool=true) - S = parent(a) - R = residue_field(S, a, cached=cached) - x = gen(S) - return R, R(x) -end - diff --git a/src/generic/Residue.jl b/src/generic/Residue.jl index daa5210a17..c1aded430e 100644 --- a/src/generic/Residue.jl +++ b/src/generic/Residue.jl @@ -60,3 +60,23 @@ function (a::EuclideanRingResidueRing{T})(b::AbstractAlgebra.ResElem{T}) where { return b end +################################################################################ +# +# Map +# +################################################################################ + +domain(f::EuclideanRingResidueMap) = f.domain + +codomain(f::EuclideanRingResidueMap) = f.codomain + +function image(f::EuclideanRingResidueMap, a) + return codomain(f)(a) +end + +(f::EuclideanRingResidueMap)(a) = image(f, a) + +function preimage(f::EuclideanRingResidueMap, a) + parent(a) != codomain(f) && error("Not an element of the codomain") + return data(a) +end diff --git a/src/generic/ResidueField.jl b/src/generic/ResidueField.jl index 4e80f9b120..110fb30abd 100644 --- a/src/generic/ResidueField.jl +++ b/src/generic/ResidueField.jl @@ -59,3 +59,19 @@ function (a::EuclideanRingResidueField{T})(b::AbstractAlgebra.ResFieldElem{T}) w a != parent(b) && error("Operation on incompatible objects") return b end + +################################################################################ +# +# Random random functionality +# +################################################################################ + +function RandomExtensions.make(S::EuclideanRingResidueField{Generic.Poly{Rational{BigInt}}}, vs...) + R = base_ring(S) + if length(vs) == 1 && elem_type(R) == Random.gentype(vs[1]) + Make(S, vs[1]) + else + n = degree(S.modulus) + Make(S, make(base_ring(S), n - 1:n - 1, vs...)) + end +end diff --git a/test/generic/AbsMSeries-test.jl b/test/generic/AbsMSeries-test.jl index 79af3a4032..ff4a2096b1 100644 --- a/test/generic/AbsMSeries-test.jl +++ b/test/generic/AbsMSeries-test.jl @@ -170,7 +170,7 @@ end @test characteristic(R) == 0 - S = residue_ring(ZZ, 7) + S, = residue_ring(ZZ, 7) R, (x, y) = power_series_ring(S, [2, 3], ["x", "y"]) @test characteristic(R) == 7 @@ -229,7 +229,7 @@ end @test characteristic(R) == 0 - S = residue_ring(ZZ, 7) + S, = residue_ring(ZZ, 7) R, (x, y) = power_series_ring(S, [2, 3], 10, ["x", "y"]) @test characteristic(R) == 7 diff --git a/test/generic/AbsSeries-test.jl b/test/generic/AbsSeries-test.jl index e4c0136b1c..a155e96a2b 100644 --- a/test/generic/AbsSeries-test.jl +++ b/test/generic/AbsSeries-test.jl @@ -139,7 +139,7 @@ end @test characteristic(R) == 0 - T = residue_ring(ZZ, 7) + T, = residue_ring(ZZ, 7) U, y = power_series_ring(T, 10, "y", model=:capped_absolute) @test modulus(T) == 7 @@ -257,7 +257,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x", model=:capped_absolute) for iter = 1:300 f = rand(R, 0:12, 0:5) @@ -300,7 +300,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x", model=:capped_absolute) for iter = 1:100 f = rand(R, 0:12, 0:5) @@ -358,7 +358,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = power_series_ring(R, 10, "x", model=:capped_absolute) for iter = 1:500 f = rand(S, 0:12, 0:5) @@ -440,7 +440,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = power_series_ring(R, 10, "x", model=:capped_absolute) for iter = 1:500 f = rand(S, 0:12, 0:5) @@ -503,7 +503,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = power_series_ring(R, 10, "x", model=:capped_absolute) for iter = 1:500 f = S() @@ -591,7 +591,7 @@ end for iter = 1:100 n = rand(2:26) - Zn = residue_ring(ZZ, n) + Zn, = residue_ring(ZZ, n) R, x = power_series_ring(Zn, 10, "x", model=:capped_absolute) f = rand(R, 0:12, 0:n - 1) @@ -649,7 +649,7 @@ end @test_throws DomainError shift_right(f, -rand(2:100)) # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x", model=:capped_absolute) for iter = 1:300 f = rand(R, 0:12, 0:5) @@ -706,7 +706,7 @@ end @test_throws DomainError truncate(f, -rand(2:100)) # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x", model=:capped_absolute) for iter = 1:300 f = rand(R, 0:12, 0:5) @@ -762,7 +762,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x", model=:capped_absolute) for iter = 1:300 f = R() @@ -825,7 +825,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x", model=:capped_absolute) for iter = 1:300 f1 = rand(R, 0:10, -10:10) @@ -905,7 +905,7 @@ end # Characteristic p field for p in [2, 7, 19, 65537, ZZ(2), ZZ(7), ZZ(19), ZZ(65537)] - R = residue_field(ZZ, p) + R, = residue_field(ZZ, p) S, x = power_series_ring(R, 10, "x", model=:capped_absolute) @@ -934,7 +934,7 @@ end end end - R = residue_field(ZZ, 2) + R, = residue_field(ZZ, 2) T, y = polynomial_ring(R, "x") S, x = power_series_ring(T, 10, "x", model=:capped_absolute) @@ -1002,7 +1002,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x", model=:capped_absolute) for iter = 1:300 s = rand(0:9) @@ -1045,7 +1045,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x", model=:capped_absolute) for iter = 1:300 f = rand(R, 0:0, 0:5) @@ -1143,7 +1143,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 143) + R, = residue_ring(ZZ, 143) S, x = power_series_ring(R, 10, "x", model=:capped_absolute) for iter = 1:10 diff --git a/test/generic/Fraction-test.jl b/test/generic/Fraction-test.jl index 025f551205..5634bd6453 100644 --- a/test/generic/Fraction-test.jl +++ b/test/generic/Fraction-test.jl @@ -280,7 +280,7 @@ end end @testset "Generic.FracFieldElem.evaluate" begin - R = residue_ring(ZZ, 5) + R, = residue_ring(ZZ, 5) S, x = polynomial_ring(R, "x") f = (x^2 + 2)//(x + 1) diff --git a/test/generic/FreeAssAlgebra-test.jl b/test/generic/FreeAssAlgebra-test.jl index 370e211bfc..73d3016817 100644 --- a/test/generic/FreeAssAlgebra-test.jl +++ b/test/generic/FreeAssAlgebra-test.jl @@ -135,7 +135,7 @@ function test_elem(R::Generic.FreeAssAlgebra{elem_type(ZZ)}) end @testset "Generic.FreeAssAlgebra.change_base_ring" begin - F5 = residue_ring(ZZ, 5) + F5, = residue_ring(ZZ, 5) R, varsR = polynomial_ring(F5, ["x"]) S, varsS = free_associative_algebra(R, ["y"]) f = x -> x^2 + F5(3) @@ -198,7 +198,7 @@ end end @testset "Generic.FreeAssAlgebra.is_unit" begin - R, (x,) = free_associative_algebra(residue_ring(ZZ, 4), ["x"]) + R, (x,) = free_associative_algebra(residue_ring(ZZ, 4)[1], ["x"]) @test !is_unit(x) @test !is_unit(2*x) diff --git a/test/generic/LaurentMPoly-test.jl b/test/generic/LaurentMPoly-test.jl index c03c965112..b99eba2a35 100644 --- a/test/generic/LaurentMPoly-test.jl +++ b/test/generic/LaurentMPoly-test.jl @@ -19,7 +19,7 @@ end test_Ring_interface(L) test_Ring_interface_recursive(L) - L, (x, y) = laurent_polynomial_ring(residue_ring(ZZ, ZZ(6)), ["x", "y"]) + L, (x, y) = laurent_polynomial_ring(residue_ring(ZZ, ZZ(6))[1], ["x", "y"]) test_Ring_interface(L) end @@ -46,12 +46,12 @@ end end @testset "Generic.LaurentMPoly.printing" begin - R, (x,) = laurent_polynomial_ring(residue_ring(ZZ, 6), ["x"]) + R, (x,) = laurent_polynomial_ring(residue_ring(ZZ, 6)[1], ["x"]) @test !occursin("\n", sprint(show, R)) end @testset "Generic.LaurentMPoly.is_unit" begin - R, (x,) = laurent_polynomial_ring(residue_ring(ZZ, 6), ["x"]) + R, (x,) = laurent_polynomial_ring(residue_ring(ZZ, 6)[1], ["x"]) @test is_unit(x) @test !is_unit(2*x) diff --git a/test/generic/LaurentPoly-test.jl b/test/generic/LaurentPoly-test.jl index 23221c974a..f62607c438 100644 --- a/test/generic/LaurentPoly-test.jl +++ b/test/generic/LaurentPoly-test.jl @@ -233,7 +233,7 @@ end end @testset "Generic.LaurentMPoly.is_unit" begin - R, x = laurent_polynomial_ring(residue_ring(ZZ, 6), "x") + R, x = laurent_polynomial_ring(residue_ring(ZZ, 6)[1], "x") @test is_unit(x) @test !is_unit(2*x) @@ -498,7 +498,7 @@ end test_EuclideanRing_interface(L) test_Ring_interface_recursive(L) - L, y = laurent_polynomial_ring(residue_ring(ZZ, ZZ(6)), "y") + L, y = laurent_polynomial_ring(residue_ring(ZZ, ZZ(6))[1], "y") test_Ring_interface(L) end end diff --git a/test/generic/LaurentSeries-test.jl b/test/generic/LaurentSeries-test.jl index 4a761e9be2..9ad2a8eeca 100644 --- a/test/generic/LaurentSeries-test.jl +++ b/test/generic/LaurentSeries-test.jl @@ -164,7 +164,7 @@ end @test characteristic(S) == 0 - T = residue_ring(ZZ, 7) + T, = residue_ring(ZZ, 7) U, y = laurent_series_ring(T, 10, "y") @test modulus(T) == 7 @@ -324,7 +324,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = laurent_series_ring(T, 10, "x") for iter = 1:300 f = rand(R, -12:12, 0:5) @@ -367,7 +367,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = laurent_series_ring(T, 10, "x") for iter = 1:100 f = rand(R, -12:12, 0:5) @@ -421,7 +421,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = laurent_series_ring(T, 10, "x") for iter = 1:100 f = rand(R, -12:12, 0:5) @@ -477,7 +477,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = laurent_series_ring(R, 10, "x") for iter = 1:500 f = rand(S, -12:12, 0:5) @@ -559,7 +559,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = laurent_series_ring(R, 10, "x") for iter = 1:500 f = rand(S, -12:12, 0:5) @@ -622,7 +622,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = laurent_series_ring(R, 10, "x") for iter = 1:500 f = S() @@ -710,7 +710,7 @@ end for iter = 1:100 n = rand(2:26) - Zn = residue_ring(ZZ, n) + Zn, = residue_ring(ZZ, n) R, x = laurent_series_ring(Zn, 10, "x") f = rand(R, -12:12, 0:n - 1) @@ -726,7 +726,7 @@ end end # regression test (see #967) - Zn = residue_ring(ZZ, 4) + Zn, = residue_ring(ZZ, 4) R, x = laurent_series_ring(Zn, 5, "x") f = 2*x^6 + O(x^11) @@ -758,7 +758,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = laurent_series_ring(T, 10, "x") for iter = 1:300 f = rand(R, -12:12, 0:5) @@ -794,7 +794,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = laurent_series_ring(T, 10, "x") for iter = 1:300 f = rand(R, -12:12, 0:5) @@ -830,7 +830,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = laurent_series_ring(T, 10, "x") for iter = 1:300 f = R() @@ -896,7 +896,7 @@ end # Characteristic p field for p in [2, 7, 19, 65537, ZZ(7), ZZ(19), ZZ(65537)] - R = residue_field(ZZ, p) + R, = residue_field(ZZ, p) S, x = laurent_series_field(R, 10, "x") @@ -925,7 +925,7 @@ end end end - R = residue_field(ZZ, 2) + R, = residue_field(ZZ, 2) T, y = polynomial_ring(R, "x") S, x = laurent_series_ring(T, 10, "x") @@ -974,7 +974,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = laurent_series_ring(T, 3, "x") for iter = 1:3000 f = rand(R, -12:12, 0:5) @@ -1013,7 +1013,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = laurent_series_ring(T, 10, "x") for iter = 1:300 f = rand(R, -12:12, 0:5) @@ -1114,7 +1114,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 143) + R, = residue_ring(ZZ, 143) S, x = laurent_series_ring(R, 10, "x") for iter = 1:10 diff --git a/test/generic/MPoly-test.jl b/test/generic/MPoly-test.jl index 6477e46373..961adc28f6 100644 --- a/test/generic/MPoly-test.jl +++ b/test/generic/MPoly-test.jl @@ -387,7 +387,7 @@ end end @testset "Generic.MPoly.is_unit" begin - R, (x,) = polynomial_ring(residue_ring(ZZ, 4), ["x"]) + R, (x,) = polynomial_ring(residue_ring(ZZ, 4)[1], ["x"]) @test !is_unit(x) @test !is_unit(2*x) @@ -755,7 +755,7 @@ end # Field of characteristic p for p in [2, 7, 13, 65537, ZZ(2), ZZ(7), ZZ(37), ZZ(65537)] - R = residue_field(ZZ, p) + R, = residue_field(ZZ, p) for num_vars = 1:10 var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() @@ -1314,7 +1314,7 @@ end end @testset "Generic.MPoly.change_base_ring" begin - F2 = residue_ring(ZZ, 2) + F2, = residue_ring(ZZ, 2) R, varsR = polynomial_ring(F2, ["x"]) S, varsS = polynomial_ring(R, ["y"]) f = x -> x^2 diff --git a/test/generic/Matrix-test.jl b/test/generic/Matrix-test.jl index c46987fbce..a106aeda62 100644 --- a/test/generic/Matrix-test.jl +++ b/test/generic/Matrix-test.jl @@ -3,7 +3,7 @@ const RINGS = Dict( "exact field" => (GF(7), ()), "inexact ring" => (RealField["t"][1], (0:200, -1000:1000)), "inexact field" => (RealField, (-1000:1000,)), - "non-integral domain" => (residue_ring(ZZ, 6), (0:5,)), + "non-integral domain" => (residue_ring(ZZ, 6)[1], (0:5,)), "fraction field" => (QQ, (-1000:1000,)), ) @@ -153,8 +153,8 @@ end SZ = matrix_space(ZZ, 3, 3) @test_throws Exception SZ(k) - R2 = residue_ring(ZZ, 2) - R3 = residue_ring(ZZ, 3) + R2, = residue_ring(ZZ, 2) + R3, = residue_ring(ZZ, 3) R2_1x2 = matrix_space(R2, 1, 2) R3_1x2 = matrix_space(R3, 1, 2) m2 = R2_1x2([0, 1]) @@ -660,7 +660,7 @@ end @test -A == S(-A.entries) # Non-integral domain - S = matrix_space(residue_ring(ZZ, 6), rand(0:9), rand(0:9)) + S = matrix_space(residue_ring(ZZ, 6)[1], rand(0:9), rand(0:9)) A = rand(S, 0:5) @test iszero(A + (-A)) @@ -844,7 +844,7 @@ end @test A[rows, cols] == matrix(R, A.entries[rows, cols]) # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S = matrix_space(R, rand(1:9), rand(1:9)) A = rand(S, 0:5) @@ -1118,7 +1118,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) for S in (matrix_space(R, rand(1:9), rand(1:9)), let n = rand(1:9) @@ -1286,7 +1286,7 @@ add_diag(M::Matrix, x) = [i != j ? M[i, j] : M[i, j] + x for (i, j) in Tuple.(Ca _test_matrix_vector_prod(R, -1000:1000) # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S = matrix_space(R, rand(1:9), rand(1:9)) A = rand(S, 0:5) @@ -1355,7 +1355,7 @@ end @testset "Generic.Mat.promotion" begin m = [1 2; 3 4] - F = residue_field(ZZ, 3) + F, = residue_field(ZZ, 3) R, t = polynomial_ring(F, "t") A = matrix(R, m) B = matrix(F, m) @@ -1385,7 +1385,7 @@ end # vector * matrix m = [1 2; 3 4] - F = residue_field(ZZ, 3) + F, = residue_field(ZZ, 3) R, t = polynomial_ring(F, "t") A = matrix(R, m) B = matrix(F, m) @@ -1715,7 +1715,8 @@ end # Extra tests R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, = residue_field(R, x^3 + 3x + 1) + a = K(x) S = matrix_space(K, 3, 3) A = S([a + 1 2a + 3 a^2 + 1; 2a^2 - 1 a - 1 2a; a^2 + 3a + 1 2a K(1)]) @@ -1788,7 +1789,8 @@ end # Other tests R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, = residue_field(R, x^3 + 3x + 1) + a = K(x) S = matrix_space(K, 3, 3) A = S([a + 1 2a + 3 a^2 + 1; 2a^2 - 1 a - 1 2a; a^2 + 3a + 1 2a K(1)]) @@ -1840,7 +1842,7 @@ end end @testset "Generic.Mat.det" begin - S, x = polynomial_ring(residue_ring(ZZ, 1009*2003), "x") + S, x = polynomial_ring(residue_ring(ZZ, 1009*2003)[1], "x") for dim = 0:5 R = matrix_space(S, dim, dim) @@ -1861,7 +1863,8 @@ end end R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, = residue_field(R, x^3 + 3x + 1) + a = K(x) for dim = 0:7 S = matrix_space(K, dim, dim) @@ -1951,7 +1954,7 @@ end end @testset "Generic.Mat.rank" begin - S = residue_ring(ZZ, 20011*10007) + S, = residue_ring(ZZ, 20011*10007) R = matrix_space(S, 5, 5) for i = 0:5 @@ -1989,7 +1992,8 @@ end end R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, = residue_field(R, x^3 + 3x + 1) + a = K(x) S = matrix_space(K, 3, 3) M = S([a a^2 + 2*a - 1 2*a^2 - 1*a; 2*a+2 2*a^2 + 2*a (-2*a^2 - 2*a); (-a) (-a^2) a^2]) @@ -2214,7 +2218,7 @@ end @test A*X == B*d end - S = residue_ring(ZZ, 20011*10007) + S, = residue_ring(ZZ, 20011*10007) for dim = 0:5 R = matrix_space(S, dim, dim) @@ -2261,7 +2265,8 @@ end end R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, = residue_field(R, x^3 + 3x + 1) + a = K(x) for dim = 0:5 S = matrix_space(K, dim, dim) @@ -2298,8 +2303,10 @@ end @test M*x == d*b end - R, t = polynomial_ring(AbstractAlgebra.JuliaQQ, "t") - K, a = number_field(t^3 + 3t + 1, "a") + R, x = polynomial_ring(AbstractAlgebra.JuliaQQ, "t") + K, = residue_field(R, x^3 + 3x + 1) + a = K(x) + S, y = polynomial_ring(K, "y") T = matrix_space(S, 3, 3) U = matrix_space(S, 3, 1) @@ -2581,7 +2588,7 @@ end end @testset "Generic.Mat.can_solve_with_solution_interpolation" begin - R1 = residue_ring(ZZ, 65537) + R1, = residue_ring(ZZ, 65537) R, x = polynomial_ring(R1, "x") RZ, x = polynomial_ring(ZZ, "x") @@ -2616,7 +2623,8 @@ end @testset "Generic.Mat.solve_triu" begin R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, = residue_field(R, x^3 + 3x + 1) + a = K(x) for dim = 0:10 S = matrix_space(K, dim, dim) @@ -2652,7 +2660,7 @@ end @testset "Generic.Mat.rref" begin # Non-integral domain - S = residue_ring(ZZ, 20011*10007) + S, = residue_ring(ZZ, 20011*10007) R = matrix_space(S, 5, 5) for i = 0:5 @@ -2715,7 +2723,8 @@ end # Exact field R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, = residue_field(R, x^3 + 3x + 1) + a = K(x) S = matrix_space(K, 5, 5) for i = 0:5 @@ -2842,7 +2851,7 @@ end end @testset "Generic.Mat.nullspace" begin - S = residue_ring(ZZ, 20011*10007) + S, = residue_ring(ZZ, 20011*10007) R = matrix_space(S, 5, 5) for i = 0:5 @@ -2884,7 +2893,8 @@ end end R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, = residue_field(R, x^3 + 3x + 1) + a = K(x) S = matrix_space(K, 5, 5) for i = 0:5 @@ -2932,7 +2942,8 @@ end end R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, = residue_field(R, x^3 + 3x + 1) + a = K(x) S = matrix_space(K, 5, 5) for i = 0:5 @@ -3051,7 +3062,7 @@ end @test M*NN == NN*M == cc*R(1) end - S = residue_ring(ZZ, 20011*10007) + S, = residue_ring(ZZ, 20011*10007) for dim = 1:5 R = matrix_space(S, dim, dim) @@ -3089,7 +3100,8 @@ end end R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, = residue_field(R, x^3 + 3x + 1) + a = K(x) for dim = 1:5 S = matrix_space(K, dim, dim) @@ -3121,7 +3133,7 @@ end end @testset "Generic.Mat.hessenberg" begin - R = residue_ring(ZZ, 18446744073709551629) + R, = residue_ring(ZZ, 18446744073709551629) for dim = 0:5 S = matrix_space(R, dim, dim) @@ -3143,7 +3155,7 @@ end end @testset "Generic.Mat.kronecker_product" begin - R = residue_ring(ZZ, 18446744073709551629) + R, = residue_ring(ZZ, 18446744073709551629) S = matrix_space(R, 2, 3) S2 = matrix_space(R, 2, 2) S3 = matrix_space(R, 3, 3) @@ -3157,7 +3169,7 @@ end end @testset "Generic.Mat.charpoly" begin - R = residue_ring(ZZ, 18446744073709551629) + R, = residue_ring(ZZ, 18446744073709551629) for dim = 0:5 S = matrix_space(R, dim, dim) @@ -3577,7 +3589,7 @@ end # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") @@ -3620,7 +3632,7 @@ end # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") @@ -3678,7 +3690,7 @@ end # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") @@ -3713,7 +3725,7 @@ end # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") @@ -3749,7 +3761,7 @@ end # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") @@ -3809,7 +3821,7 @@ end # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") @@ -3888,7 +3900,7 @@ end @test is_unit(det(U)) end - R = residue_field(ZZ, randprime(100)) + R, = residue_field(ZZ, randprime(100)) M = matrix_space(polynomial_ring(R, "x")[1], rand(1:5), rand(1:5)) @@ -3975,7 +3987,7 @@ end @test is_unit(det(U)) end - R = residue_field(ZZ, randprime(100)) + R, = residue_field(ZZ, randprime(100)) M = matrix_space(polynomial_ring(R, "x")[1], rand(1:5), rand(1:5)) diff --git a/test/generic/MatrixAlgebra-test.jl b/test/generic/MatrixAlgebra-test.jl index 62cc42c89f..e1c31a6a65 100644 --- a/test/generic/MatrixAlgebra-test.jl +++ b/test/generic/MatrixAlgebra-test.jl @@ -151,7 +151,7 @@ end @test degree(A) == 3 # Tests over residue ring - S = MatrixAlgebra(residue_ring(ZZ, 6), 2) + S = MatrixAlgebra(residue_ring(ZZ, 6)[1], 2) A = S([1 2; 3 4]) B = S([0 0; 3 3]) @test is_zero(A*B) @@ -326,7 +326,7 @@ end @testset "Generic.MatAlg.promotion" begin m = [1 2; 3 4] - F = residue_field(ZZ, 3) + F, = residue_field(ZZ, 3) R, t = polynomial_ring(F, "t") A = MatrixAlgebra(R, 2)(m) B = MatrixAlgebra(F, 2)(m) @@ -356,7 +356,7 @@ end # vector * matrix m = [1 2; 3 4] - F = residue_field(ZZ, 3) + F, = residue_field(ZZ, 3) R, t = polynomial_ring(F, "t") A = MatrixAlgebra(R, 2)(m) B = MatrixAlgebra(F, 2)(m) @@ -567,7 +567,8 @@ end @testset "Generic.MatAlg.lu" begin R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, f = residue_field(R, x^3 + 3x + 1) + a = f(x) S = MatrixAlgebra(K, 3) A = S([a + 1 2a + 3 a^2 + 1; 2a^2 - 1 a - 1 2a; a^2 + 3a + 1 2a K(1)]) @@ -605,7 +606,8 @@ end @testset "Generic.MatAlg.fflu" begin R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, f = residue_field(R, x^3 + 3x + 1) + a = f(x) S = MatrixAlgebra(K, 3) A = S([a + 1 2a + 3 a^2 + 1; 2a^2 - 1 a - 1 2a; a^2 + 3a + 1 2a K(1)]) @@ -658,7 +660,7 @@ end end @testset "Generic.MatAlg.det" begin - S, x = polynomial_ring(residue_ring(ZZ, 1009*2003), "x") + S, x = polynomial_ring(residue_ring(ZZ, 1009*2003)[1], "x") for dim = 0:5 R = MatrixAlgebra(S, dim) @@ -679,7 +681,8 @@ end end R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, f = residue_field(R, x^3 + 3x + 1) + a = f(x) for dim = 0:7 S = MatrixAlgebra(K, dim) @@ -810,7 +813,7 @@ end end @testset "Generic.MatAlg.rank" begin - S = residue_ring(ZZ, 20011*10007) + S, = residue_ring(ZZ, 20011*10007) R = MatrixAlgebra(S, 5) for i = 0:5 @@ -849,7 +852,9 @@ end end R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, f = residue_field(R, x^3 + 3x + 1) + a = f(x) + S = MatrixAlgebra(K, 3) M = S([a a^2 + 2*a - 1 2*a^2 - 1*a; 2*a+2 2*a^2 + 2*a (-2*a^2 - 2*a); (-a) (-a^2) a^2]) @@ -919,7 +924,7 @@ end end @testset "Generic.MatAlg.rref" begin - S = residue_ring(ZZ, 20011*10007) + S, = residue_ring(ZZ, 20011*10007) R = MatrixAlgebra(S, 5) for i = 0:5 @@ -956,7 +961,8 @@ end end R, x = polynomial_ring(QQ, "x") - K, a = number_field(x^3 + 3x + 1, "a") + K, f = residue_field(R, x^3 + 3x + 1) + a = f(x) S = MatrixAlgebra(K, 5) for i = 0:5 @@ -1021,7 +1027,7 @@ end end @testset "Matrix Algebra over residue_ring" begin - S = residue_ring(ZZ, 20011*10007) + S, = residue_ring(ZZ, 20011*10007) for dim = 1:5 R = MatrixAlgebra(S, dim) @@ -1072,7 +1078,8 @@ end @testset "Matrix Algebra over number_field over QQ" begin R, x = polynomial_ring(QQ, "x") - S, a = number_field(x^3 + 3x + 1, "a") + S, f = residue_field(R, x^3 + 3x + 1) + a = f(x) for dim = 1:5 R = MatrixAlgebra(S, dim) @@ -1120,7 +1127,7 @@ end end # of @testset "Generic.MatAlg.inversion" @testset "Generic.MatAlg.hessenberg" begin - R = residue_ring(ZZ, 18446744073709551629) + R, = residue_ring(ZZ, 18446744073709551629) for dim = 0:5 S = MatrixAlgebra(R, dim) @@ -1136,7 +1143,7 @@ end # of @testset "Generic.MatAlg.inversion" end @testset "Generic.MatAlg.charpoly" begin - R = residue_ring(ZZ, 18446744073709551629) + R, = residue_ring(ZZ, 18446744073709551629) for dim = 0:5 S = matrix_space(R, dim, dim) @@ -1342,7 +1349,7 @@ if false # see bug 160 # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") @@ -1378,7 +1385,7 @@ end # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") @@ -1413,7 +1420,7 @@ end # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") @@ -1448,7 +1455,7 @@ end # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") @@ -1484,7 +1491,7 @@ end # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") @@ -1521,7 +1528,7 @@ end # Fake up finite field of char 7, degree 2 R, x = polynomial_ring(GF(7), "x") - F = residue_field(R, x^2 + 6x + 3) + F, = residue_field(R, x^2 + 6x + 3) a = F(x) S, y = polynomial_ring(F, "y") diff --git a/test/generic/Poly-test.jl b/test/generic/Poly-test.jl index ca6ed62181..99f39ee75f 100644 --- a/test/generic/Poly-test.jl +++ b/test/generic/Poly-test.jl @@ -381,7 +381,7 @@ end end @testset "Generic.Poly.is_unit" begin - R, x = polynomial_ring(residue_ring(ZZ, 4), "x") + R, x = polynomial_ring(residue_ring(ZZ, 4)[1], "x") @test !is_unit(x) @test !is_unit(2*x) @@ -433,7 +433,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") for iter = 1:100 @@ -464,7 +464,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = T["x"] for iter = 1:100 f = rand(R, -1:10, 0:5) @@ -502,7 +502,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") for iter = 1:500 @@ -544,7 +544,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = R["x"] for iter = 1:500 f = rand(S, -1:10, 0:5) @@ -607,7 +607,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") for iter = 1:500 @@ -633,7 +633,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = R["x"] for iter = 1:500 f = rand(S, -1:10, 0:5) @@ -667,7 +667,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") for iter = 1:500 @@ -705,7 +705,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = R["x"] for iter = 1:500 f = rand(S, 0:10, 0:5) @@ -760,7 +760,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") for iter = 1:300 @@ -780,7 +780,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = T["x"] for iter = 1:300 f = rand(R, -1:10, 0:5) @@ -855,7 +855,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") for iter = 1:300 @@ -878,7 +878,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = T["x"] for iter = 1:300 f = rand(R, -1:10, 0:5) @@ -919,7 +919,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") for iter = 1:300 @@ -967,7 +967,7 @@ end @test_throws DomainError reverse(f, -rand(2:100)) # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = T["x"] for iter = 1:300 f = rand(R, -1:10, 0:5) @@ -1012,7 +1012,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") for iter = 1:300 @@ -1050,7 +1050,7 @@ end @test_throws DomainError shift_left(f, -rand(2:100)) # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = T["x"] for iter = 1:300 f = rand(R, -1:10, 0:5) @@ -1094,7 +1094,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") @@ -1143,7 +1143,7 @@ end for iter = 1:10 n = rand(2:26) - Zn = residue_ring(ZZ, n) + Zn, = residue_ring(ZZ, n) R, x = polynomial_ring(Zn, "x") f = rand(R, -1:10, 0:n - 1) @@ -1168,7 +1168,7 @@ end if false @testset "Generic.Poly.modular_arithmetic" begin # Exact ring - R = residue_ring(ZZ, 23) + R, = residue_ring(ZZ, 23) S, x = polynomial_ring(R, "x") for iter = 1:100 @@ -1207,7 +1207,7 @@ if false # Fake finite field of char 7, degree 2 R, y = polynomial_ring(GF(7), "y") - F = residue_field(R, y^2 + 6y + 3) + F, = residue_field(R, y^2 + 6y + 3) a = F(y) S, x = polynomial_ring(F, "x") @@ -1337,7 +1337,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") @@ -1360,7 +1360,7 @@ end # Characteristic p ring n = 23 - Zn = residue_ring(ZZ, n) + Zn, = residue_ring(ZZ, n) R, x = polynomial_ring(Zn, "x") for iter = 1:100 @@ -1396,7 +1396,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") @@ -1439,7 +1439,7 @@ end # Characteristic p ring n = 23 - Zn = residue_ring(ZZ, n) + Zn, = residue_ring(ZZ, n) R, x = polynomial_ring(Zn, "x") for iter = 1:100 @@ -1477,7 +1477,7 @@ end @testset "Generic.Poly.euclidean_division" begin # Exact ring - R = residue_ring(ZZ, 23) + R, = residue_ring(ZZ, 23) S, x = polynomial_ring(R, "x") for iter = 1:100 @@ -1500,7 +1500,7 @@ end # Fake finite field of char 7, degree 2 R, y = polynomial_ring(GF(7), "y") - F = residue_field(R, y^2 + 6y + 3) + F, = residue_field(R, y^2 + 6y + 3) a = F(y) S, x = polynomial_ring(F, "x") @@ -1593,7 +1593,7 @@ end end # Residue ring - S = residue_ring(ZZ, 23) + S, = residue_ring(ZZ, 23) R, x = polynomial_ring(S, "x") for iter = 1:100 @@ -1627,7 +1627,7 @@ end end # Characteristic p ring - Zn = residue_ring(ZZ, 23) + Zn, = residue_ring(ZZ, 23) R, x = polynomial_ring(Zn, "x") for iter = 1:100 @@ -1713,7 +1713,7 @@ end end # Characteristic p ring - R = residue_ring(ZZ, 23) + R, = residue_ring(ZZ, 23) S, x = polynomial_ring(R, "x") for iter = 1:100 @@ -1816,7 +1816,7 @@ end end # Non-integral domain - Zn = residue_ring(ZZ, 23) + Zn, = residue_ring(ZZ, 23) R, x = polynomial_ring(Zn, "x") for iter in 1:10 @@ -1862,7 +1862,7 @@ end end # Non-integral domain - Zn = residue_ring(ZZ, 6) + Zn, = residue_ring(ZZ, 6) R, x = polynomial_ring(Zn, "x") for iter in 1:10 @@ -1900,7 +1900,7 @@ end end # Non-integral domain - Zn = residue_ring(ZZ, 6) + Zn, = residue_ring(ZZ, 6) R, x = polynomial_ring(Zn, "x") for iter in 1:10 @@ -1929,7 +1929,7 @@ end end # Characteristic p ring - Zn = residue_ring(ZZ, 23) + Zn, = residue_ring(ZZ, 23) R, x = polynomial_ring(Zn, "x") for iter in 1:10 @@ -2015,7 +2015,7 @@ end end # Characteristic p ring - Zn = residue_ring(ZZ, 23) + Zn, = residue_ring(ZZ, 23) R, x = polynomial_ring(Zn, "x") for iter in 1:10 @@ -2060,7 +2060,7 @@ end end # Non-integral domain - Zn = residue_ring(ZZ, 6) + Zn, = residue_ring(ZZ, 6) R, x = polynomial_ring(Zn, "x") for iter in 1:10 @@ -2102,7 +2102,7 @@ end # TODO: Fix issue #291 # # Non-integral domain -# Zn = residue_ring(ZZ, 6) +# Zn, = residue_ring(ZZ, 6) # R, x = polynomial_ring(Zn, "x") # # for iter = 1:100 @@ -2172,7 +2172,7 @@ end end # Characteristic p ring - Zn = residue_ring(ZZ, 23) + Zn, = residue_ring(ZZ, 23) R, x = polynomial_ring(Zn, "x") for iter in 1:100 @@ -2210,7 +2210,7 @@ end # Test will cause impossible inverse in the mean time # # # Non-integral domain -# Zn = residue_ring(ZZ, 6) +# Zn, = residue_ring(ZZ, 6) # R, x = polynomial_ring(Zn, "x") # # for iter in 1:100 @@ -2253,7 +2253,7 @@ end end # Characteristic p ring - Zn = residue_ring(ZZ, 23) + Zn, = residue_ring(ZZ, 23) R, x = polynomial_ring(Zn, "x") for iter in 1:100 @@ -2289,7 +2289,7 @@ end # Fake finite field of char 7, degree 2 S, y = polynomial_ring(GF(7), "y") - F = residue_field(S, y^2 + 6y + 3) + F, = residue_field(S, y^2 + 6y + 3) a = F(y) R, x = polynomial_ring(F, "x") @@ -2311,7 +2311,7 @@ end @testset "Generic.Poly.gcd_gcdx_gcdinv_nonfield" begin for n in (6, 101*103) - Zn = residue_ring(ZZ, n) + Zn, = residue_ring(ZZ, n) R, x = polynomial_ring(Zn, "x") for iter in 1:100 @@ -2393,7 +2393,7 @@ end end # Characteristic p ring - Zn = residue_ring(ZZ, 23) + Zn, = residue_ring(ZZ, 23) R, x = polynomial_ring(Zn, "x") for iter in 1:10 @@ -2423,7 +2423,7 @@ end end # Non-integral domain - Zn = residue_ring(ZZ, 6) + Zn, = residue_ring(ZZ, 6) R, x = polynomial_ring(Zn, "x") for iter in 1:10 @@ -2482,7 +2482,7 @@ end end # Characteristic p ring - Zn = residue_ring(ZZ, 23) + Zn, = residue_ring(ZZ, 23) R, x = polynomial_ring(Zn, "x") for iter in 1:10 @@ -2513,7 +2513,7 @@ end # TODO: Fix issue #294 (if possible) # # Non-integral domain -# Zn = residue_ring(ZZ, 6) +# Zn, = residue_ring(ZZ, 6) # R, x = polynomial_ring(Zn, "x") # # for iter in 1:10 @@ -2590,7 +2590,7 @@ end end # Characteristic p ring - Zn = residue_ring(ZZ, 23) + Zn, = residue_ring(ZZ, 23) R, x = polynomial_ring(Zn, "x") for n in 10:20 @@ -2629,7 +2629,7 @@ end end # Non-integral domain - Zn = residue_ring(ZZ, 6) + Zn, = residue_ring(ZZ, 6) R, x = polynomial_ring(Zn, "x") for n in 10:20 @@ -2766,7 +2766,7 @@ end end # Characteristic p ring - Zn = residue_ring(ZZ, 23) + Zn, = residue_ring(ZZ, 23) R, x = polynomial_ring(Zn, "x") for iter = 1:10 @@ -2906,7 +2906,7 @@ end # Characteristic p field for p in [2, 7, 19, 65537, ZZ(2), ZZ(7), ZZ(19), ZZ(65537)] - R = residue_field(ZZ, p) + R, = residue_field(ZZ, p) S, x = polynomial_ring(R, "x") diff --git a/test/generic/PuiseuxSeries-test.jl b/test/generic/PuiseuxSeries-test.jl index a6e1782e65..1fb88b8794 100644 --- a/test/generic/PuiseuxSeries-test.jl +++ b/test/generic/PuiseuxSeries-test.jl @@ -145,7 +145,7 @@ end @test characteristic(S) == 0 - T = residue_ring(ZZ, 7) + T, = residue_ring(ZZ, 7) U, y = puiseux_series_ring(T, 10, "y") @test modulus(T) == 7 @@ -227,7 +227,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = puiseux_series_ring(T, 10, "x") for iter = 1:300 f = rand(R, -12:12, 1:6, 0:5) @@ -270,7 +270,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = puiseux_series_ring(T, 10, "x") for iter = 1:100 f = rand(R, -12:12, 1:6, 0:5) @@ -339,7 +339,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = puiseux_series_ring(R, 10, "x") for iter = 1:500 f = rand(S, -12:12, 1:6, 0:5) @@ -421,7 +421,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = puiseux_series_ring(R, 10, "x") for iter = 1:500 f = rand(S, -12:12, 1:6, 0:5) @@ -484,7 +484,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = puiseux_series_ring(R, 10, "x") for iter = 1:500 f = S() @@ -572,7 +572,7 @@ end for iter = 1:100 n = rand(2:26) - Zn = residue_ring(ZZ, n) + Zn, = residue_ring(ZZ, n) R, x = puiseux_series_ring(Zn, 10, "x") f = rand(R, -12:12, 1:6, 0:n - 1) @@ -612,7 +612,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = puiseux_series_ring(T, 10, "x") for iter = 1:300 f = R() @@ -666,7 +666,7 @@ end # Characteristic p field for p in [2, 7, 19, 65537, ZZ(7), ZZ(19), ZZ(65537)] - R = residue_field(ZZ, p) + R, = residue_field(ZZ, p) S, x = puiseux_series_field(R, 10, "x") @@ -691,7 +691,7 @@ end end end - R = residue_field(ZZ, 2) + R, = residue_field(ZZ, 2) T, y = polynomial_ring(R, "x") S, x = puiseux_series_ring(T, 10, "x") @@ -732,7 +732,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = puiseux_series_ring(T, 10, "x") for iter = 1:300 s = rand(0:12) @@ -772,7 +772,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = puiseux_series_ring(T, 10, "x") for iter = 1:300 f = rand(R, -12:12, 1:6, 0:5) @@ -811,7 +811,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 143) + R, = residue_ring(ZZ, 143) S, x = puiseux_series_ring(R, 5, "x") for iter = 1:100 @@ -882,7 +882,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 143) + R, = residue_ring(ZZ, 143) S, x = puiseux_series_ring(R, 5, "x") for iter = 1:10 diff --git a/test/generic/RelSeries-test.jl b/test/generic/RelSeries-test.jl index 0afbf0b0a5..3520a822d9 100644 --- a/test/generic/RelSeries-test.jl +++ b/test/generic/RelSeries-test.jl @@ -145,7 +145,7 @@ end @test characteristic(S) == 0 - T = residue_ring(ZZ, 7) + T, = residue_ring(ZZ, 7) U, y = power_series_ring(T, 10, "y") @test modulus(T) == 7 @@ -261,7 +261,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x") for iter = 1:300 f = rand(R, 0:12, 0:5) @@ -304,7 +304,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x") for iter = 1:100 f = rand(R, 0:12, 0:5) @@ -362,7 +362,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = power_series_ring(R, 10, "x") for iter = 1:500 f = rand(S, 0:12, 0:5) @@ -444,7 +444,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = power_series_ring(R, 10, "x") for iter = 1:500 f = rand(S, 0:12, 0:5) @@ -507,7 +507,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 6) + R, = residue_ring(ZZ, 6) S, x = power_series_ring(R, 10, "x") for iter = 1:500 f = S() @@ -603,7 +603,7 @@ end for iter = 1:100 n = rand(2:26) - Zn = residue_ring(ZZ, n) + Zn, = residue_ring(ZZ, n) R, x = power_series_ring(Zn, 10, "x") f = rand(R, 0:12, 0:n - 1) @@ -619,7 +619,7 @@ end end # regression test (see #931) - Zn = residue_ring(ZZ, 2) + Zn, = residue_ring(ZZ, 2) R, x = power_series_ring(Zn, 10, "x") f = O(x^2) @test isequal(f^0, 1 + O(x^10)) @@ -629,7 +629,7 @@ end @test_throws DomainError f^-rand(2:100) # regression test (see #967) - Zn = residue_ring(ZZ, 4) + Zn, = residue_ring(ZZ, 4) R, x = power_series_ring(Zn, 5, "x") f = 2*x^6 + O(x^11) @@ -679,7 +679,7 @@ end @test_throws DomainError shift_right(f, -rand(2:100)) # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x") for iter = 1:300 f = rand(R, 0:12, 0:5) @@ -732,7 +732,7 @@ end @test_throws DomainError truncate(f, -rand(2:100)) # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x") for iter = 1:300 f = rand(R, 0:12, 0:5) @@ -785,7 +785,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x") for iter = 1:300 f = R() @@ -848,7 +848,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x") for iter = 1:300 f1 = rand(R, 0:10, -10:10) @@ -928,7 +928,7 @@ end # Characteristic p field for p in [2, 7, 19, 65537, ZZ(2), ZZ(7), ZZ(19), ZZ(65537)] - R = residue_field(ZZ, p) + R, = residue_field(ZZ, p) S, x = power_series_ring(R, 10, "x") @@ -957,7 +957,7 @@ end end end - R = residue_field(ZZ, 2) + R, = residue_field(ZZ, 2) T, y = polynomial_ring(R, "x") S, x = power_series_ring(T, 10, "x") @@ -1025,7 +1025,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x") for iter = 1:300 s = rand(0:12) @@ -1068,7 +1068,7 @@ end end # Non-integral domain - T = residue_ring(ZZ, 6) + T, = residue_ring(ZZ, 6) R, x = power_series_ring(T, 10, "x") for iter = 1:300 f = rand(R, 0:12, 0:5) @@ -1179,7 +1179,7 @@ end end # Non-integral domain - R = residue_ring(ZZ, 143) + R, = residue_ring(ZZ, 143) S, x = power_series_ring(R, 10, "x") for iter = 1:10 diff --git a/test/generic/Residue-test.jl b/test/generic/Residue-test.jl index 3b5d9da607..5794f9ad15 100644 --- a/test/generic/Residue-test.jl +++ b/test/generic/Residue-test.jl @@ -7,21 +7,21 @@ function test_elem(R::AbstractAlgebra.Generic.EuclideanRingResidueRing{AbstractA end @testset "Generic.EuclideanRingResidueRingElem.conformance_tests" begin - test_Ring_interface(residue_ring(ZZ, 1)) # is_gen fails on polys - test_Ring_interface_recursive(residue_ring(ZZ, -4)) + test_Ring_interface(residue_ring(ZZ, 1)[1]) # is_gen fails on polys + test_Ring_interface_recursive(residue_ring(ZZ, -4)[1]) # - R = residue_ring(ZZ, 16453889) + R, = residue_ring(ZZ, 16453889) test_Ring_interface_recursive(R) # S, x = polynomial_ring(R, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) test_Ring_interface_recursive(T) # S, x = polynomial_ring(ZZ, "x") - T = residue_ring(S, x^2 + 1) + T, = residue_ring(S, x^2 + 1) #test_Ring_interface_recursive(T) # TODO: currently fails because `inv(one(T))` fails @test !occursin("\n", sprint(show, T)) @@ -30,7 +30,9 @@ end @testset "Generic.EuclideanRingResidueRingElem.constructors" begin B = ZZ - R = Generic.residue_ring(B, 16453889) + R, f = Generic.residue_ring(B, 16453889) + @test domain(f) === B + @test codomain(f) === R S, f1 = quo(B, 16453889) U, f2 = quo(B, 16453889; cached=false) @@ -39,15 +41,15 @@ end @test U !== R v1 = rand(R, -100:100) - @test f1(inv(f1)(v1)) == v1 + @test f1(preimage(f1, v1)) == v1 c1 = rand(B, -1000:1000) @test f1(c1) == S(c1) @test f2(c1) == S(c1) - @test Generic.residue_ring(B, 16453889, cached = true) === Generic.residue_ring(B, 16453889, cached = true) - @test Generic.residue_ring(B, 16453889, cached = false) !== Generic.residue_ring(B, 16453889, cached = true) + @test Generic.residue_ring(B, 16453889, cached = true)[1] === Generic.residue_ring(B, 16453889, cached = true)[1] + @test Generic.residue_ring(B, 16453889, cached = false)[1] !== Generic.residue_ring(B, 16453889, cached = true)[1] @test_throws DomainError Generic.residue_ring(B, 0) @@ -74,7 +76,7 @@ end @test isa(d, Generic.EuclideanRingResidueRingElem) S, x = polynomial_ring(R, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) @test isa(T, Generic.EuclideanRingResidueRing) @@ -88,7 +90,7 @@ end # Poly modulus, invertible lc S, x = polynomial_ring(ZZ, "x") - T = residue_ring(S, x^2 + 1) + T, = residue_ring(S, x^2 + 1) @test isa(T, Generic.EuclideanRingResidueRing) @@ -108,7 +110,7 @@ end @test isa(k, Generic.EuclideanRingResidueRingElem) - S = Generic.residue_ring(B, 164538890) + S, = Generic.residue_ring(B, 164538890) x = R(1) y = S(1) @test x in [x, y] @@ -120,7 +122,7 @@ end end @testset "Generic.EuclideanRingResidueRingElem.rand" begin - R = Generic.residue_ring(ZZ, 49) + R, = Generic.residue_ring(ZZ, 49) test_rand(R, 1:9) do f @test 1 <= f.data <= 9 @@ -128,13 +130,13 @@ end # make with 3 arguments P, x = polynomial_ring(RealField, "x") - R = Generic.residue_ring(P, x^3) + R, = Generic.residue_ring(P, x^3) test_rand(R, -1:9, -3:3) end @testset "Generic.EuclideanRingResidueRingElem.manipulation" begin - R = Generic.residue_ring(ZZ, 16453889) + R, = Generic.residue_ring(ZZ, 16453889) @test modulus(R) == 16453889 @@ -145,7 +147,7 @@ end @test modulus(g) == 16453889 S, x = polynomial_ring(R, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) h = one(T) @@ -169,7 +171,7 @@ end # Poly modulus, invertible lc S, x = polynomial_ring(ZZ, "x") - T = residue_ring(S, x^2 + 1) + T, = residue_ring(S, x^2 + 1) @test isone(one(T)) @test iszero(zero(T)) @@ -177,31 +179,31 @@ end @test canonical_unit(T(x)) == T(x) @test modulus(T) == x^2 + 1 - S = residue_ring(zz, 23) + S, = residue_ring(zz, 23) @test lift(S(1)) == 1 @test isa(lift(S(1)), BigInt) end @testset "Generic.EuclideanRingResidueRingElem.unary_ops" begin - R = Generic.residue_ring(ZZ, 16453889) + R, = Generic.residue_ring(ZZ, 16453889) @test -R(12345) == R(16441544) S, x = polynomial_ring(R, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) @test -T(x^5 + 1) == T(x^2+16453880*x+16453885) # Poly modulus, invertible lc S, x = polynomial_ring(ZZ, "x") - T = residue_ring(S, x^2 + 1) + T, = residue_ring(S, x^2 + 1) @test -T(x + 1) == T(-x - 1) end @testset "Generic.EuclideanRingResidueRingElem.binary_ops" begin - R = Generic.residue_ring(ZZ, 12) + R, = Generic.residue_ring(ZZ, 12) f = R(4) g = R(6) @@ -212,9 +214,9 @@ end @test f*g == R(0) - Q = Generic.residue_ring(ZZ, 7) + Q, = Generic.residue_ring(ZZ, 7) S, x = polynomial_ring(Q, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) n = T(x^5 + 1) p = T(x^2 + 2x + 1) @@ -227,7 +229,7 @@ end # Poly modulus, invertible lc S, x = polynomial_ring(ZZ, "x") - T = residue_ring(S, x^2 + 1) + T, = residue_ring(S, x^2 + 1) n = T(x^5 + 1) p = T(x^2 + 2x + 1) @@ -240,16 +242,16 @@ end end @testset "Generic.EuclideanRingResidueRingElem.gcd" begin - R = Generic.residue_ring(ZZ, 12) + R, = Generic.residue_ring(ZZ, 12) f = R(4) g = R(6) @test gcd(f, g) == R(2) - Q = Generic.residue_ring(ZZ, 7) + Q, = Generic.residue_ring(ZZ, 7) S, x = polynomial_ring(Q, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) n = T(x^5 + 1) p = T(x^2 + 2x + 1) @@ -258,17 +260,17 @@ end # Poly modulus, invertible lc S, x = polynomial_ring(ZZ, "x") - T = residue_ring(S, x^2 + 2x + 1) + T, = residue_ring(S, x^2 + 2x + 1) @test gcd(T(x + 1), T(x + 1)) == T(x + 1) - T = residue_ring(S, x^2 + 1) + T, = residue_ring(S, x^2 + 1) @test gcd(T(x + 1), T(x + 1)) == T(1) end @testset "Generic.EuclideanRingResidueRingElem.adhoc_binary" begin - R = Generic.residue_ring(ZZ, 7) + R, = Generic.residue_ring(ZZ, 7) a = R(3) @@ -279,7 +281,7 @@ end @test 5a == R(1) S, x = polynomial_ring(R, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) f = T(x^5 + 1) @@ -291,7 +293,7 @@ end # Poly modulus, invertible lc S, x = polynomial_ring(ZZ, "x") - T = residue_ring(S, x^2 + 2x + 1) + T, = residue_ring(S, x^2 + 2x + 1) f = T(x + 1) @@ -303,7 +305,7 @@ end end @testset "Generic.EuclideanRingResidueRingElem.comparison" begin - R = Generic.residue_ring(ZZ, 7) + R, = Generic.residue_ring(ZZ, 7) a = R(3) b = a @@ -316,7 +318,7 @@ end @test c != a S, x = polynomial_ring(R, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) f = T(x^5 + 1) g = 8f @@ -329,14 +331,14 @@ end # Poly modulus, invertible lc S, x = polynomial_ring(ZZ, "x") - T = residue_ring(S, x^2 + 1) + T, = residue_ring(S, x^2 + 1) @test T(x + 1) == T(x + 1) @test isequal(T(x + 2), T(x + 2)) end @testset "Generic.EuclideanRingResidueRingElem.adhoc_comparison" begin - R = Generic.residue_ring(ZZ, 7) + R, = Generic.residue_ring(ZZ, 7) a = R(3) @@ -344,7 +346,7 @@ end @test 4 != a S, x = polynomial_ring(R, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) f = T(x^5 + 1) @@ -352,21 +354,21 @@ end # Poly modulus, invertible lc S, x = polynomial_ring(ZZ, "x") - T = residue_ring(S, x^2 + 1) + T, = residue_ring(S, x^2 + 1) @test T(2) == 2 @test T(x) != 2 end @testset "Generic.EuclideanRingResidueRingElem.powering" begin - R = Generic.residue_ring(ZZ, 7) + R, = Generic.residue_ring(ZZ, 7) a = R(3) @test a^5 == 5 S, x = polynomial_ring(R, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) f = T(x^5 + 1) @@ -374,7 +376,7 @@ end # Poly modulus, invertible lc S, x = polynomial_ring(ZZ, "x") - T = residue_ring(S, x^2 + 1) + T, = residue_ring(S, x^2 + 1) @test T(x + 1)^0 == T(1) @test T(x + 1)^1 == T(x + 1) @@ -382,7 +384,7 @@ end @test T(x + 1)^3 == T(2x - 2) - R = residue_ring(ZZ, ZZ(4)) + R, = residue_ring(ZZ, ZZ(4)) @test_throws NotInvertibleError R(4)^-1 @test_throws NotInvertibleError R(2)^-1 try @@ -393,7 +395,7 @@ end @test modulus(e.mod) == 4 end - R = residue_ring(ZZ, 4) + R, = residue_ring(ZZ, 4) @test_throws NotInvertibleError R(4)^-1 @test_throws NotInvertibleError R(2)^-1 try @@ -404,23 +406,23 @@ end @test modulus(e.mod) == 4 end - R = residue_ring(ZZ, ZZ(5)) + R, = residue_ring(ZZ, ZZ(5)) @test_throws NotInvertibleError R(5)^-1 - R = residue_ring(ZZ, 5) + R, = residue_ring(ZZ, 5) @test_throws NotInvertibleError R(5)^-1 end @testset "Generic.EuclideanRingResidueRingElem.inversion" begin - R = Generic.residue_ring(ZZ, 49) + R, = Generic.residue_ring(ZZ, 49) a = R(5) @test inv(a) == 10 - R = Generic.residue_ring(ZZ, 41) + R, = Generic.residue_ring(ZZ, 41) S, x = polynomial_ring(R, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) f = T(x^5 + 1) @@ -428,16 +430,16 @@ end end @testset "Generic.EuclideanRingResidueRingElem.exact_division" begin - R = Generic.residue_ring(ZZ, 49) + R, = Generic.residue_ring(ZZ, 49) a = R(5) b = R(3) @test divexact(a, b) == 18 - R = Generic.residue_ring(ZZ, 41) + R, = Generic.residue_ring(ZZ, 41) S, x = polynomial_ring(R, "x") - T = residue_ring(S, x^3 + 3x + 1) + T, = residue_ring(S, x^3 + 3x + 1) f = T(x^5 + 1) g = T(x^4 + x + 2) @@ -446,7 +448,7 @@ end for i = 1:100 n = rand(1:24) - R = residue_ring(ZZ, n) + R, = residue_ring(ZZ, n) for iter = 1:100 a1 = rand(R, 0:n - 1) diff --git a/test/generic/ResidueField-test.jl b/test/generic/ResidueField-test.jl index e126b9ec9d..4939f5ca29 100644 --- a/test/generic/ResidueField-test.jl +++ b/test/generic/ResidueField-test.jl @@ -1,7 +1,7 @@ @testset "Generic.EuclideanRingResidueFieldElem.constructors" begin B = ZZ - R = Generic.residue_field(B, 16453889) + R, = Generic.residue_field(B, 16453889) S, f1 = quo(Field, B, 16453889) U, f2 = quo(Field, B, 16453889; cached=false) @@ -9,16 +9,19 @@ @test S === R @test U !== R + @test domain(f1) === B + @test codomain(f1) === S + v1 = rand(R, -100:100) - @test f1(inv(f1)(v1)) == v1 + @test f1(preimage(f1, v1)) == v1 c1 = rand(B, -1000:1000) @test f1(c1) == S(c1) @test f2(c1) == S(c1) - @test Generic.residue_field(B, 16453889, cached = true) === Generic.residue_field(B, 16453889, cached = true) - @test Generic.residue_field(B, 16453889, cached = true) !== Generic.residue_field(B, 16453889, cached = false) + @test Generic.residue_field(B, 16453889, cached = true)[1] === Generic.residue_field(B, 16453889, cached = true)[1] + @test Generic.residue_field(B, 16453889, cached = true)[1] !== Generic.residue_field(B, 16453889, cached = false)[1] @test elem_type(R) == Generic.EuclideanRingResidueFieldElem{elem_type(B)} @test elem_type(Generic.EuclideanRingResidueField{elem_type(B)}) == Generic.EuclideanRingResidueFieldElem{elem_type(B)} @@ -43,7 +46,7 @@ @test isa(d, Generic.EuclideanRingResidueFieldElem) S, x = polynomial_ring(R, "x") - T = residue_field(S, x^3 + 3x + 1) + T, = residue_field(S, x^3 + 3x + 1) @test isa(T, Generic.EuclideanRingResidueField) @@ -55,7 +58,7 @@ @test isa(g, Generic.EuclideanRingResidueFieldElem) - S = Generic.residue_ring(B, 2) + S, = Generic.residue_ring(B, 2) x = R(1) y = S(1) @test x in [x, y] @@ -67,7 +70,7 @@ end @testset "Generic.EuclideanRingResidueFieldElem.printing" begin - R = Generic.residue_field(ZZ, 16453889) + R, = Generic.residue_field(ZZ, 16453889) @test string(zero(R)) == "0" @test string(one(R)) == "1" @@ -81,7 +84,7 @@ end end @testset "Generic.EuclideanRingResidueFieldElem.rand" begin - R = Generic.residue_field(ZZ, 16453889) + R, = Generic.residue_field(ZZ, 16453889) test_rand(R, 1:9) do f @test 1 <= f.data <= 9 @@ -89,7 +92,7 @@ end end @testset "Generic.EuclideanRingResidueFieldElem.manipulation" begin - R = Generic.residue_field(ZZ, 16453889) + R, = Generic.residue_field(ZZ, 16453889) @test modulus(R) == 16453889 @@ -100,7 +103,7 @@ end @test modulus(g) == 16453889 S, x = polynomial_ring(R, "x") - T = residue_field(S, x^3 + 3x + 1) + T, = residue_field(S, x^3 + 3x + 1) h = one(T) @@ -119,25 +122,25 @@ end @test deepcopy(h) == h - S = residue_field(zz, 23) + S, = residue_field(zz, 23) @test lift(S(1)) == 1 @test isa(lift(S(1)), BigInt) end @testset "Generic.EuclideanRingResidueFieldElem.unary_ops" begin - R = Generic.residue_field(ZZ, 16453889) + R, = Generic.residue_field(ZZ, 16453889) @test -R(12345) == R(16441544) S, x = polynomial_ring(R, "x") - T = residue_field(S, x^3 + 3x + 1) + T, = residue_field(S, x^3 + 3x + 1) @test -T(x^5 + 1) == T(x^2+16453880*x+16453885) end @testset "Generic.EuclideanRingResidueFieldElem.binary_ops" begin - R = Generic.residue_field(ZZ, 13) + R, = Generic.residue_field(ZZ, 13) f = R(4) g = R(6) @@ -148,9 +151,9 @@ end @test f*g == R(11) - Q = Generic.residue_field(ZZ, 7) + Q, = Generic.residue_field(ZZ, 7) S, x = polynomial_ring(Q, "x") - T = residue_field(S, x^3 + 3x + 1) + T, = residue_field(S, x^3 + 3x + 1) n = T(x^5 + 1) p = T(x^2 + 2x + 1) @@ -163,16 +166,16 @@ end end @testset "Generic.EuclideanRingResidueFieldElem.gcd" begin - R = Generic.residue_field(ZZ, 13) + R, = Generic.residue_field(ZZ, 13) f = R(4) g = R(6) @test gcd(f, g) == R(1) - Q = Generic.residue_field(ZZ, 7) + Q, = Generic.residue_field(ZZ, 7) S, x = polynomial_ring(Q, "x") - T = residue_field(S, x^3 + 3x + 1) + T, = residue_field(S, x^3 + 3x + 1) n = T(x^5 + 1) p = T(x^2 + 2x + 1) @@ -181,7 +184,7 @@ end end @testset "Generic.EuclideanRingResidueFieldElem.adhoc_binary" begin - R = Generic.residue_field(ZZ, 7) + R, = Generic.residue_field(ZZ, 7) a = R(3) @@ -192,7 +195,7 @@ end @test 5a == R(1) S, x = polynomial_ring(R, "x") - T = residue_field(S, x^3 + 3x + 1) + T, = residue_field(S, x^3 + 3x + 1) f = T(x^5 + 1) @@ -204,7 +207,7 @@ end end @testset "Generic.EuclideanRingResidueFieldElem.comparison" begin - R = Generic.residue_field(ZZ, 7) + R, = Generic.residue_field(ZZ, 7) a = R(3) b = a @@ -217,7 +220,7 @@ end @test c != a S, x = polynomial_ring(R, "x") - T = residue_field(S, x^3 + 3x + 1) + T, = residue_field(S, x^3 + 3x + 1) f = T(x^5 + 1) g = 8f @@ -230,7 +233,7 @@ end end @testset "Generic.EuclideanRingResidueFieldElem.adhoc_comparison" begin - R = Generic.residue_field(ZZ, 7) + R, = Generic.residue_field(ZZ, 7) a = R(3) @@ -238,7 +241,7 @@ end @test 4 != a S, x = polynomial_ring(R, "x") - T = residue_field(S, x^3 + 3x + 1) + T, = residue_field(S, x^3 + 3x + 1) f = T(x^5 + 1) @@ -246,14 +249,14 @@ end end @testset "Generic.EuclideanRingResidueFieldElem.powering" begin - R = Generic.residue_field(ZZ, 7) + R, = Generic.residue_field(ZZ, 7) a = R(3) @test a^5 == 5 S, x = polynomial_ring(R, "x") - T = residue_field(S, x^3 + 3x + 1) + T, = residue_field(S, x^3 + 3x + 1) f = T(x^5 + 1) @@ -261,15 +264,15 @@ end end @testset "Generic.EuclideanRingResidueFieldElem.inversion" begin - R = Generic.residue_field(ZZ, 47) + R, = Generic.residue_field(ZZ, 47) a = R(5) @test inv(a) == 19 - R = Generic.residue_field(ZZ, 41) + R, = Generic.residue_field(ZZ, 41) S, x = polynomial_ring(R, "x") - T = residue_field(S, x^3 + 3x + 1) + T, = residue_field(S, x^3 + 3x + 1) f = T(x^5 + 1) @@ -277,16 +280,16 @@ end end @testset "Generic.EuclideanRingResidueFieldElem.exact_division" begin - R = Generic.residue_field(ZZ, 47) + R, = Generic.residue_field(ZZ, 47) a = R(5) b = R(3) @test divexact(a, b) == 33 - R = Generic.residue_field(ZZ, 41) + R, = Generic.residue_field(ZZ, 41) S, x = polynomial_ring(R, "x") - T = residue_field(S, x^3 + 3x + 1) + T, = residue_field(S, x^3 + 3x + 1) f = T(x^5 + 1) g = T(x^4 + x + 2) @@ -296,7 +299,7 @@ end @testset "Generic.EuclideanRingResidueFieldElem.square_root" begin for p in [3, 47, 733, 13913, 168937, 3980299, 57586577] - R = Generic.residue_field(ZZ, p) + R, = Generic.residue_field(ZZ, p) for i = 1:10 a = rand(R, 0:p - 1)^2 @@ -316,7 +319,7 @@ end end for p in [ZZ(3), ZZ(53), ZZ(727), ZZ(8893), ZZ(191339), ZZ(2369093), ZZ(52694921)] - R = Generic.residue_field(ZZ, p) + R, = Generic.residue_field(ZZ, p) for i = 1:10 a = rand(R, 0:Int(p - 1))^2 diff --git a/test/generic/TotalFraction-test.jl b/test/generic/TotalFraction-test.jl index 2d50191bdb..20fa75da90 100644 --- a/test/generic/TotalFraction-test.jl +++ b/test/generic/TotalFraction-test.jl @@ -1,5 +1,5 @@ @testset "Generic.TotFrac.constructors" begin - S = residue_ring(ZZ, 12) + S, = residue_ring(ZZ, 12) T = total_ring_of_fractions(S) @test total_ring_of_fractions(S, cached = true) === total_ring_of_fractions(S, cached = true) @@ -45,14 +45,14 @@ end end @testset "Generic.TotFrac.rand" begin - S = residue_ring(ZZ, 12) + S, = residue_ring(ZZ, 12) K = total_ring_of_fractions(S) test_rand(K, 0:11) end @testset "Generic.TotFrac.manipulation" begin - R = residue_ring(ZZ, 12) + R, = residue_ring(ZZ, 12) S = total_ring_of_fractions(R) @test denominator(S(5, 7)) == 7 @@ -88,14 +88,14 @@ end end @testset "Generic.TotFrac.unary_ops" begin - R = residue_ring(ZZ, 12) + R, = residue_ring(ZZ, 12) S = total_ring_of_fractions(R) @test -(S(5, 7)) == 1 end @testset "Generic.TotFrac.binary_ops" begin - R = residue_ring(ZZ, 12) + R, = residue_ring(ZZ, 12) S = total_ring_of_fractions(R) for iter = 1:100 @@ -111,7 +111,7 @@ end end @testset "Generic.TotFrac.adhoc_binary" begin - R = residue_ring(ZZ, 12) + R, = residue_ring(ZZ, 12) S = total_ring_of_fractions(R) a = S(3, 7) @@ -151,7 +151,7 @@ end end @testset "Generic.TotFrac.comparison" begin - R = residue_ring(ZZ, 12) + R, = residue_ring(ZZ, 12) S = total_ring_of_fractions(R) a = S(3, 7) @@ -163,7 +163,7 @@ end end @testset "Generic.TotFrac.adhoc_comparison" begin - R = residue_ring(ZZ, 12) + R, = residue_ring(ZZ, 12) S = total_ring_of_fractions(R) @test S(3, 1) == 3 @@ -176,7 +176,7 @@ end end @testset "Generic.TotFrac.powering" begin - R = residue_ring(ZZ, 12) + R, = residue_ring(ZZ, 12) S = total_ring_of_fractions(R) a = S(5, 7) @@ -185,7 +185,7 @@ end end @testset "Generic.TotFrac.inversion" begin - R = residue_ring(ZZ, 12) + R, = residue_ring(ZZ, 12) S = total_ring_of_fractions(R) a = S(5, 7) @@ -196,7 +196,7 @@ end end @testset "Generic.TotFrac.promotion" begin - R = residue_ring(ZZ, 12) + R, = residue_ring(ZZ, 12) S = total_ring_of_fractions(R) T = elem_type(S) @@ -204,7 +204,7 @@ end end @testset "Generic.TotFrac.unsafe_operators" begin - R = residue_ring(ZZ, 12) + R, = residue_ring(ZZ, 12) S = total_ring_of_fractions(R) a = S(5, 7) diff --git a/test/generic/UnivPoly-test.jl b/test/generic/UnivPoly-test.jl index 85629b098a..fe2e484cce 100644 --- a/test/generic/UnivPoly-test.jl +++ b/test/generic/UnivPoly-test.jl @@ -132,7 +132,7 @@ function test_elem(R::AbstractAlgebra.Generic.UniversalPolyRing{AbstractAlgebra. end @testset "Generic.UnivPoly.conformance" begin - S = UniversalPolynomialRing(residue_ring(ZZ, ZZ(6))) + S = UniversalPolynomialRing(residue_ring(ZZ, ZZ(6))[1]) gen(S, "x") test_Ring_interface(S) end