Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add is_finite methods for various ring types #1842

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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)))

Check warning on line 25 in src/FreeAssociativeAlgebra.jl

View check run for this annotation

Codecov / codecov/patch

src/FreeAssociativeAlgebra.jl#L25

Added line #L25 was not covered by tests

###############################################################################
#
# 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) = is_trivial(base_ring(R)) || (nvars(R) == 0 && is_finite(base_ring(R)))

Check warning on line 15 in src/LaurentMPoly.jl

View check run for this annotation

Codecov / codecov/patch

src/LaurentMPoly.jl#L15

Added line #L15 was not covered by tests

###############################################################################
#
# 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))

Check warning on line 13 in src/LaurentPoly.jl

View check run for this annotation

Codecov / codecov/patch

src/LaurentPoly.jl#L13

Added line #L13 was not covered by tests

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

Check warning on line 15 in src/LaurentPoly.jl

View check run for this annotation

Codecov / codecov/patch

src/LaurentPoly.jl#L15

Added line #L15 was not covered by tests

###############################################################################
#
# 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 @@
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)))

Check warning on line 143 in src/MPoly.jl

View check run for this annotation

Codecov / codecov/patch

src/MPoly.jl#L143

Added line #L143 was not covered by tests


###############################################################################
#
Expand Down
4 changes: 3 additions & 1 deletion src/MatRing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@


function characteristic(a::MatRing)
iszero(a.n) && return 1
iszero(nrows(a)) && return 1
return characteristic(base_ring(a))
end

is_finite(R::MatRing) = iszero(nrows(a)) || is_finite(base_ring(R))

Check warning on line 73 in src/MatRing.jl

View check run for this annotation

Codecov / codecov/patch

src/MatRing.jl#L73

Added line #L73 was not covered by tests

###############################################################################
#
# 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 @@

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

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

Check warning on line 105 in src/NCPoly.jl

View check run for this annotation

Codecov / codecov/patch

src/NCPoly.jl#L105

Added line #L105 was not covered by tests

###############################################################################
#
# 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 @@

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

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

Check warning on line 52 in src/Poly.jl

View check run for this annotation

Codecov / codecov/patch

src/Poly.jl#L52

Added line #L52 was not covered by tests

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

###############################################################################
Expand Down
7 changes: 6 additions & 1 deletion src/Rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,9 @@

is_finite(F::FinField) = true

is_finite(F::Field) = characteristic(F) != 0 && throw(NotImplementedError(:is_finite, F))
function is_finite(R::NCRing)
c = characteristic(R)
c == 0 && return false
c == 1 && return true
throw(NotImplementedError(:is_finite, R))

Check warning on line 214 in src/Rings.jl

View check run for this annotation

Codecov / codecov/patch

src/Rings.jl#L213-L214

Added lines #L213 - L214 were not covered by tests
end
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
Loading