Skip to content

Commit

Permalink
Some MatrixRing fixes (#1852)
Browse files Browse the repository at this point in the history
* Error on MatrixRing of size -1
* Fix characteristic of `matrix_ring(R, 0)`
  • Loading branch information
lgoettgens authored Oct 9, 2024
1 parent 502745e commit 709f421
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/MatRing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ end


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

Expand Down
1 change: 1 addition & 0 deletions src/generic/MatRing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ end
function matrix_ring(R::AbstractAlgebra.NCRing, n::Int; cached::Bool = true)
# TODO: the 'cached' argument is ignored and mainly here for backwards compatibility
# (and perhaps future compatibility, in case we need it again)
@req n >= 0 "n must be a non-negative integer"
T = elem_type(R)
return MatRing{T}(R, n)
end
4 changes: 4 additions & 0 deletions test/generic/MatRing-test.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@testset "Generic.MatAlg.constructors" begin
R, t = polynomial_ring(QQ, "t")
@test_throws ArgumentError matrix_ring(R, -1)

S = matrix_ring(R, 3)

@test S === matrix_ring(R, 3)
Expand Down Expand Up @@ -177,6 +179,8 @@ end
@test is_zero_column(M, 1)

@test degree(M) == 2

@test characteristic(matrix_ring(R, 0)) == 1
end

@testset "Generic.MatAlg.size/axes" begin
Expand Down

0 comments on commit 709f421

Please sign in to comment.