Skip to content

Commit

Permalink
Add is_finite methods for various ring types
Browse files Browse the repository at this point in the history
Also add missing (but documented) `characteristic` method for
`FreeAssociativeAlgebra`
  • Loading branch information
fingolfin committed Oct 10, 2024
1 parent 69ba0a5 commit af60fd0
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/FreeAssociativeAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function is_exact_type(a::Type{S}) where {T <: RingElement, S <: FreeAssociative
return is_exact_type(T)
end

characteristic(R::FreeAssociativeAlgebra) = characteristic(base_ring(R))

is_finite(R::FreeAssociativeAlgebra) = is_trivial(base_ring(R)) || (nvars(R) == 0 && is_finite(base_ring(R)))

###############################################################################
#
# String IO
Expand Down
10 changes: 10 additions & 0 deletions src/LaurentMPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
#
###############################################################################

###############################################################################
#
# Data type and parent object methods
#
###############################################################################

characteristic(R::LaurentMPolyRing) = characteristic(base_ring(R))

is_finite(R::LaurentMPolyRing) = characteristic(a) == 1 || (nvars(R) == 0 && is_finite(base_ring(R)))

###############################################################################
#
# String I/O
Expand Down
10 changes: 10 additions & 0 deletions src/LaurentPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
#
###############################################################################

###############################################################################
#
# Data type and parent object methods
#
###############################################################################

characteristic(R::LaurentPolyRing) = characteristic(base_ring(R))

is_finite(R::LaurentPolyRing) = is_trivial(R)

###############################################################################
#
# laurent_polynomial_ring constructor
Expand Down
7 changes: 4 additions & 3 deletions src/MPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ function var_index(x::MPolyRingElem{T}) where {T <: RingElement}
return index
end

function characteristic(a::MPolyRing{T}) where T <: RingElement
return characteristic(base_ring(a))
end
characteristic(R::MPolyRing) = characteristic(base_ring(R))

is_finite(R::MPolyRing) = is_trivial(base_ring(R)) || (nvars(R) == 0 && is_finite(base_ring(R)))


###############################################################################
#
Expand Down
2 changes: 2 additions & 0 deletions src/MatRing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ function characteristic(a::MatRing)
return characteristic(base_ring(a))
end

is_finite(R::MatRing) = iszero(a.n) || is_finite(base_ring(R))

###############################################################################
#
# Similar and zero
Expand Down
2 changes: 2 additions & 0 deletions src/NCPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ number_of_variables(a::NCPolyRing) = 1

characteristic(a::NCPolyRing) = characteristic(base_ring(a))

is_finite(a::NCPolyRing) = is_trivial(a)

###############################################################################
#
# Basic manipulation
Expand Down
2 changes: 2 additions & 0 deletions src/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ number_of_variables(a::PolyRing) = 1

characteristic(a::PolyRing) = characteristic(base_ring(a))

is_finite(a::PolyRing) = is_trivial(a)

Base.copy(a::PolyRingElem) = deepcopy(a)

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion src/Rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,4 @@ is_perfect(F::Field) = characteristic(F) == 0 || F isa FinField ||

is_finite(F::FinField) = true

is_finite(F::Field) = characteristic(F) != 0 && throw(NotImplementedError(:is_finite, F))
is_finite(R::NCRing) = characteristic(R) != 0 && throw(NotImplementedError(:is_finite, R))
2 changes: 0 additions & 2 deletions src/generic/LaurentMPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ number_of_variables(R::LaurentMPolyWrapRing) = number_of_variables(R.mpolyring)

number_of_generators(R::LaurentMPolyWrapRing) = number_of_variables(R.mpolyring)

characteristic(R::LaurentMPolyWrapRing) = characteristic(R.mpolyring)

###############################################################################
#
# Basic manipulation
Expand Down

0 comments on commit af60fd0

Please sign in to comment.