From 2e37a9ea3b5ca14d8995ee8816eaae26c97eb477 Mon Sep 17 00:00:00 2001 From: Rafael Fourquet Date: Wed, 4 Nov 2020 18:21:42 +0100 Subject: [PATCH 1/2] make MatrixSpace <: AA.MatSpace --- src/matrix/MatrixTypes.jl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/matrix/MatrixTypes.jl b/src/matrix/MatrixTypes.jl index 1676de079..47eada505 100644 --- a/src/matrix/MatrixTypes.jl +++ b/src/matrix/MatrixTypes.jl @@ -1,12 +1,10 @@ ############################################################################### # -# MatrixSpace/smatrix +# MatrixSpace/smatrix # ############################################################################### -const MatrixSpaceID = Dict{Tuple{PolyRing, Int, Int}, Set}() - -mutable struct MatrixSpace{T <: Nemo.RingElem} <: Set +mutable struct MatrixSpace{T <: Nemo.RingElem} <: AbstractAlgebra.MatSpace{T} base_ring::PolyRing nrows::Int ncols::Int @@ -20,7 +18,9 @@ mutable struct MatrixSpace{T <: Nemo.RingElem} <: Set end end -mutable struct smatrix{T <: Nemo.RingElem} <: Nemo.SetElem +const MatrixSpaceID = Dict{Tuple{PolyRing, Int, Int}, MatrixSpace}() + +mutable struct smatrix{T <: Nemo.RingElem} <: AbstractAlgebra.MatElem{T} ptr::libSingular.matrix_ptr base_ring::PolyRing @@ -43,4 +43,3 @@ end function _smatrix_clear_fn(I::smatrix) libSingular.mp_Delete(I.ptr, I.base_ring.ptr) end - From ccd9d6bfc37e8b1a996461e35e8a44e868431c37 Mon Sep 17 00:00:00 2001 From: Rafael Fourquet Date: Wed, 4 Nov 2020 19:03:27 +0100 Subject: [PATCH 2/2] add tests for random matrices --- test/matrix/smatrix-test.jl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/matrix/smatrix-test.jl b/test/matrix/smatrix-test.jl index 44343a210..ccd080d72 100644 --- a/test/matrix/smatrix-test.jl +++ b/test/matrix/smatrix-test.jl @@ -102,3 +102,20 @@ end @test M1 == M1 @test M1 == deepcopy(M1) end + +@testset "smatrix.rand..." begin + F = Fp(7) + R, _ = PolynomialRing(F, ["x"]) + m = identity_matrix(R, 3) + M = parent(m) + + f = rand(M, 1:2, 1:2) + @test parent(f) == M + + R, _ = PolynomialRing(ZZ, ["x"]) + m = identity_matrix(R, 3) + M = parent(m) + + f = rand(M, 1:2, 1:2, 1:2) + @test parent(f) == M +end