diff --git a/src/generic/GenericTypes.jl b/src/generic/GenericTypes.jl index 54958e7b56..d16f75f549 100644 --- a/src/generic/GenericTypes.jl +++ b/src/generic/GenericTypes.jl @@ -1068,6 +1068,11 @@ struct MatSpaceElem{T <: NCRingElement} <: Mat{T} end end +function MatSpaceElem{T}(R::NCRing, ::UndefInitializer, r::Int, c::Int) + t = Matrix{T}(undef, r, c) + return MatSpaceElem{T}(R, t) +end + function MatSpaceElem{T}(R::NCRing, A::AbstractMatrix{T}) where T <: NCRingElement return MatSpaceElem{T}(R, Matrix(A)) end diff --git a/src/generic/Matrix.jl b/src/generic/Matrix.jl index a1f63b726b..adfd3421e9 100644 --- a/src/generic/Matrix.jl +++ b/src/generic/Matrix.jl @@ -59,23 +59,11 @@ Base.isassigned(a::Union{Mat,MatRingElem}, i, j) = isassigned(a.entries, i, j) ################################################################################ function copy(d::MatSpaceElem{T}) where T <: NCRingElement - z = similar(d) - for i = 1:nrows(d) - for j = 1:ncols(d) - z[i, j] = d[i, j] - end - end - return z + return MatSpaceElem{T}(base_ring(d), copy(d.entries)) end function deepcopy_internal(d::MatSpaceElem{T}, dict::IdDict) where T <: NCRingElement - z = similar(d) - for i = 1:nrows(d) - for j = 1:ncols(d) - z[i, j] = deepcopy_internal(d[i, j], dict) - end - end - return z + return MatSpaceElem{T}(base_ring(d), deepcopy_internal(d.entries, dict)) end function deepcopy_internal(d::MatSpaceView{T}, dict::IdDict) where T <: NCRingElement