Skip to content

Commit e26b4c9

Browse files
committed
Add many @req !is_trivial checks
1 parent 9ebc781 commit e26b4c9

18 files changed

+47
-16
lines changed

docs/src/constructors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ AbstractAlgebra.jl and explain what mathematical domains they represent.
7474
| $S = K((x))$ (to precision $n$) | `S, x = laurent_series_field(K, n, :x)` |
7575
| $S = R((x, y))$ (to precision $n$) | `S, (x, y) = laurent_polynomial_ring(R, n, [:x, :y])` |
7676
| Puiseux series ring to precision $n$ | `S, x = puiseux_series_ring(R, n, :x)` |
77-
| Puiseux series field to precision $n$| `S, x = puiseux_series_field(R, n, :x)` |
77+
| Puiseux series field to precision $n$| `S, x = puiseux_series_field(K, n, :x)` |
7878
| $S = K(x)(y)/(f)$ | `S, y = function_field(f, :y)` with $f\in K(x)[t]$ |
7979
| $S = \mathrm{Frac}_R$ | `S = fraction_field(R)` |
8080
| $S = R/(f)$ | `S, = residue_ring(R, f)` |

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/FreeAssociativeAlgebra.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ function free_associative_algebra(
270270
s::Vector{Symbol};
271271
cached::Bool = true,
272272
)
273+
@req !is_trivial(R) "Zero rings are currently not supported as coefficient ring."
273274
parent_obj = Generic.FreeAssociativeAlgebra{elem_type(R)}(R, s, cached)
274275
return (parent_obj, gens(parent_obj))
275276
end

src/LaurentPoly.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,7 @@ julia> rand(R, -3:3, -9:9)
3939
-3*x^2 - 8*x + 4 + 3*x^-1 - 6*x^-2 + 9*x^-3
4040
```
4141
"""
42-
laurent_polynomial_ring(R::Ring, s::VarName; cached::Bool = true) =
43-
Generic.laurent_polynomial_ring(R, Symbol(s); cached)
42+
function laurent_polynomial_ring(R::Ring, s::VarName; cached::Bool = true)
43+
@req !is_trivial(R) "Zero rings are currently not supported as coefficient ring."
44+
return Generic.laurent_polynomial_ring(R, Symbol(s); cached)
45+
end

src/LaurentSeries.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ object `S` will be cached so that supplying the same base ring, string and
2424
precision in future will return the same parent object and generator. If
2525
caching of the parent object is not required, `cached` can be set to `false`.
2626
"""
27-
laurent_series_ring(R::Ring, prec::Int, s::VarName; cached::Bool=true) =
28-
Generic.laurent_series_ring(R, prec, Symbol(s); cached)
27+
function laurent_series_ring(R::Ring, prec::Int, s::VarName; cached::Bool=true)
28+
@req !is_trivial(R) "Zero rings are currently not supported as coefficient ring."
29+
return Generic.laurent_series_ring(R, prec, Symbol(s); cached)
30+
end
2931

3032
@doc raw"""
3133
laurent_series_field(R::Field, prec::Int, s::VarName; cached::Bool=true)

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
@@ -441,5 +441,6 @@ Return parent object corresponding to the ring of $n\times n$ matrices over
441441
the ring $R$.
442442
"""
443443
function matrix_ring(R::NCRing, n::Int)
444-
Generic.matrix_ring(R, n)
444+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
445+
return Generic.matrix_ring(R, n)
445446
end

src/Matrix.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6633,6 +6633,7 @@ randmat_with_rank(S::MatSpace{T}, rank::Int, v...) where {T <: RingElement} =
66336633
Constructs the matrix over $R$ with entries as in `arr`.
66346634
"""
66356635
function matrix(R::NCRing, arr::AbstractMatrix{T}) where {T}
6636+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
66366637
if elem_type(R) === T && all(e -> parent(e) === R, arr)
66376638
z = Generic.MatSpaceElem{elem_type(R)}(R, arr)
66386639
return z
@@ -6643,6 +6644,7 @@ function matrix(R::NCRing, arr::AbstractMatrix{T}) where {T}
66436644
end
66446645

66456646
function matrix(R::NCRing, arr::MatElem)
6647+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
66466648
return map_entries(R, arr)
66476649
end
66486650

@@ -6681,6 +6683,7 @@ Constructs the $r \times c$ matrix over $R$, where the entries are taken
66816683
row-wise from `arr`.
66826684
"""
66836685
function matrix(R::NCRing, r::Int, c::Int, arr::AbstractVecOrMat{T}) where T
6686+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
66846687
_check_dim(r, c, arr)
66856688
ndims(arr) == 2 && return matrix(R, arr)
66866689
if elem_type(R) === T && all(e -> parent(e) === R, arr)
@@ -7062,6 +7065,7 @@ the ring $R$.
70627065
function matrix_space(R::NCRing, r::Int, c::Int; cached::Bool = true)
70637066
# TODO: the 'cached' argument is ignored and mainly here for backwards compatibility
70647067
# (and perhaps future compatibility, in case we need it again)
7068+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
70657069
(r < 0 || c < 0) && error("Dimensions must be non-negative")
70667070
T = elem_type(R)
70677071
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/PuiseuxSeries.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ object `S` will be cached so that supplying the same base ring, string and
2424
precision in future will return the same parent object and generator. If
2525
caching of the parent object is not required, `cached` can be set to `false`.
2626
"""
27-
puiseux_series_ring(R::Ring, prec::Int, s::VarName; cached::Bool=true) =
28-
Generic.PuiseuxSeriesRing(R, prec, Symbol(s); cached)
27+
function puiseux_series_ring(R::Ring, prec::Int, s::VarName; cached::Bool=true)
28+
@req !is_trivial(R) "Zero rings are currently not supported as coefficient ring."
29+
return Generic.PuiseuxSeriesRing(R, prec, Symbol(s); cached)
30+
end
2931

30-
puiseux_series_field(R::Field, prec::Int, s::VarName; cached::Bool=true) =
31-
Generic.PuiseuxSeriesField(R, prec, Symbol(s); cached)
32+
function puiseux_series_field(R::Field, prec::Int, s::VarName; cached::Bool=true)
33+
return Generic.PuiseuxSeriesField(R, prec, Symbol(s); cached)
34+
end

0 commit comments

Comments
 (0)