Skip to content

Commit f84179f

Browse files
lgoettgensthofma
authored andcommitted
Add many @req !is_trivial checks
1 parent 31f0414 commit f84179f

File tree

7 files changed

+18
-5
lines changed

7 files changed

+18
-5
lines changed

src/Fraction.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ that it will always be returned by a call to the constructor when the same
823823
base ring $R$ is supplied.
824824
"""
825825
function fraction_field(R::Ring; cached::Bool=true)
826+
@req !is_trivial(R) "Zero rings are currently not supported as coefficient ring."
826827
return Generic.fraction_field(R; cached=cached)
827828
end
828829

src/MPoly.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,5 +1508,7 @@ true
15081508
Like [`polynomial_ring(R::Ring, s::Vector{Symbol})`](@ref) but return only the
15091509
multivariate polynomial ring.
15101510
"""
1511-
polynomial_ring_only(R::T, s::Vector{Symbol}; internal_ordering::Symbol=:lex, cached::Bool=true) where T<:Ring =
1512-
mpoly_ring_type(T)(R, s, internal_ordering, cached)
1511+
function polynomial_ring_only(R::T, s::Vector{Symbol}; internal_ordering::Symbol=:lex, cached::Bool=true) where T<:Ring
1512+
@req !is_trivial(R) "Zero rings are currently not supported as coefficient ring."
1513+
return mpoly_ring_type(T)(R, s, internal_ordering, cached)
1514+
end

src/MatRing.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,5 +446,6 @@ Return parent object corresponding to the ring of $n\times n$ matrices over
446446
the ring $R$.
447447
"""
448448
function matrix_ring(R::NCRing, n::Int)
449-
Generic.matrix_ring(R, n)
449+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
450+
return Generic.matrix_ring(R, n)
450451
end

src/Matrix.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6653,6 +6653,7 @@ julia> using LinearAlgebra ; matrix(GF(5), I(2))
66536653
"""
66546654
function matrix(R::NCRing, arr::AbstractMatrix{T}) where {T}
66556655
Base.require_one_based_indexing(arr)
6656+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
66566657
if elem_type(R) === T && all(e -> parent(e) === R, arr)
66576658
z = Generic.MatSpaceElem{elem_type(R)}(R, arr)
66586659
return z
@@ -6664,6 +6665,7 @@ function matrix(R::NCRing, arr::AbstractMatrix{T}) where {T}
66646665
end
66656666

66666667
function matrix(R::NCRing, arr::MatElem)
6668+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
66676669
return map_entries(R, arr)
66686670
end
66696671

@@ -6702,6 +6704,7 @@ Constructs the $r \times c$ matrix over $R$, where the entries are taken
67026704
row-wise from `arr`.
67036705
"""
67046706
function matrix(R::NCRing, r::Int, c::Int, arr::AbstractVecOrMat{T}) where T
6707+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
67056708
_check_dim(r, c, arr)
67066709
ndims(arr) == 2 && return matrix(R, arr)
67076710
if elem_type(R) === T && all(e -> parent(e) === R, arr)
@@ -7086,6 +7089,7 @@ the ring $R$.
70867089
function matrix_space(R::NCRing, r::Int, c::Int; cached::Bool = true)
70877090
# TODO: the 'cached' argument is ignored and mainly here for backwards compatibility
70887091
# (and perhaps future compatibility, in case we need it again)
7092+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
70897093
(r < 0 || c < 0) && error("Dimensions must be non-negative")
70907094
T = elem_type(R)
70917095
return MatSpace{T}(R, r, c)

src/NCPoly.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,10 @@ end
764764
Like [`polynomial_ring(R::NCRing, s::Symbol)`](@ref) but return only the
765765
polynomial ring.
766766
"""
767-
polynomial_ring_only(R::T, s::Symbol; cached::Bool=true) where T<:NCRing =
768-
dense_poly_ring_type(T)(R, s, cached)
767+
function polynomial_ring_only(R::T, s::Symbol; cached::Bool=true) where T<:NCRing
768+
@req !is_trivial(R) "Zero rings are currently not supported as coefficient ring."
769+
return dense_poly_ring_type(T)(R, s, cached)
770+
end
769771

770772
# Simplified constructor
771773

src/Residue.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ to the constructor with the same base ring $R$ and element $a$. A modulus
450450
of zero is not supported and throws an exception.
451451
"""
452452
function residue_ring(R::Ring, a::RingElement; cached::Bool = true)
453+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
453454
# Modulus of zero cannot be supported. E.g. A C library could not be expected to
454455
# do matrices over Z/0 using a Z/nZ type. The former is multiprecision, the latter not.
455456
iszero(a) && throw(DomainError(a, "Modulus must be nonzero"))
@@ -459,6 +460,7 @@ function residue_ring(R::Ring, a::RingElement; cached::Bool = true)
459460
end
460461

461462
function residue_ring(R::PolyRing, a::RingElement; cached::Bool = true)
463+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
462464
iszero(a) && throw(DomainError(a, "Modulus must be nonzero"))
463465
!is_unit(leading_coefficient(a)) && throw(DomainError(a, "Non-invertible leading coefficient"))
464466
T = elem_type(R)

src/ResidueField.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ residue ring parent object is cached and returned for any subsequent calls
490490
to the constructor with the same base ring $R$ and element $a$.
491491
"""
492492
function residue_field(R::Ring, a::RingElement; cached::Bool = true)
493+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
493494
iszero(a) && throw(DivideError())
494495
T = elem_type(R)
495496
S = EuclideanRingResidueField{T}(R(a), cached)

0 commit comments

Comments
 (0)